AddDefinitionFromLibFile

Adds a material definition from a library file (e.g. AMAT file), by name and library type (using definition folder name) . This scripting command directly supports the .AMAT (or .ASURF) definition formats.

UI Access N/A
Parameters
Name

 

Type Description

<FilePath>

String

Path of the library file (i.e. AMAT file or ASURF file)

<defName> String Which definition to use, required because a lib file can have multiple definitions.
<defFolderName> String Library type (by definition folder name).
<newTimeStamp> String New timestamp string (time_t as integer, number of seconds since 1/1/1970 12:00am), default is current time
<replaceExisting> Boolean True to replace existing, False to choose a new unique name if an existing definition is found, default is False
Return Value Property scripting object for the definition.

 

Python Syntax AddDefinitionFromLibFile(<FilePath>, <defName>, <defFolderName>, <newTimeStamp>,<replaceExisting>)
Python Example

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

]

]

]

])