Advertisement
danfalck

selection shape2DView

Sep 3rd, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. from FreeCAD import Base, Vector
  2. import FreeCAD,FreeCADGui,Part
  3. import Drawing
  4.  
  5. sel = FreeCADGui.Selection.getSelection()
  6.  
  7. for o in sel:
  8.     solid = o.Shape
  9.  
  10.  
  11. #get the outside shape of the profile:
  12.  
  13. proj = Part.Shape
  14. [visibleG0,visibleG1,hiddenG0,hiddenG1] = Drawing.project(solid,Vector(0,0,-1))
  15. proj = visibleG0
  16. proj.rotate(Vector(0,0,0), Vector(0,1,0), 180)
  17. outerProfile=FreeCAD.ActiveDocument.addObject("Part::Feature","Outside_Profile")
  18. outerProfile.Shape = proj # <- outer profile
  19.  
  20. FreeCAD.activeDocument().recompute()
  21.  
  22. #select individual faces to get their profiles -for pockets and open pockets
  23.  
  24. objGeom=[]
  25. s=Gui.Selection.getSelectionEx()
  26. for i in s:
  27.     for e in i.SubElementNames:
  28.         objGeom.append(getattr(i.Object.Shape,e))
  29.  
  30. face = objGeom[0]
  31.  
  32. [visibleG0,visibleG1,hiddenG0,hiddenG1] = Drawing.project(face,Vector(0,0,-1))
  33. proj2 = Part.Shape
  34. proj2 = visibleG0
  35. proj2.rotate(Vector(0,0,0), Vector(0,1,0), 180)
  36. pocket =FreeCAD.ActiveDocument.addObject("Part::Feature","Pocket")
  37. pocket.Shape = proj2
  38. FreeCAD.activeDocument().recompute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement