oProject = oDesktop.NewProject()
oProject.InsertDesign("HFSS", "HFSSDesign1", "DrivenModal", "")
oDesign = oProject.SetActiveDesign("HFSSDesign1")
oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateBox(
[
"NAME:BoxParameters",
"XPosition:=" , "-0.4mm",
"YPosition:=" , "-1mm",
"ZPosition:=" , "0mm",
"XSize:=" , "1.4mm",
"YSize:=" , "1.6mm",
"ZSize:=" , "0.6mm"
],
[
"NAME:Attributes",
"Name:=" , "Box1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , True,
"ShellElement:=" , False,
"ShellElementThickness:=", "0mm",
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False,
"IsLightweight:=" , False
])
oDefinitionManager = oProject.GetDefinitionManager()
scriptDir = os.path.dirname(os.path.realpath(__file__)) amatFilePath = scriptDir + '/material0.txt' materialName = "material0" materialNameInQuotes = "\"" + materialName + "\"" added = oDefinitionManager.AddDefinitionFromLibFile(amatFilePath, materialName, "Materials", "") addedName = '' if isinstance(added, basestring): addedName = added elif isinstance(added, list): addedName = added[0] else: addedName = added.GetName().replace("Materials:", "") AddInfoMessage(os.path.basename(__file__) + " result: " + addedName) oEditor.ChangeProperty( [ "NAME:AllTabs", [ "NAME:Geometry3DAttributeTab", [ "NAME:PropServers", "Box1" ], [ "NAME:ChangedProps", [ "NAME:Material", "Value:=", materialNameInQuotes ] ] ] ])
|