# Import packages/functions import os import sys from win32com.client.dynamic import Dispatch # Start Modeller mdlr = Dispatch('Lusas.Modeller.' + sys.argv[1]) # Create new model db = mdlr.newDatabase("structural", os.path.join(os.getcwd(), "Python_test.mdl")) db.setModelTitle("Python test") db.setVerticalDir("Y") db.setAnalysisCategory("2D Inplane") # Create points geom = mdlr.getSessionFileGeometryData() geom.setAllDefaults() geom.addCoords(0, 0, 0) geom.addCoords(1, 0, 0) geom.addCoords(2, 0, 0) geom.setLowerOrderGeometryType("coordinates") db.createPoint(geom) # Create lines sel = mdlr.getSelection() sel.remove("All") sel.add("Point") geom.setAllDefaults() geom.setCreateMethod("straight") geom.createMultipleObjects() geom.setLowerOrderGeometryType("points") sel.createLine(geom) # Create and assign beam element attr = db.createMeshLine("LMsh1") attr.setValue("uiSpacing", "uniform").setSpacing("BMI2").addSpacing(2, 1) attr.setAnalysisCategory("2D Inplane") set = mdlr.getVisibleSet() lines = set.getObjects("Line") attr.assignTo(lines) db.updateMesh() # Print model summary print("Title: " + db.getModelTitle()) print("N. of points: " + str(len(set.getObjects("Point")))) print("N. of lines: " + str(len(set.getObjects("Line")))) # Save the model and quit Modeller db.save() mdlr.quit()