Macro Geodesic Dome

Description
This macro creates a geodesic dome shell. The dome radius and the frequency parameter will be set at creation time.



Installation
Save the following script as MacroGeodesicDome.py to your macro directory.

Script
MacroGeodesicDome.py

QtGui.QDialogButtonBox.Ok)      self.buttonBox.setObjectName("buttonBox")        self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1)

Dialog.setWindowTitle("Geodesic Dome Creator") self.label.setText("Dome Radius") self.label_2.setText("Frequency Parameter\n(Integer between 1 to 10)") self.label_3.setText("This Macro creates \na full geodesic dome shell.\nX-Y-symmetry plane \nfor even frequencies") QtCore.QObject.connect(self.buttonBox, \           QtCore.SIGNAL("accepted"), self.makeSomething) QtCore.QObject.connect(self.buttonBox, \           QtCore.SIGNAL("rejected"), self.makeNothing) QtCore.QMetaObject.connectSlotsByName(Dialog)

def makeSomething(self): print("accepted! Dome radius: ", self.lineEdit.property("text"), \             " with Frequency: ", int(self.lineEdit_2.text)) if FreeCAD.ActiveDocument is None: FreeCAD.newDocument doc = FreeCAD.ActiveDocument theDome = GeodesicDome(doc).host theDome.Radius = FreeCAD.Units.Quantity(self.lineEdit.property("text")) theDome.FrequencyParameter = int(self.lineEdit_2.text) self.dia.close doc.recompute def makeNothing(self): print("rejected!!") self.dia.close

def showDialog: d = QtGui.QWidget d.ui = Ui_Dialog d.ui.setupUi(d) d.ui.lineEdit_2.setText("2") d.ui.lineEdit.setProperty("text", "2 m") d.show

class GeodesicDome(object): host = None def __init__(self, doc): host = doc.addObject('Part::FeaturePython', 'GeoDome') self.host = host host.Proxy = self VPGeodesicDome(host.ViewObject) host.addProperty('App::PropertyLength', 'Radius', "Geodesic Dome", "") host.addProperty('App::PropertyInteger', 'FrequencyParameter', "Geodesic Dome", "Frequency Parameter (integer, 1 to 10). If even, the dome is symmetric against XY plane.") host.addProperty('App::PropertyEnumeration', 'ShapeType', "Geodesic Dome", "") host.ShapeType = ['Solid', 'Shell', 'Wireframe', 'Vertices'] def execute(self, host): shell = makeDomeShape(host.Radius.getValueAs('mm'), host.FrequencyParameter) if host.ShapeType == 'Solid': host.Shape = Part.Solid(shell) elif host.ShapeType == 'Shell': host.Shape = shell elif host.ShapeType == 'Wireframe': host.Shape = Part.Compound(shell.Edges) elif host.ShapeType == 'Vertices': host.Shape = Part.Compound(shell.Vertexes) else: assert(False)

def __getstate__(self): return None

def __setstate__(self,state): return None class VPGeodesicDome(object): def __init__(self, host): host.Proxy = self def __getstate__(self): return None

def __setstate__(self,state): return None

if __name__ == '__main__': #running as a macro. Load as module, to support save-restore. try: import MacroGeodesicDome except ImportError as err: FreeCAD.Console.PrintError("Macro Geodesic Dome: failed to import MacroGeodesicDome.py. The parametric object will lose functionality after saving-loading your project, sorry.") showDialog else: MacroGeodesicDome.showDialog

Get the code from Github here!