Hi, it seems i am not familiar / confused by those geometrical terms.
Assume a Sketch map on XY plane (regardless of its content) has a Normal (0,0,1) correct?
(Map on XZ plane has a Normal (0,-1,0) )
Try to 'calculate' this Normal, (from the sketch's placement?), searching googling but find no previous discussion.
Any idea? Thanks.
[ Solved ] Normal of a Sketch - Calculate Normal from Placement ?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[ Solved ] Normal of a Sketch - Calculate Normal from Placement ?
Last edited by paullee on Mon Sep 16, 2019 2:40 pm, edited 1 time in total.
Re: Normal of a Sketch - Calculate Normal from Placement ?
I would do :
Code: Select all
normal = sketch.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1))
Re: Normal of a Sketch - Calculate Normal from Placement ?
This is perfect to get the normal vector in the LCS.Chris_G wrote: ↑Sat Sep 14, 2019 8:48 pm I would do :Code: Select all
normal = sketch.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1))
If normal vector in the GCS is needed, just change to :
Code: Select all
normal = sketch.getGlobalPlacement().Rotation.multVec(FreeCAD.Vector(0,0,1))
Re: Normal of a Sketch - Calculate Normal from Placement ?
Thanks both for the solutions!
... I do not understand the correct way to use it ?
Do some exercise, haven't figured out the difference between sketch.Placement and sketch.getGlobalPlacement() :-openBrain wrote: ↑Sat Sep 14, 2019 9:12 pm If normal vector in the GCS is needed, just change to :Code: Select all
normal = sketch.getGlobalPlacement().Rotation.multVec(FreeCAD.Vector(0,0,1))
- Make 2 Sketches
(1st rectangle, 2nd triangle) - Map the 2nd to 1st with ObjectXY mapmode
- Attachment Offset 0,0,50
- With 1st Sketch Placement at 0,0,0, 2nd's Placement / getGlobalPlacement are (0,0,50), so far so good.
Code: Select all
>>> s1.Placement
Placement [Pos=(0,0,0), Yaw-Pitch-Roll=(0,0,0)]
>>> s2.Placement
Placement [Pos=(0,0,50), Yaw-Pitch-Roll=(0,0,0)]
>>> s2.getGlobalPlacement()
Placement [Pos=(0,0,50), Yaw-Pitch-Roll=(0,0,0)]
- Now set 1st Sketch placement to (10,10,10), 2nd sketch move altogether, ok
- 2nd's Placement / getGlobalPlacement both return (10,10,60) ...
Code: Select all
>>> s2.Placement
Placement [Pos=(10,10,60), Yaw-Pitch-Roll=(0,0,0)]
>>> s2.getGlobalPlacement()
Placement [Pos=(10,10,60), Yaw-Pitch-Roll=(0,0,0)]
- Attachments
-
- Test_ Sketch_ Global Placement.FCStd
- (4.68 KiB) Downloaded 18 times
Re: Normal of a Sketch - Calculate Normal from Placement ?
Quite simple when you know.
'Attachment' properties in PartDesign are directly injected in 'Placement', thus changing them makes no difference as it doesn't rely in a LCS.
To demonstrate, you have to use a 'container' that has an LCS, such as Body in the below example (also works with Part container).
In the attached file, 'Sketch' is mapped on XY plane with no offset/rotation.
However I changed the 'Body' Placement to offset 10,10,10 and rotation of 90° around X.
And now we see a difference.
Code: Select all
>>> App.ActiveDocument.Sketch.Placement
Placement [Pos=(0,0,0), Yaw-Pitch-Roll=(0,0,0)]
>>> App.ActiveDocument.Sketch.getGlobalPlacement()
Placement [Pos=(10,10,10), Yaw-Pitch-Roll=(0,0,90)]
- Attachments
-
- GGP.FCStd
- (5.58 KiB) Downloaded 26 times
Re: Normal of a Sketch - Calculate Normal from Placement ?
Thanks, got it and it become quite simple nowopenBrain wrote: ↑Sun Sep 15, 2019 8:29 am
Quite simple when you know.
'Attachment' properties in PartDesign are directly injected in 'Placement', thus changing them makes no difference as it doesn't rely in a LCS.
To demonstrate, you have to use a 'container' that has an LCS, such as Body in the below example (also works with Part container).
In the attached file, 'Sketch' is mapped on XY plane with no offset/rotation.
However I changed the 'Body' Placement to offset 10,10,10 and rotation of 90° around X.
And now we see a difference.Code: Select all
>>> App.ActiveDocument.Sketch.Placement Placement [Pos=(0,0,0), Yaw-Pitch-Roll=(0,0,0)] >>> App.ActiveDocument.Sketch.getGlobalPlacement() Placement [Pos=(10,10,10), Yaw-Pitch-Roll=(0,0,90)]