Advertisement
danfalck

highlight_wire_from_selected_edge.py

Jul 30th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. ###########################################################
  2. # select one edge on a solid- preferably one that lies in a horizontal plane
  3. # the rest of the script will deterimine which wire it is part of
  4. # and highlight the rest of the edges in that wire
  5. ###########################################################
  6. import FreeCAD
  7. import FreeCADGui as Gui
  8. import Part
  9.  
  10. sel=Gui.Selection.getSelectionEx()[0].SubObjects
  11. obj=Gui.Selection.getSelection()[0]
  12.  
  13. edge = sel[0]
  14.  
  15. goodface = None
  16.  
  17. for f in obj.Shape.Faces:
  18.     if (f.BoundBox.ZMax==f.BoundBox.ZMin) and (f.BoundBox.ZMax==edge.BoundBox.ZMax):
  19.         goodface = f
  20.  
  21. wire=None
  22.  
  23. for w in goodface.Wires:
  24.     for e in w.Edges:
  25.         if e.isSame(edge):
  26.             print 'found a match'
  27.             wire=w
  28.  
  29. # now we know which wire we are dealing with
  30. # time to match edge names with it
  31.  
  32. eidx = 1
  33. elindex =[]
  34.  
  35. for e in obj.Shape.Edges:
  36.     for ew in wire.Edges:
  37.         if e.isSame(ew):
  38.             elindex.append(eidx)
  39.     eidx+=1
  40.  
  41. # now highlight the appropriate edges:
  42. edlist = []
  43. for i in elindex:
  44.     edlist.append('Edge'+str(i))
  45.     Gui.Selection.addSelection(App.ActiveDocument.Fillet, ('Edge'+str(i)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement