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()
defBlock = "$begin 'vacuum2' $begin 'AttachedData' $begin 'MatAppearanceData' property_data='appearance_data' Red=230 Green=230 Blue=230 Transparency=0.95 $end 'MatAppearanceData' $end 'AttachedData' simple('permittivity', 1) ModTime=1499970477 $end 'vacuum2'"
added = oDefinitionManager.AddDefinitionFromBlock(defBlock, "Materials", "10101010", True)
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)
materialNameInQuotes = "\"" + addedName + "\""
oEditor.ChangeProperty(
[
"NAME:AllTabs",
[
"NAME:Geometry3DAttributeTab",
[
"NAME:PropServers",
"Box1"
],
[
"NAME:ChangedProps",
[
"NAME:Material",
"Value:=", materialNameInQuotes
]
]
]
])
|