淘宝官方店     推荐课程     在线工具     联系方式     关于我们  
 
 

微波射频仿真设计   Ansoft Designer 中文培训教程   |   HFSS视频培训教程套装

 

Agilent ADS 视频培训教程   |   CST微波工作室视频教程   |   AWR Microwave Office

          首页 >> Ansoft Designer >> Ansoft Designer在线帮助文档


Ansoft Designer / Ansys Designer 在线帮助文档:


Script Guide >
Desktop Scripting with IronPython >
   Appendix: IronPython Samples       


Appendix: IronPython Samples

Change property

The following snippets show how a change property command (in this case, to change the color of a cone) looks in VBScript and its two possible IronPython variants.

oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab",_

Array("NAME:PropServers", "Cone1"), _

Array("NAME:ChangedProps", _

Array("NAME:Color", "R:=", 255, "G:=", 255, "B:=", 0))))

Sample Script 13: ChangeProperty command to change color of a cone in VBScript

 

oEditor.ChangeProperty(

["NAME:AllTabs",

["NAME:Geometry3DAttributeTab",

["NAME:PropServers", "Cone1"],

["NAME:ChangedProps",

["NAME:Color", "R:=", 0, "G:=", 0, "B:=", 64]

]

]

])

Sample Script 14: ChangeProperty command to change color of cone using Python arrays

Any time there are named arrays composed purely of key-value pairs, they can always be represented using a Python dictionary, irrespective of the nesting of said named array.

 

oEditor.ChangeProperty(

["NAME:AllTabs",

["NAME:Geometry3DAttributeTab",

["NAME:PropServers", "Cone1"],

["NAME:ChangedProps",

{

"NAME":"Color",

"R" : 0,

"G" : 64,

"B" : 0

}]]

])

Sample Script 15: ChangeProperty command to change the color of a cone using Python arrays and dictionaries

 

Create a Cone using IronPython

Most scripting tasks using IronPython are expected to be formatted as the example below. One starts with the predefined oDesktop object and drills down to the design, editors, modules etc and issues any required commands on the object while formatting the script command arguments in natural python syntax.

oProject = oDesktop.GetActiveProject()

oDesign = oProject.InsertDesign("Designer","Random","DrivenModal","")

oEditor = oDesign.SetActiveEditor("3D Modeler")

oEditor.CreateCone(

{

"NAME" : "ConeParameters",

"XCenter" : "0mm",

"YCenter" : "0mm",

"ZCenter" : "0mm",

"WhichAxis" : "Z",

"Height" : "2mm",

"BottomRadius" : "1.56204993518133mm",

"TopRadius" : "0mm"

},

{

"NAME" : "Attributes",

"Name" : "Cone1",

"Flags" : "",

"Color" : "(132 132 193)",

"Transparency" : 0,

"PartCoordinateSystem": "Global",

"UDMId" : "",

"MaterialValue" : "\"vacuum\"",

"SolveInside" : True

}

)

Sample Script 16: IronPython script to create a cone

Create geometry and then create a grid from it using copy/paste/move

The following script demonstrates slightly more advanced use of scripting and the use of return values from script methods. It creates a 5x5 grid of cones and also demonstrates the adding of information messages to the application’s message window.

oProject = oDesktop.GetActiveProject()

oDesign = oProject.InsertDesign("Designer","Hersheys Kisses","DrivenModal","")

oEditor = oDesign.SetActiveEditor("3D Modeler")

 

 

# create the first cone

AddInfoMessage("Creating first cone")

firstConeName = "firstCone"

coneBotRad = "1.5mm"

oEditor.CreateCone(

{

"NAME" : "ConeParameters",

"XCenter" : "0mm",

"YCenter" : "0mm",

"ZCenter" : "0mm",

"WhichAxis" : "Z",

"Height" : "2mm",

"BottomRadius": coneBotRad,

"TopRadius" : "0mm"

},

{

"NAME" : "Attributes",

"Name" : firstConeName,

"Flags" : "",

"Color" : "(132 132 193)",

"Transparency" : 0,

"PartCoordinateSystem": "Global",

"UDMId" : "",

"MaterialValue" : "\"vacuum\"",

"SolveInside" : True

}

)

 

# Now replicate this a few times and create an array out of it

AddInfoMessage("Replicating it 24 times")

for x in range(5):

for y in range(5):

# leave the first one alone in it's created

# position

if x == 0 and y == 0:

continue

 

# all other grid positions, replicate from the

# first one

 

# copy first

oEditor.Copy(

{

"NAME" : "Selections",

"Selections" : firstConeName

}

)

 

# paste it and capture the pasted name

# the pasted names come in an array as we could

# be pasting a selection cmposed of multiple objects

pasteName = oEditor.Paste()[0]

 

# now move the pasted item to it's final position

oEditor.Move(

{

"NAME" : "Selections",

"Selections" : pasteName

},

{

"NAME" : "TransalateParameters",

"CoordinateSystemID" : -1,

"TranslateVectorX" : "%d * 3 * %s" % (x, coneBotRad),

"TranslateVectorY" : "%d * 3 * %s" % (y, coneBotRad),

"TranslateVectorZ" : "0mm"

}

)

 

 

# Now fit the display to the created grid

oEditor.FitAll()

Sample Script 17: Sample script to create a cone and then use copy/paste/move to replicate it.

 

 




HFSS视频教学培训教程 ADS2011视频培训教程 CST微波工作室教程 Ansoft Designer 教程

                HFSS视频教程                                      ADS视频教程                               CST视频教程                           Ansoft Designer 中文教程


 

      Copyright © 2006 - 2013   微波EDA网, All Rights Reserved    业务联系:mweda@163.com