Advertisement
danfalck

BOM_parse.py

May 23rd, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import FreeCADGui as Gui
  2.  
  3. a = Gui.Selection.getSelection()
  4.  
  5. for i in a:
  6.     xl = i.Shape.BoundBox.XLength/25.4
  7.     yl = i.Shape.BoundBox.YLength/25.4
  8.     zl = i.Shape.BoundBox.ZLength/25.4
  9.     print i.Label +", x="+ str(xl)+" , y="+str(yl)+" , z="+str(zl)
  10.  
  11.  
  12. #parse groups
  13. g  = Gui.Selection.getSelection()
  14.  
  15. for l in g:
  16.     if l.TypeId == 'App::DocumentObjectGroup':
  17.         print l.Label
  18.        
  19.         for i in l.Group:
  20.             xl = i.Shape.BoundBox.XLength/25.4
  21.             yl = i.Shape.BoundBox.YLength/25.4
  22.             zl = i.Shape.BoundBox.ZLength/25.4
  23.             print i.Label +", x="+ str(xl)+" , y="+str(yl)+" , z="+str(zl)
  24.  
  25.     if l.TypeId <> 'App::DocumentObjectGroup':
  26.         xl = l.Shape.BoundBox.XLength/25.4
  27.         yl = l.Shape.BoundBox.YLength/25.4
  28.         zl = l.Shape.BoundBox.ZLength/25.4
  29.         print i.Label +", x="+ str(xl)+" , y="+str(yl)+" , z="+str(zl)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement