西莫电机圈

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

查看: 907|回复: 2

[Maxwell] 利用VBscripting的参数化分析《失败?》案例

[复制链接]

该用户从未签到

发表于 2017-8-1 09:40 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 tomorrowgary 于 2017-8-1 09:40 编辑

原设计是参数化设计,验证在不同的磁铁(红色蓝色)数量和定子(青褐色)槽数(线圈[黄色,图形中线圈和定子重叠了,因为参数没有调好]数量)的组合下,最佳的设计。故考虑用parametric设计,但是在对磁铁及线圈旋转复制时,数量参数只能是正整数,故转向VBscript,在数量参数中引用变量。但最终失败,别人告知,旋转复制数量参数不可以是变量,即使script中成功应用变量,但是parametric时,此参数不会发生变化。(也不知这个说法对不对,心里还抱有希望,希望大神指点)



因为在学习中,发现VBscript的例子较少,故贴出这个《失败》例子,也希望对大家有所帮助。先贴出代码,后期再完善这个帖子吧。代码主要是录制然后修改的。







  1. ' ----------------------------------------------
  2. ' Script Recorded by ANSYS Electronics Desktop Version 2016.2.0
  3. ' 15:05:10  7月 27, 2017
  4. ' ----------------this file is to implement whole parametric simulation, including the poles number,
  5. 'slot number as well as coils number, but variables can't be assigned to rotation, so failed.
  6. Dim oAnsoftApp
  7. Dim oDesktop
  8. Dim oProject
  9. Dim oDesign
  10. Dim oEditor
  11. Dim oModule
  12. Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
  13. Set oDesktop = oAnsoftApp.GetAppDesktop()
  14. oDesktop.RestoreWindow
  15. Set oProject = oDesktop.GetActiveProject()
  16. 'a project name can be given to direct to a project
  17. Set oDesign = oProject.GetActiveDesign()
  18. Set oEditor = oDesign.SetActiveEditor("3D Modeler")
  19. '-------------------------------------------function--------------------------------------------
  20. function Ain(number)
  21.   Ain="Ain_" & (number+1)'vb中函数返回应该用(函数名=返回值)定义
  22.   end function
  23. function Aout(number)
  24.   Aout="Aout_" & (number+1)
  25.   end function
  26. function Bin(number)
  27.   Bin="Bin_" & (number+1)
  28.   end function
  29. function Bout(number)
  30.   Bout="Bout_" & (number+1)
  31.   end function
  32. function Cin(number)
  33.   Cin="Cin_" & (number+1)
  34.   end function
  35. function Cout(number)
  36.   Cout="Cout_" & (number+1)
  37.   end function
  38. function AinRectanglem1(number)
  39.   if number=0 then
  40.   AinRectanglem1="Rectanglem1"
  41.   else
  42.   AinRectanglem1="Rectanglem1" & "_" & number*3
  43.   end if
  44.   end function
  45. function AoutRectangles1(number)
  46.   if number=0 then
  47.   AoutRectangles1="Rectangles1"
  48.   else
  49.   AoutRectangles1="Rectangles1" & "_" & number*3
  50.   end if
  51.   end function
  52. function BinRectanglem1(number)
  53.   BinRectanglem1="Rectanglem1" & "_" & number*3+1
  54.   end function
  55. function BoutRectangles1(number)
  56.   BoutRectangles1="Rectangles1" & "_" & number*3+1
  57.   end function
  58. function CinRectanglem1(number)
  59.   CinRectanglem1="Rectanglem1" & "_" & number*3+2
  60.   end function
  61. function CoutRectangles1(number)
  62.   CoutRectangles1="Rectangles1" & "_" & number*3+2
  63. end function
  64. '----------------------------------------------inner rotor-------------------------------------------
  65. oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=",  _
  66.   false, "IsPolylineClosed:=", false, Array("NAME:PolylinePoints", Array("NAME:PLPoint", "X:=",  _
  67.   "10mm", "Y:=", "0mm", "Z:=", "0mm"), Array("NAME:PLPoint", "X:=", "12.5mm", "Y:=",  _
  68.   "0mm", "Z:=", "0mm")), Array("NAME:PolylineSegments", Array("NAME:PLSegment", "SegmentType:=",  _
  69.   "Line", "StartIndex:=", 0, "NoOfPoints:=", 2)), Array("NAME:PolylineXSection", "XSectionType:=",  _
  70.   "None", "XSectionOrient:=", "Auto", "XSectionWidth:=", "0mm", "XSectionTopWidth:=",  _
  71.   "0mm", "XSectionHeight:=", "0mm", "XSectionNumSegments:=", "0", "XSectionBendType:=",  _
  72.   "Corner")), Array("NAME:Attributes", "Name:=", "Polyline1", "Flags:=", "", "Color:=",  _
  73.   "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=",  _
  74.   "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  75.   true)
  76. oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=",  _
  77.   false, "IsPolylineClosed:=", false, Array("NAME:PolylinePoints", Array("NAME:PLPoint", "X:=",  _
  78.   "10mm", "Y:=", "0mm", "Z:=", "0mm"), Array("NAME:PLPoint", "X:=",  _
  79.   "9.65925826289068mm", "Y:=", "2.58819045102521mm", "Z:=", "0mm"), Array("NAME:PLPoint", "X:=",  _
  80.   "8.66025403784439mm", "Y:=", "5mm", "Z:=", "0mm")), Array("NAME:PolylineSegments", Array("NAME:PLSegment", "SegmentType:=",  _
  81.   "AngularArc", "StartIndex:=", 0, "NoOfPoints:=", 3, "NoOfSegments:=", "0", "ArcAngle:=",  _
  82.   "30deg", "ArcCenterX:=", "0mm", "ArcCenterY:=", "0mm", "ArcCenterZ:=", "0mm", "ArcPlane:=",  _
  83.   "XY")), Array("NAME:PolylineXSection", "XSectionType:=", "None", "XSectionOrient:=",  _
  84.   "Auto", "XSectionWidth:=", "0mm", "XSectionTopWidth:=", "0mm", "XSectionHeight:=",  _
  85.   "0mm", "XSectionNumSegments:=", "0", "XSectionBendType:=", "Corner")), Array("NAME:Attributes", "Name:=",  _
  86.   "Polyline2", "Flags:=", "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  87.   "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  88.   true)
  89. oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",  _
  90.   "LocalVariables"), Array("NAME:NewProps", Array("NAME:poles", "PropType:=", "VariableProp", "UserDef:=",  _
  91.   true, "Value:=", "1"))))
  92. oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DPolylineTab", Array("NAME:PropServers",  _
  93.   "Polyline2:CreatePolyline:2:Segment0"), Array("NAME:ChangedProps", Array("NAME:Angle", "Value:=",  _
  94.   "180deg/poles-5deg"))))
  95. oEditor.SweepAlongPath Array("NAME:Selections", "Selections:=", "Polyline1,Polyline2", "NewPartsModelFlag:=",  _
  96.   "Model"), Array("NAME:PathSweepParameters", "DraftAngle:=", "0deg", "DraftType:=",  _
  97.   "Round", "CheckFaceFaceIntersection:=", false, "TwistAngle:=", "0deg")
  98. Set oDefinitionManager = oProject.GetDefinitionManager()
  99. oDefinitionManager.AddMaterial Array("NAME:myNdFe35", "CoordinateSystemType:=",  _
  100.   "Cylindrical", Array("NAME:AttachedData"), Array("NAME:ModifierData"), "permittivity:=",  _
  101.   "1", "permeability:=", "1.0997785406", "conductivity:=", "625000", "dielectric_loss_tangent:=",  _
  102.   "0", "magnetic_loss_tangent:=", "0", Array("NAME:magnetic_coercivity", "property_type:=",  _
  103.   "VectorProperty", "Magnitude:=", "-890000A_per_meter", "DirComp1:=", "1", "DirComp2:=",  _
  104.   "0", "DirComp3:=", "0"), "thermal_conductivity:=", "0", "saturation_mag:=",  _
  105.   "0gauss", "lande_g_factor:=", "2", "delta_H:=", "0Oe", "mass_density:=", "7400", "youngs_modulus:=",  _
  106.   "147000000000", Array("NAME:thermal_expansion_coeffcient", "property_type:=",  _
  107.   "AnisoProperty", "unit:=", "", "component1:=", "3e-006", "component2:=",  _
  108.   "-5e-006", "component3:=", "-5e-006"))
  109. oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",  _
  110.   "Polyline1"), Array("NAME:ChangedProps", Array("NAME:Material", "Value:=", "" & Chr(34) & "myNdFe35" & Chr(34) & ""))))
  111. oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=", "Polyline1", "NewPartsModelFlag:=",  _
  112.   "Model"), Array("NAME:DuplicateAroundAxisParameters", "CreateNewObjects:=", true, "WhichAxis:=",  _
  113.   "Z", "AngleStr:=", "180deg/poles", "NumClones:=", "2*poles"), Array("NAME:Options", "DuplicateAssignments:=", false)
  114. oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",  _
  115.   "LocalVariables"), Array("NAME:NewProps", Array("NAME:sn", "PropType:=", "VariableProp", "UserDef:=",  _
  116.   true, "Value:=", "6"))))
  117. Set oModule = oDesign.GetModule("AnalysisSetup")
  118. '------------------------------------analysis-------------------------------------------
  119. oModule.InsertSetup "Transient", Array("NAME:Setup1", "Enabled:=", true, "NonlinearSolverResidual:=",  _
  120.   "0.0001", "TimeIntegrationMethod:=", 0, "StopTime:=", "1s", "TimeStep:=", "0.1s", "OutputError:=",  _
  121.   false, "UseControlProgram:=", false, "ControlProgramName:=", " ", "ControlProgramArg:=",  _
  122.   " ", "CallCtrlProgAfterLastStep:=", false, "FastReachSteadyState:=", false, "IsGeneralTransient:=",  _
  123.   true, "NumberOfTimeSubDivisions:=", 1, "HasSweepSetup:=", true, "SweepSetupType:=",  _
  124.   "LinearStep", "StartValue:=", "0ns", "StopValue:=", "1s", "StepSize:=", "0.1s", "UseAdaptiveTimeStep:=",  _
  125.   false, "InitialTimeStep:=", "0.002s", "MinTimeStep:=", "0.001s", "MaxTimeStep:=",  _
  126.   "0.003s", "TimeStepErrTolerance:=", 0.0001)
  127. Set oModule = oDesign.GetModule("Optimetrics")
  128. '-----------------------------------parametric analysis------------------------------------
  129. oModule.InsertSetup "OptiParametric", Array("NAME:ParametricSetup1", "IsEnabled:=",  _
  130.   true, Array("NAME:ProdOptiSetupData", "SaveFields:=", true, "CopyMesh:=", false), Array("NAME:StartingPoint"), "Sim. Setups:=", Array( _
  131.   "Setup1"), Array("NAME:Sweeps", Array("NAME:SweepDefinition", "Variable:=", "poles", "Data:=",  _
  132.   "LIN 1 3 1", "OffsetF1:=", false, "Synchronize:=", 0), Array("NAME:SweepDefinition", "Variable:=",  _
  133.   "sn", "Data:=", "LIN 6 12 3", "OffsetF1:=", false, "Synchronize:=", 0)), Array("NAME:Sweep Operations"), Array("NAME:Goals", Array("NAME:Goal", "ReportType:=",  _
  134.   "Transient", "Solution:=", "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=",  _
  135.   "Moving1"), "Calculation:=", "rms(abs(FluxLinkage(Ayellow)))", "Name:=",  _
  136.   "FluxLinkage(Ayellow)", Array("NAME:Ranges", "Range:=", Array("Var:=", "Time", "Type:=",  _
  137.   "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",  _
  138.   "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",  _
  139.   "rms(FluxLinkage(Bgreen))", "Name:=", "rms(FluxLinkage(Bgreen))", Array("NAME:Ranges", "Range:=", Array("Var:=",  _
  140.   "Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",  _
  141.   "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",  _
  142.   "rms(FluxLinkage(Cblue))", "Name:=", "rms(FluxLinkage(Cblue))", Array("NAME:Ranges", "Range:=", Array("Var:=",  _
  143.   "Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",  _
  144.   "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",  _
  145.   "rms(InducedVoltage(Ayellow))", "Name:=", "rms(InducedVoltage(Ayellow))", Array("NAME:Ranges", "Range:=", Array("Var:=",  _
  146.   "Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",  _
  147.   "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",  _
  148.   "rms(InducedVoltage(Bgreen))", "Name:=", "rms(InducedVoltage(Bgreen))", Array("NAME:Ranges", "Range:=", Array("Var:=",  _
  149.   "Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",  _
  150.   "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",  _
  151.   "rms(InducedVoltage(Cblue))", "Name:=", "rms(InducedVoltage(Cblue))", Array("NAME:Ranges", "Range:=", Array("Var:=",  _
  152.   "Time", "Type:=", "a")))))
  153. oProject.Save
  154. Set oEditor = oDesign.SetActiveEditor("3D Modeler")
  155. '------------------------------------------stator----------------------------------
  156. oEditor.CreateUserDefinedPart Array("NAME:UserDefinedPrimitiveParameters", "DllName:=",  _
  157.   "RMxprt/SlotCore.dll", "Version:=", "12.1", "NoOfParameters:=", 19, "Library:=",  _
  158.   "syslib", Array("NAME:ParamVector", Array("NAME:Pair", "Name:=", "DiaGap", "Value:=",  _
  159.   "19.4mm"), Array("NAME:Pair", "Name:=", "DiaYoke", "Value:=", "3mm"), Array("NAME:Pair", "Name:=",  _
  160.   "Length", "Value:=", "0mm"), Array("NAME:Pair", "Name:=", "Skew", "Value:=", "0deg"), Array("NAME:Pair", "Name:=",  _
  161.   "Slots", "Value:=", "sn"), Array("NAME:Pair", "Name:=", "SlotType", "Value:=", "1"), Array("NAME:Pair", "Name:=",  _
  162.   "Hs0", "Value:=", "0.5mm"), Array("NAME:Pair", "Name:=", "Hs01", "Value:=", "0mm"), Array("NAME:Pair", "Name:=",  _
  163.   "Hs1", "Value:=", "0.6mm"), Array("NAME:Pair", "Name:=", "Hs2", "Value:=",  _
  164.   "3mm"), Array("NAME:Pair", "Name:=", "Bs0", "Value:=", "1mm"), Array("NAME:Pair", "Name:=",  _
  165.   "Bs1", "Value:=", "3mm"), Array("NAME:Pair", "Name:=", "Bs2", "Value:=", "0.3mm"), Array("NAME:Pair", "Name:=",  _
  166.   "Rs", "Value:=", "0mm"), Array("NAME:Pair", "Name:=", "FilletType", "Value:=", "0"), Array("NAME:Pair", "Name:=",  _
  167.   "HalfSlot", "Value:=", "0"), Array("NAME:Pair", "Name:=", "SegAngle", "Value:=",  _
  168.   "15deg"), Array("NAME:Pair", "Name:=", "LenRegion", "Value:=",  _
  169.   "200mm"), Array("NAME:Pair", "Name:=", "InfoCore", "Value:=", "0"))), Array("NAME:Attributes", "Name:=",  _
  170.   "SlotCore1", "Flags:=", "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  171.   "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  172.   true)
  173.   Set oDefinitionManager = oProject.GetDefinitionManager()
  174. oDefinitionManager.AddMaterial Array("NAME:mysteel_1009", "CoordinateSystemType:=",  _
  175.   "Cartesian", Array("NAME:AttachedData"), Array("NAME:ModifierData"), Array("NAME:permeability", "property_type:=",  _
  176.   "nonlinear", "BType:=", "normal", "HUnit:=", "A_per_meter", "BUnit:=", "tesla", Array("NAME:BHCoordinates", Array("NAME:Coordinate", "X:=",  _
  177.   0, "Y:=", 0), Array("NAME:Coordinate", "X:=", 159.2, "Y:=", 0.2402), Array("NAME:Coordinate", "X:=",  _
  178.   318.3, "Y:=", 0.8654), Array("NAME:Coordinate", "X:=", 477.5, "Y:=", 1.1106), Array("NAME:Coordinate", "X:=",  _
  179.   636.6, "Y:=", 1.2458), Array("NAME:Coordinate", "X:=", 795.8, "Y:=", 1.331), Array("NAME:Coordinate", "X:=",  _
  180.   1591.5, "Y:=", 1.5), Array("NAME:Coordinate", "X:=", 3183.1, "Y:=", 1.6), Array("NAME:Coordinate", "X:=",  _
  181.   4774.6, "Y:=", 1.683), Array("NAME:Coordinate", "X:=", 6366.2, "Y:=", 1.741), Array("NAME:Coordinate", "X:=",  _
  182.   7957.7, "Y:=", 1.78), Array("NAME:Coordinate", "X:=", 15915.5, "Y:=", 1.905), Array("NAME:Coordinate", "X:=",  _
  183.   31831, "Y:=", 2.025), Array("NAME:Coordinate", "X:=", 47746.5, "Y:=", 2.085), Array("NAME:Coordinate", "X:=",  _
  184.   63662, "Y:=", 2.13), Array("NAME:Coordinate", "X:=", 79577.5, "Y:=", 2.165), Array("NAME:Coordinate", "X:=",  _
  185.   159155, "Y:=", 2.28), Array("NAME:Coordinate", "X:=", 318310, "Y:=", 2.485), Array("NAME:Coordinate", "X:=",  _
  186.   397887, "Y:=", 2.5851))), "conductivity:=", "0", "magnetic_loss_tangent:=", "0", Array("NAME:magnetic_coercivity", "property_type:=",  _
  187.   "VectorProperty", "Magnitude:=", "0A_per_meter", "DirComp1:=", "1", "DirComp2:=",  _
  188.   "0", "DirComp3:=", "0"), "thermal_conductivity:=", "45", Array("NAME:core_loss_type", "property_type:=",  _
  189.   "ChoiceProperty", "Choice:=", "Electrical Steel"), "core_loss_kh:=", "190", "core_loss_kc:=",  _
  190.   "0.822", "core_loss_ke:=", "0", "core_loss_kdc:=", "0", "mass_density:=", "7872", Array("NAME:stacking_type", "property_type:=",  _
  191.   "ChoiceProperty", "Choice:=", "Lamination"), "stacking_factor:=", "0.96", Array("NAME:stacking_direction", "property_type:=",  _
  192.   "ChoiceProperty", "Choice:=", "V(3)"), "specific_heat:=", "481", "youngs_modulus:=",  _
  193.   "200000000000", "poissons_ratio:=", "0.25", "thermal_expansion_coeffcient:=",  _
  194.   "1.26e-005")
  195. oProject.Save
  196. '-------------------------------------------coil--------------------------------------------
  197. oEditor.CreateRectangle Array("NAME:RectangleParameters", "IsCovered:=", false, "XStart:=",  _
  198.   "7.4mm", "YStart:=", "1.4mm", "ZStart:=", "0mm", "Width:=", "-0.4mm", "Height:=",  _
  199.   "0.4mm", "WhichAxis:=", "Z"), Array("NAME:Attributes", "Name:=", "Rectangle1", "Flags:=",  _
  200.   "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  201.   "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "mysteel_1009" & Chr(34) & "", "SolveInside:=",  _
  202.   true)
  203. oEditor.CoverLines Array("NAME:Selections", "Selections:=", "Rectangle1", "NewPartsModelFlag:=",  _
  204.   "Model")
  205. oEditor.DuplicateMirror Array("NAME:Selections", "Selections:=", "Rectangle1", "NewPartsModelFlag:=",  _
  206.   "Model"), Array("NAME:DuplicateToMirrorParameters", "DuplicateMirrorBaseX:=", "0mm", "DuplicateMirrorBaseY:=",  _
  207.   "0mm", "DuplicateMirrorBaseZ:=", "0mm", "DuplicateMirrorNormalX:=", "0mm", "DuplicateMirrorNormalY:=",  _
  208.   "1mm", "DuplicateMirrorNormalZ:=", "0mm"), Array("NAME:Options", "DuplicateAssignments:=",  _
  209.   false)
  210. oEditor.Renamepart Array("NAME:Rename Data","Old Name:=", "Rectangle1","New Name:=", "Rectanglem1")
  211. oEditor.Renamepart Array("NAME:Rename Data","Old Name:=", "Rectangle1_1","New Name:=", "Rectangles1")
  212. oDefinitionManager.AddMaterial Array("NAME:mycopper", "CoordinateSystemType:=",  _
  213.   "Cartesian", Array("NAME:AttachedData"), Array("NAME:ModifierData"), "permeability:=",  _
  214.   "0.999991", "conductivity:=", "58000000", "thermal_conductivity:=", "400", "mass_density:=",  _
  215.   "8933", "specific_heat:=", "385", "youngs_modulus:=", "120000000000", "poissons_ratio:=",  _
  216.   "0.38", "thermal_expansion_coeffcient:=", "1.77e-005")
  217. oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",  _
  218.   "Rectanglem1", "Rectangles1"), Array("NAME:ChangedProps", Array("NAME:Material", "Value:=",  _
  219.   "" & Chr(34) & "mycopper" & Chr(34) & ""))))
  220. oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=",  _
  221.   "Rectanglem1,Rectangles1", "NewPartsModelFlag:=", "Model"), Array("NAME:DuplicateAroundAxisParameters", "CreateNewObjects:=",  _
  222.   true, "WhichAxis:=", "Z", "AngleStr:=", "360deg/sn", "NumClones:=", "sn"), Array("NAME:Options", "DuplicateAssignments:=",  _
  223. false)
  224. '------------------------------------------windings--------------------------------------
  225. oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",  _
  226.   "LocalVariables"), Array("NAME:NewProps", Array("NAME:nocoils", "PropType:=",  _
  227.   "VariableProp", "UserDef:=", true, "Value:=", "60"))))'define coil numbers
  228. Set oModule = oDesign.GetModule("BoundarySetup")
  229. loopsn=CInt(oDesign.GetVariableValue("sn"))
  230. for j=0 to (loopsn/3-1)
  231.   oModule.AssignCoil Array("NAME:Ain_"&j+1, "Objects:=", Array( AinRectanglem1(j) ), "Conductor number:=",  _
  232.   "nocoils", "PolarityType:=", "Positive")
  233.   oModule.AssignCoil Array("NAME:Aout_"&j+1, "Objects:=", Array( AoutRectangles1(j) ), "Conductor number:=",  _
  234.   "nocoils", "PolarityType:=", "Negative")
  235.   oModule.AssignCoil Array("NAME:Bin_"&j+1, "Objects:=", Array( BinRectanglem1(j) ), "Conductor number:=",  _
  236.   "nocoils", "PolarityType:=", "Positive")
  237.   oModule.AssignCoil Array("NAME:Bout_"&j+1, "Objects:=", Array( BoutRectangles1(j) ), "Conductor number:=",  _
  238.   "nocoils", "PolarityType:=", "Negative")
  239.   oModule.AssignCoil Array("NAME:Cin_"&j+1, "Objects:=", Array( CinRectanglem1(j) ), "Conductor number:=",  _
  240.   "nocoils", "PolarityType:=", "Positive")
  241.   oModule.AssignCoil Array("NAME:Cout_"&j+1, "Objects:=", Array( CoutRectangles1(j) ), "Conductor number:=",  _
  242.   "nocoils", "PolarityType:=", "Negative")
  243. Next
  244. oModule.AssignWindingGroup Array("NAME:Ayellow", "Type:=", "Current", "IsSolid:=",  _
  245.   false, "Current:=", "0mA", "Resistance:=", "0ohm", "Inductance:=", "0nH", "Voltage:=",  _
  246.   "0mV", "ParallelBranchesNum:=", "1")
  247. oModule.AssignWindingGroup Array("NAME:Bgreen", "Type:=", "Current", "IsSolid:=",  _
  248.   false, "Current:=", "0mA", "Resistance:=", "0ohm", "Inductance:=", "0nH", "Voltage:=",  _
  249.   "0mV", "ParallelBranchesNum:=", "1")
  250. oModule.AssignWindingGroup Array("NAME:Cblue", "Type:=", "Current", "IsSolid:=",  _
  251.   false, "Current:=", "0mA", "Resistance:=", "0ohm", "Inductance:=", "0nH", "Voltage:=",  _
  252.   "0mV", "ParallelBranchesNum:=", "1")
  253. oProject.Save
  254. '--------------------addcoilstowinding---------------------------------------------
  255. for j=0 to (loopsn/3-1)
  256.   oModule.EditCoil Ain(j), Array("NAME:Ain_"&j+1, "ParentBndID:=", "Ayellow", "Conductor number:=",  _
  257.   "nocoils", "Winding:=", "Ayellow", "PolarityType:=", "Positive")
  258.   oModule.EditCoil Aout(j), Array("NAME:Aout_"&j+1, "ParentBndID:=", "Ayellow", "Conductor number:=",  _
  259.   "nocoils", "Winding:=", "Ayellow", "PolarityType:=", "negative")
  260.   oModule.EditCoil Bin(j), Array("NAME:Bin_"&j+1, "ParentBndID:=", "Bgreen", "Conductor number:=",  _
  261.   "nocoils", "Winding:=", "Bgreen", "PolarityType:=", "Positive")
  262.   oModule.EditCoil Bout(j), Array("NAME:Bout_"&j+1, "ParentBndID:=", "Bgreen", "Conductor number:=",  _
  263.   "nocoils", "Winding:=", "Bgreen", "PolarityType:=", "negative")
  264.   oModule.EditCoil Cin(j), Array("NAME:Cin_"&j+1, "ParentBndID:=", "Cblue", "Conductor number:=",  _
  265.   "nocoils", "Winding:=", "Cblue", "PolarityType:=", "Positive")
  266.   oModule.EditCoil Cout(j), Array("NAME:Cout_"&j+1, "ParentBndID:=", "Cblue", "Conductor number:=",  _
  267.   "nocoils", "Winding:=", "Cblue", "PolarityType:=", "negative")
  268. Next
  269. '-------------------------------------------band and region---------------------------------
  270. oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", false, "XCenter:=",  _
  271.   "0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "9.80mm", "WhichAxis:=",  _
  272.   "Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle1", "Flags:=",  _
  273.   "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  274.   "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  275.   true)
  276. oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", false, "XCenter:=",  _
  277.   "0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "12.7mm", "WhichAxis:=",  _
  278.   "Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle2", "Flags:=",  _
  279.   "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  280.   "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  281.   true)
  282. oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", false, "XCenter:=",  _
  283.   "0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "20mm", "WhichAxis:=",  _
  284.   "Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle3", "Flags:=",  _
  285.   "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  286.   "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  287.   true)
  288. oEditor.CoverLines Array("NAME:Selections", "Selections:=", "Circle1,Circle2,Circle3", "NewPartsModelFlag:=",  _
  289.   "Model")
  290. oEditor.Subtract Array("NAME:Selections", "Blank Parts:=", "Circle2", "Tool Parts:=",  _
  291.   "Circle1"), Array("NAME:SubtractParameters", "KeepOriginals:=", false)
  292. Set oModule = oDesign.GetModule("BoundarySetup")

  293. edgeid =oEditor.GetEdgeByPosition(Array("NAME:EdgeParameters", "BodyName:=", "Circle3", "XPosition:=", "20mm", _
  294. "YPosition:=", "0mm", "ZPosition:=", "0mm"))
  295. oModule.AssignVectorPotential Array("NAME:VectorPotential1", "Edges:=",Array(edgeid) ,  "Value:=",  _
  296.   "0", "CoordinateSystem:=", "")
  297. Set oModule = oDesign.GetModule("ModelSetup")
  298. oModule.AssignBand Array("NAME:Data", "Move Type:=", "Rotate", "Coordinate System:=",  _
  299.   "Global", "Axis:=", "Z", "Is Positive:=", true, "InitPos:=", "0deg", "HasRotateLimit:=",  _
  300.   false, "NonCylindrical:=", false, "Consider Mechanical Transient:=", false, "Angular Velocity:=",  _
  301.   "60rpm", "Objects:=", Array("Circle2"))
  302. Set oModule = oDesign.GetModule("MeshSetup")
  303. '---------------------------------------mesh-------------------------------------------
  304. oModule.AssignLengthOp Array("NAME:Length1", "RefineInside:=", false, "Enabled:=",  _
  305.   true, "Objects:=", Array("Circle3"), "RestrictElem:=", false, "NumMaxElem:=",  _
  306.   "1000", "RestrictLength:=", true, "MaxLength:=", "0.5mm")
复制代码
model.JPG
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过

该用户从未签到

发表于 2017-8-1 15:53 | 显示全部楼层
在GUI中操作的时候,旋转复制数量必须是整数,且不能是参数,脚本还真不清楚。
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2017-8-1 18:40 | 显示全部楼层
luomu 发表于 2017-8-1 15:53
在GUI中操作的时候,旋转复制数量必须是整数,且不能是参数,脚本还真不清楚。

是啊,所以转向了脚本,然后尝试了还是不行。论坛也没有相关的问题,期待高手
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|西莫电机圈 ( 浙ICP备10025899号-3 浙公网安备:33028202000436号

GMT+8, 2024-4-25 19:52 , Processed in 0.082285 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表