MACRO:Work Feature 2014_12
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: MACRO:Work Feature 2014_12
mario52 I did as you wrote but I got the message:
NameError: name 'NormalA' is not defined.
Thanks anyway.
NameError: name 'NormalA' is not defined.
Thanks anyway.
Re: MACRO:Work Feature 2014_12
hi
@manos try this
mario
@manos try this
Code: Select all
## original code by JMG https://forum.freecadweb.org/viewtopic.php?f=22&t=9056&start=60#p79922
## 05/06/2021
## Mario52
## https://forum.freecadweb.org/viewtopic.php?f=22&t=9056&start=210
import Draft, Part
SelObj = Gui.Selection.getSelectionEx()
Sel = Gui.Selection.getSelection()
tolerance = 1e-10
try: # verify if 2 faces hare selected
face = 0
if SelObj[0].SubObjects[0].ShapeType == "Face":
face+=1
try:
if SelObj[1].SubObjects[0].ShapeType == "Face":
face+=1
except Exception:
try:
if SelObj[0].SubObjects[1].ShapeType == "Face":
face+=1
except Exception:
print("Oups Bad selection")
if face == 2:
try:
NormalA = SelObj[0].SubObjects[0].normalAt(0,0)
VAB = (SelObj[1].SubObjects[0].CenterOfMass-SelObj[0].SubObjects[0].CenterOfMass).normalize()
#print("(1) ",NormalA," ",VAB)
except Exception:
try:
fa = int(SelObj[1].SubElementNames[0][4:])
NormalA = Sel[1].Shape.Faces[fa - 1].normalAt(0,0)
VAB = (Sel[0].Shape.CenterOfMass-SelObj[1].SubObjects[0].CenterOfMass).normalize()
#print("(2) ",NormalA," ",VAB)
except Exception:
try:
NormalA = SelObj[0].SubObjects[0].normalAt(0,0)
VAB = (SelObj[0].SubObjects[0].CenterOfMass-SelObj[0].SubObjects[1].CenterOfMass).normalize()
#print("(3) ",NormalA," ",VAB)
except Exception:
try:
NormalA = Sel[1].Shape.Faces[0].normalAt(0,0)
VAB = (Sel[0].Shape.CenterOfMass-Sel[1].Shape.CenterOfMass).normalize()
#print("(4) ",NormalA," ",VAB)
except Exception:
#print("Oups")
None
try:
#print(NormalA.dot(VAB))
if NormalA.dot(VAB) == 0.0:
FreeCAD.Console.PrintMessage("\nCoplanar faces \n")
else:
FreeCAD.Console.PrintMessage("\nNon coplanar faces \n")
except Exception:
print("Oups Non VAB value")
else:
print("Oups select 2 faces")
except Exception:
print("Oups Bad selection")
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: MACRO:Work Feature 2014_12
I tried. So far so good.
Will you include it in a next version of Workfeatures macro ?
Thanks Mario52
Will you include it in a next version of Workfeatures macro ?
Thanks Mario52
Re: MACRO:Work Feature 2014_12
Hi
unzip the file and copy this new file WF.py in WorkFeature mod instead the original WF.py
and report ...
mario
unzip the file and copy this new file WF.py in WorkFeature mod instead the original WF.py
and report ...
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: MACRO:Work Feature 2014_12
mario52 I copied the WF.py to the folder: /home/manosd/.freeCAD/Macros .
I am not sure that it is the appropriate folder because of the file I attached.
Any hint ?
I am not sure that it is the appropriate folder because of the file I attached.
Any hint ?
- Attachments
-
- start_WF_WorkFeature.FCMacro
- (1.94 KiB) Downloaded 55 times
Re: MACRO:Work Feature 2014_12
hi
not the good folder, in Windows the folder is
/home/manosd/.freeCAD/Macros is the macros folder (start_WF_WorkFeature.FCMacro is the lauch macro for WorkFeature)
see in (search and replace the WF.py macro)
mario
not the good folder, in Windows the folder is
Code: Select all
C:\Users\UserName\AppData\Roaming\FreeCAD\Mod\WorkFeature\WorkFeature
/home/manosd/.freeCAD/Macros is the macros folder (start_WF_WorkFeature.FCMacro is the lauch macro for WorkFeature)
see in (search and replace the WF.py macro)
Code: Select all
/home/manosd/.freeCAD/Mod/WorkFeature/WorkFeature
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: MACRO:Work Feature 2014_12
Thanks mario52 I will try it.
- Charles Gull
- Posts: 6
- Joined: Thu Aug 12, 2021 5:02 am
Re: MACRO:Work Feature 2014_12
Hello,
I like the look of this macro and it's listed features hold greatpromise.
I am having a problem with creating an axis between two planes.
If I select two plannar surfaces from my model and axis is created, no problem.
If one, or both, of the plannar surfaces is a datum plane, it fails. Error message says that the selections are parallel. I should change my selection. They are very muchnot parallel.
I like the look of this macro and it's listed features hold greatpromise.
I am having a problem with creating an axis between two planes.
If I select two plannar surfaces from my model and axis is created, no problem.
If one, or both, of the plannar surfaces is a datum plane, it fails. Error message says that the selections are parallel. I should change my selection. They are very muchnot parallel.
Re: MACRO:Work Feature 2014_12
hi
I think WF is not yet adapted for the datum plane
want to give an example file fot testing
and the command used (maybe Axis Plane/Plane) ?
mario
I think WF is not yet adapted for the datum plane
want to give an example file fot testing
and the command used (maybe Axis Plane/Plane) ?
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.