App::PropertyDirection vs. App::PropertyVector?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8584
Joined: Thu Dec 27, 2018 12:28 pm

App::PropertyDirection vs. App::PropertyVector?

Post by Roy_043 »

Is there a difference between App::PropertyDirection and App::PropertyVector? Both hold a vector and seem identical.
User avatar
dprojects
Posts: 722
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by dprojects »

Roy_043 wrote: Thu Jan 19, 2023 9:49 pm Is there a difference between App::PropertyDirection and App::PropertyVector? Both hold a vector and seem identical.
You mean Part.Vertex vs FreeCAD.Vector?

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
User avatar
onekk
Veteran
Posts: 6222
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by onekk »

They seems the same except for what is contained as data.

they share many things see maybe.

Code: Select all

help(Part.makeCylinder())
as example pnt is the Vector and dir is a Vector but usually "normalized" to Vector(0, 0, 1) Vector(1, 0, 0) and Vector(0, 1, 0) but even complex things like Vector(0.5, 0.5, 0.5) (fake numbers).

but also normals are returned as Vector but are conceptual more similar to an Axis.

We have had some other discussion recently about cylinder orientation where some code was posted.

I could remember wrong but usually a dir is returned "normalized".


@edwilliams16 will for sure correct me. :oops:

Regards

Carlo D.

Edited post to clarify my thoughts and commented out some wrong assumptions.
Last edited by onekk on Fri Jan 20, 2023 5:53 am, edited 1 time in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8584
Joined: Thu Dec 27, 2018 12:28 pm

Re: App::PropertyDirection vs. App::PropertyVector?

Post by Roy_043 »

Apart from the name these property types seem identical, there is no built-in normalization of App::PropertyDirection. For example in the Draft WB App::PropertyDirection is not used at all. I just wonder why App::PropertyDirection exists.
edwilliams16
Veteran
Posts: 3192
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by edwilliams16 »

If I add a Direction Property and set it to (1,1,1), then read it out with Python, it comes back as is - not normalized. Even if I set it to (0,0,0) which is illegal for a direction, it comes back as is. So I would say that it is functionally identical to a Vector.
Rotations make a distinction between RawAxis and the normalized Axis. I'm not sure how to check their Property Types.
I noted that FreeCAD would not accept my changing a Rotation Axis to (0,0,0) - which is good!
User avatar
Chris_G
Veteran
Posts: 2602
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by Chris_G »

edwilliams16 wrote: Fri Jan 20, 2023 12:44 am Rotations make a distinction between RawAxis and the normalized Axis. I'm not sure how to check their Property Types.

Code: Select all

obj.getTypeIdOfProperty("Axis")
edwilliams16
Veteran
Posts: 3192
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by edwilliams16 »

Chris_G wrote: Fri Jan 20, 2023 3:01 pm
edwilliams16 wrote: Fri Jan 20, 2023 12:44 am Rotations make a distinction between RawAxis and the normalized Axis. I'm not sure how to check their Property Types.

Code: Select all

obj.getTypeIdOfProperty("Axis")

Code: Select all

rot = App.Rotation()
What is obj to use obj.getTypeIdOfProperty("Axis"). rot doesn't have that method.
User avatar
Chris_G
Veteran
Posts: 2602
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by Chris_G »

obj is a document object.
edwilliams16
Veteran
Posts: 3192
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by edwilliams16 »

@Chris_G

Code: Select all

doc = App.getDocument("Unnamed10")
obj = doc.getObject("Box")
obj.PropertiesList
['AttacherType', 'AttachmentOffset', 'ExpressionEngine', 'Height', 'Label', 'Label2', 'Length', 'MapMode', 'MapPathParameter', 'MapReversed', 'Placement', 'Shape', 'Support', 'Visibility', 'Width']
How do I drill down to Axis or RawAxis?
User avatar
Chris_G
Veteran
Posts: 2602
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: App::PropertyDirection vs. App::PropertyVector?

Post by Chris_G »

I was just answering on "how to get the type of property".
Post Reply