Get the normal vector of a sketch

Need help, or want to share a macro? Post here!
noone
Posts: 3
Joined: Sun Mar 24, 2019 12:53 pm

Get the normal vector of a sketch

Hello everyone,

this seems to be a simple question, but I used some hours until now without finding a solution.

I need to get the normal vector of a sketch in the coordinate system of the body containing it (or in the global one if the sketch is not within a body).
(Or simpler the vector pointing out of the screen if one opens the sketch in the sketcher-workbench.)

I tried to find something in the documentation, but I found there only the C++ member function Sketcher::Sketch::calculateNormalAtPoint (https://www.freecadweb.org/api/d9/d9b/c ... 92bae4a5c1), and from the code I guess that this method does not even do what I want (it should do something like calculating the normal to a curve at a point in 2D).

Thanks for the help.
openBrain
Posts: 1332
Joined: Fri Nov 09, 2018 5:38 pm

Re: Get the normal vector of a sketch

Considering the normal orientation is along Z axis, following code (with "obj" being the sketch) should do the trick :

Code: Select all

``obj.Placement.Rotation.multVec(App.Vector(0,0,1))``
noone
Posts: 3
Joined: Sun Mar 24, 2019 12:53 pm

Re: Get the normal vector of a sketch

Thanks,

do you mean any sketch has its normal along the positive z-axis in its own coordinates? (I could not create one where this is not the case.)

So it seems like this is the solution i was looking for.
openBrain
Posts: 1332
Joined: Fri Nov 09, 2018 5:38 pm

Re: Get the normal vector of a sketch

noone wrote:
Sun Mar 24, 2019 10:14 pm
do you mean any sketch has its normal along the positive z-axis in its own coordinates? (I could not create one where this is not the case.)
Not exactly. I mean that a sketch rotation is always referenced to the XY plane. In other words, normal to sketch plane is by default along the Z axis.
noone
Posts: 3
Joined: Sun Mar 24, 2019 12:53 pm

OK, thx.