微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 电磁仿真讨论 > HFSS Scripting: running a script multiple times gives naming conflicts

HFSS Scripting: running a script multiple times gives naming conflicts

时间:03-26 整理:3721RD 点击:
I created a script to build a geometric model, and it works, but If I try to run it more than once, the code manipulates the first object since it uses the same variables and relative Coordinate systems. Is there a way to create temporary coordinate systems? or dynamically create them each time the script is run? Basically the issue is hard coded names for parts or coordinate systems which act as globally scoped variables. If I could assign a newly created box to a function variable that would help. I've attached the code.

I figured out a solution. I create an array of model objects, then each time in the code that a new model object is created it gets added to the array. If I need to reference the part later in the code I can just refer to the array location as shown below.

oEditor.CreateRectangle Array("NAME:RectangleParameters", _
"XStart:=", "0mils", _
"YStart:=", "0mils", _
"ZStart:=", "strMinRadius", _
"Width:=", "strLeadWidth", _
"Height:=", "strLeadThickness", _
"WhichAxis:=", "X"), _
Array("NAME:Attributes", _
"Name:=", "ArchRect1")
objectArray(1) = oEditor.GetObjectName(oEditor.getNumObjects() - 1)
oEditor.SweepAroundAxis Array("NAME:Selections", _
"Selections:=", objectArray(1)), _
Array("NAME:AxisSweepParameters", _
"DraftAngle:=", "0", _
"DraftType:=", "Natural", _
"SweepAxis:=", "Y", _
"SweepAngle:=", "strAngle * Pi/180")

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top