[Draft] Force to draft in current workplane
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
[Draft] Force to draft in current workplane
Hi,
It is possible to make that all the points of the geometry in the course of drawing is constrained in the surface of current workplane ? And this even when one makes use of the snaps tool like intersection and that this intersection is not in the plan of current workplane ?
It is possible to make that all the points of the geometry in the course of drawing is constrained in the surface of current workplane ? And this even when one makes use of the snaps tool like intersection and that this intersection is not in the plan of current workplane ?
Formations - Assistance - Développement : https://freecad-france.com
Re: [Draft] Force to draft in current workplane
Hi rockn, I'm pretty sure that at present there is no such a FreeCAD tool but I'm no expert.rockn wrote:... even when one makes use of the snaps tool like intersection and that this intersection is not in the plan of current workplane ?
I have used a similar tool to what you've described, in other CAD program(s) as something like "Apparent Intersection" or some similar name. From your other posts I can see how this would be a quite useful tool for you, as it would be for others. It would be handy for measuring distances too. We'll wait and see the thoughts of others about this...
Re: [Draft] Force to draft in current workplane
It's actually a good idea... What I usually do is press Shift to constrain in one direction, then you can snap outside of the working plane. But indeed a kind of "lock" that would force the point on the WP would be pretty interesting. I'll open a ticket: issue #1461rockn wrote:It is possible to make that all the points of the geometry in the course of drawing is constrained in the surface of current workplane ? And this even when one makes use of the snaps tool like intersection and that this intersection is not in the plan of current workplane ?
Re: [Draft] Force to draft in current workplane
Hi,
Thanks for the Mantis Ticket. I would help me a lot, because I'm working a lot in another direction than x or y so the Shift constrain don't help me.
I can draw my line in any direction by initially drawing the two edges perpendicular of the right-angled triangle by helping me of Shift. The hypotenuse will be my line.
But the force workplane lock snap mode will facilitate the operation.
Thanks for the Mantis Ticket. I would help me a lot, because I'm working a lot in another direction than x or y so the Shift constrain don't help me.
I can draw my line in any direction by initially drawing the two edges perpendicular of the right-angled triangle by helping me of Shift. The hypotenuse will be my line.
But the force workplane lock snap mode will facilitate the operation.

Formations - Assistance - Développement : https://freecad-france.com
Re: [Draft] Force to draft in current workplane
Thank you very much Yorik for the fix 1461.
I'm playing with it and work like a charm.
I am now thinking (and searching) that I just need to place the camera in front of the working plane to be in perfect conditions to draw my pieces of wood.
I don't find a lot of thing about View orientation.
I try something like : "Gui.ActiveDocument.ActiveView.setCameraOrientation(0.0,-0.0,1.0)"
But the console say to me that .setCameraOrientation need a tuple... and I don't know where I can get it ? I think it need the normal of the working plane.
In any case thank you again for the WP snap mode.
I'm playing with it and work like a charm.
I am now thinking (and searching) that I just need to place the camera in front of the working plane to be in perfect conditions to draw my pieces of wood.
I don't find a lot of thing about View orientation.
I try something like : "Gui.ActiveDocument.ActiveView.setCameraOrientation(0.0,-0.0,1.0)"
But the console say to me that .setCameraOrientation need a tuple... and I don't know where I can get it ? I think it need the normal of the working plane.
In any case thank you again for the WP snap mode.

Formations - Assistance - Développement : https://freecad-france.com
Re: [Draft] Force to draft in current workplane
I don't remember exactly and I cant test right now, but in any case you are giving it 3 separate arguments... If it needs a tuple, you need to do: setCameraOrientation( (0.0,-0.0,1.0) ) but there might be something else needed too.
Have a search in the source code, or on the wiki, or on the forum, there is certainly an example of how to use it...
Have a search in the source code, or on the wiki, or on the forum, there is certainly an example of how to use it...
Re: [Draft] Force to draft in current workplane
Ok, the right command is something like this :
FreeCADGui.ActiveDocument.ActiveView.setCameraOrientation( (0.0, 0.0, 1.0, 0.0) )
I see in Sketcher WB code something like this :
https://github.com/FreeCAD/FreeCAD_sf_m ... ommand.cpp line 407
Now I try to get the placement of the selected face.
With this code I get the same "tuple" whatever the selected face.
Why the placement isn't different when I selected different face ?
FreeCADGui.ActiveDocument.ActiveView.setCameraOrientation( (0.0, 0.0, 1.0, 0.0) )
I see in Sketcher WB code something like this :
https://github.com/FreeCAD/FreeCAD_sf_m ... ommand.cpp line 407
Code: Select all
doCommand(Gui,"Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.%s.Placement.Rotation.Q)"
With this code I get the same "tuple" whatever the selected face.
Code: Select all
s=Gui.Selection.getSelectionEx()
obj=s[0]
faceSel = obj.SubObjects[0]
FreeCADGui.ActiveDocument.ActiveView.setCameraOrientation( faceSel.Placement.Rotation.Q )
Formations - Assistance - Développement : https://freecad-france.com
Re: [Draft] Force to draft in current workplane
I think the placement is only one for each shape, there is no difference for each face... I think the line you took is when you are editing an existing sketch, so you are actually using the placement of the sketch.
You could take the normal of your face with faceSel.normalAt(0,0) and extract the rotation value from it (not sure how to do that,though), but it is maybe easier to do this with pivy, since coin allows you to give a "target point" to orient a camera ( http://www-evasion.imag.fr/~Francois.Fa ... amera.html )
Probably something like this (untested):
You could take the normal of your face with faceSel.normalAt(0,0) and extract the rotation value from it (not sure how to do that,though), but it is maybe easier to do this with pivy, since coin allows you to give a "target point" to orient a camera ( http://www-evasion.imag.fr/~Francois.Fa ... amera.html )
Probably something like this (untested):
Code: Select all
from pivy import coin
dir = faceSel.normalAt(0,0)
cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
pos = FreeCAD.Vector( cam.position.getValue().getValue() )
p = pos.add(dir)
cam.pointAt( coin.SbVec3f(p.x,p.y,p.z) )
Re: [Draft] Force to draft in current workplane
Thank you Yorik.
I'm close to get it with this code :
I'm close to get it with this code :
Code: Select all
from pivy import coin
s=Gui.Selection.getSelectionEx()
obj=s[0]
faceSel = obj.SubObjects[0]
dir = faceSel.normalAt(0,0)
cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
camValues = cam.position.getValue()
pos = FreeCAD.Vector( (camValues[0], camValues[1], camValues[2],) )
p = pos.add(dir.negative())
cam.pointAt( coin.SbVec3f(p.x,p.y,p.z) )
Gui.SendMsgToActiveView("ViewFit")
Formations - Assistance - Développement : https://freecad-france.com
Re: [Draft] Force to draft in current workplane
So I share with you this macro to set the current view perpendicular to the selected face.
Code: Select all
# -*- coding: utf-8 -*-
# Set the current view perpendicular to the selected face
# Place la vue perpendiculairement à la face selectionnee
# 2013 Jonathan Wiedemann
from pivy import coin
s=Gui.Selection.getSelectionEx()
obj=s[0]
faceSel = obj.SubObjects[0]
dir = faceSel.normalAt(0,0)
cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
camValues = cam.position.getValue()
pos = FreeCAD.Vector( (camValues[0], camValues[1], camValues[2],) )
p = pos.add(dir.negative())
print(p.x,p.y,p.z)
if dir.z == 1 :
cam.pointAt( coin.SbVec3f(p.x,p.y,p.z), coin.SbVec3f(0.0,1.0,0.0))
print("normal = 1")
elif dir.z == -1 :
cam.pointAt( coin.SbVec3f(p.x,p.y,p.z), coin.SbVec3f(0.0,1.0,0.0))
print("normal = -1")
else :
cam.pointAt( coin.SbVec3f(p.x,p.y,p.z), coin.SbVec3f(0.0,0.0,1.0))
print("normal normale")
Gui.SendMsgToActiveView("ViewSelection")
Formations - Assistance - Développement : https://freecad-france.com