Macro for making a drawing of the building in FreeCAD

Today, I make a macro which automates the drawing of the building on drawing sheet. Here is the code of macro.

obj_list = FreeCAD.ActiveDocument.Objects                                      
App.activeDocument().addObject("Part::Compound","Compound")             
App.activeDocument().Compound.Links = obj_list                                 
                                                                        
App.ActiveDocument.addObject('Drawing::FeaturePage','Page')             
App.ActiveDocument.Page.Template = App.getResourceDir()+'Mod/Drawing/Templates/A3_Landscape.svg'
                                                                        
App.ActiveDocument.addObject('Drawing::FeatureViewPart','View')         
App.ActiveDocument.View.Source = App.ActiveDocument.Compound            
App.ActiveDocument.View.Direction = (0.0,0.0,1.0)                       
App.ActiveDocument.View.X = 30.0                                        
App.ActiveDocument.View.Y = 100.0                                       
App.ActiveDocument.View.ShowHiddenLines = False                         
App.ActiveDocument.View.Scale = 2.0                                     
App.ActiveDocument.Page.addObject(App.ActiveDocument.View)                                                        
                                                                        
App.ActiveDocument.addObject('Drawing::FeatureViewPart','ViewIso')      
App.ActiveDocument.ViewIso.Source = App.ActiveDocument.Compound         
App.ActiveDocument.ViewIso.Direction = (1, 1, 1)                        
App.ActiveDocument.ViewIso.X = 335.0                                    
App.ActiveDocument.ViewIso.Y = 60.0                                     
App.ActiveDocument.ViewIso.ShowHiddenLines = True                       
App.ActiveDocument.ViewIso.Rotation = 120                               
App.ActiveDocument.ViewIso.Scale = 2.0                                  
App.ActiveDocument.Page.addObject(App.ActiveDocument.ViewIso)           
App.ActiveDocument.recompute()                                          

Output when you run the above macro:
Drawing of building

Source code:
https://github.com/amrit3701/Drawing-FreeCAD/blob/master/macro_building_drawing.py

FollowFollow on FacebookFollow on Google+Email this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *