利用VBscripting的参数化分析《失败?》案例
本帖最后由 tomorrowgary 于 2017-8-1 09:40 编辑原设计是参数化设计,验证在不同的磁铁(红色蓝色)数量和定子(青褐色)槽数(线圈[黄色,图形中线圈和定子重叠了,因为参数没有调好]数量)的组合下,最佳的设计。故考虑用parametric设计,但是在对磁铁及线圈旋转复制时,数量参数只能是正整数,故转向VBscript,在数量参数中引用变量。但最终失败,别人告知,旋转复制数量参数不可以是变量,即使script中成功应用变量,但是parametric时,此参数不会发生变化。(也不知这个说法对不对,心里还抱有希望,希望大神指点)
因为在学习中,发现VBscript的例子较少,故贴出这个《失败》例子,也希望对大家有所帮助。先贴出代码,后期再完善这个帖子吧。代码主要是录制然后修改的。
' ----------------------------------------------
' Script Recorded by ANSYS Electronics Desktop Version 2016.2.0
' 15:05:107月 27, 2017
' ----------------this file is to implement whole parametric simulation, including the poles number,
'slot number as well as coils number, but variables can't be assigned to rotation, so failed.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
'a project name can be given to direct to a project
Set oDesign = oProject.GetActiveDesign()
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
'-------------------------------------------function--------------------------------------------
function Ain(number)
Ain="Ain_" & (number+1)'vb中函数返回应该用(函数名=返回值)定义
end function
function Aout(number)
Aout="Aout_" & (number+1)
end function
function Bin(number)
Bin="Bin_" & (number+1)
end function
function Bout(number)
Bout="Bout_" & (number+1)
end function
function Cin(number)
Cin="Cin_" & (number+1)
end function
function Cout(number)
Cout="Cout_" & (number+1)
end function
function AinRectanglem1(number)
if number=0 then
AinRectanglem1="Rectanglem1"
else
AinRectanglem1="Rectanglem1" & "_" & number*3
end if
end function
function AoutRectangles1(number)
if number=0 then
AoutRectangles1="Rectangles1"
else
AoutRectangles1="Rectangles1" & "_" & number*3
end if
end function
function BinRectanglem1(number)
BinRectanglem1="Rectanglem1" & "_" & number*3+1
end function
function BoutRectangles1(number)
BoutRectangles1="Rectangles1" & "_" & number*3+1
end function
function CinRectanglem1(number)
CinRectanglem1="Rectanglem1" & "_" & number*3+2
end function
function CoutRectangles1(number)
CoutRectangles1="Rectangles1" & "_" & number*3+2
end function
'----------------------------------------------inner rotor-------------------------------------------
oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=",_
false, "IsPolylineClosed:=", false, Array("NAME:PolylinePoints", Array("NAME:PLPoint", "X:=",_
"10mm", "Y:=", "0mm", "Z:=", "0mm"), Array("NAME:PLPoint", "X:=", "12.5mm", "Y:=",_
"0mm", "Z:=", "0mm")), Array("NAME:PolylineSegments", Array("NAME:PLSegment", "SegmentType:=",_
"Line", "StartIndex:=", 0, "NoOfPoints:=", 2)), Array("NAME:PolylineXSection", "XSectionType:=",_
"None", "XSectionOrient:=", "Auto", "XSectionWidth:=", "0mm", "XSectionTopWidth:=",_
"0mm", "XSectionHeight:=", "0mm", "XSectionNumSegments:=", "0", "XSectionBendType:=",_
"Corner")), Array("NAME:Attributes", "Name:=", "Polyline1", "Flags:=", "", "Color:=",_
"(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=",_
"", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",_
true)
oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=",_
false, "IsPolylineClosed:=", false, Array("NAME:PolylinePoints", Array("NAME:PLPoint", "X:=",_
"10mm", "Y:=", "0mm", "Z:=", "0mm"), Array("NAME:PLPoint", "X:=",_
"9.65925826289068mm", "Y:=", "2.58819045102521mm", "Z:=", "0mm"), Array("NAME:PLPoint", "X:=",_
"8.66025403784439mm", "Y:=", "5mm", "Z:=", "0mm")), Array("NAME:PolylineSegments", Array("NAME:PLSegment", "SegmentType:=",_
"AngularArc", "StartIndex:=", 0, "NoOfPoints:=", 3, "NoOfSegments:=", "0", "ArcAngle:=",_
"30deg", "ArcCenterX:=", "0mm", "ArcCenterY:=", "0mm", "ArcCenterZ:=", "0mm", "ArcPlane:=",_
"XY")), Array("NAME:PolylineXSection", "XSectionType:=", "None", "XSectionOrient:=",_
"Auto", "XSectionWidth:=", "0mm", "XSectionTopWidth:=", "0mm", "XSectionHeight:=",_
"0mm", "XSectionNumSegments:=", "0", "XSectionBendType:=", "Corner")), Array("NAME:Attributes", "Name:=",_
"Polyline2", "Flags:=", "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",_
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",_
true)
oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",_
"LocalVariables"), Array("NAME:NewProps", Array("NAME:poles", "PropType:=", "VariableProp", "UserDef:=",_
true, "Value:=", "1"))))
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DPolylineTab", Array("NAME:PropServers",_
"Polyline2:CreatePolyline:2:Segment0"), Array("NAME:ChangedProps", Array("NAME:Angle", "Value:=",_
"180deg/poles-5deg"))))
oEditor.SweepAlongPath Array("NAME:Selections", "Selections:=", "Polyline1,Polyline2", "NewPartsModelFlag:=",_
"Model"), Array("NAME:PathSweepParameters", "DraftAngle:=", "0deg", "DraftType:=",_
"Round", "CheckFaceFaceIntersection:=", false, "TwistAngle:=", "0deg")
Set oDefinitionManager = oProject.GetDefinitionManager()
oDefinitionManager.AddMaterial Array("NAME:myNdFe35", "CoordinateSystemType:=",_
"Cylindrical", Array("NAME:AttachedData"), Array("NAME:ModifierData"), "permittivity:=",_
"1", "permeability:=", "1.0997785406", "conductivity:=", "625000", "dielectric_loss_tangent:=",_
"0", "magnetic_loss_tangent:=", "0", Array("NAME:magnetic_coercivity", "property_type:=",_
"VectorProperty", "Magnitude:=", "-890000A_per_meter", "DirComp1:=", "1", "DirComp2:=",_
"0", "DirComp3:=", "0"), "thermal_conductivity:=", "0", "saturation_mag:=",_
"0gauss", "lande_g_factor:=", "2", "delta_H:=", "0Oe", "mass_density:=", "7400", "youngs_modulus:=",_
"147000000000", Array("NAME:thermal_expansion_coeffcient", "property_type:=",_
"AnisoProperty", "unit:=", "", "component1:=", "3e-006", "component2:=",_
"-5e-006", "component3:=", "-5e-006"))
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",_
"Polyline1"), Array("NAME:ChangedProps", Array("NAME:Material", "Value:=", "" & Chr(34) & "myNdFe35" & Chr(34) & ""))))
oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=", "Polyline1", "NewPartsModelFlag:=",_
"Model"), Array("NAME:DuplicateAroundAxisParameters", "CreateNewObjects:=", true, "WhichAxis:=",_
"Z", "AngleStr:=", "180deg/poles", "NumClones:=", "2*poles"), Array("NAME:Options", "DuplicateAssignments:=", false)
oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",_
"LocalVariables"), Array("NAME:NewProps", Array("NAME:sn", "PropType:=", "VariableProp", "UserDef:=",_
true, "Value:=", "6"))))
Set oModule = oDesign.GetModule("AnalysisSetup")
'------------------------------------analysis-------------------------------------------
oModule.InsertSetup "Transient", Array("NAME:Setup1", "Enabled:=", true, "NonlinearSolverResidual:=",_
"0.0001", "TimeIntegrationMethod:=", 0, "StopTime:=", "1s", "TimeStep:=", "0.1s", "OutputError:=",_
false, "UseControlProgram:=", false, "ControlProgramName:=", " ", "ControlProgramArg:=",_
" ", "CallCtrlProgAfterLastStep:=", false, "FastReachSteadyState:=", false, "IsGeneralTransient:=",_
true, "NumberOfTimeSubDivisions:=", 1, "HasSweepSetup:=", true, "SweepSetupType:=",_
"LinearStep", "StartValue:=", "0ns", "StopValue:=", "1s", "StepSize:=", "0.1s", "UseAdaptiveTimeStep:=",_
false, "InitialTimeStep:=", "0.002s", "MinTimeStep:=", "0.001s", "MaxTimeStep:=",_
"0.003s", "TimeStepErrTolerance:=", 0.0001)
Set oModule = oDesign.GetModule("Optimetrics")
'-----------------------------------parametric analysis------------------------------------
oModule.InsertSetup "OptiParametric", Array("NAME:ParametricSetup1", "IsEnabled:=",_
true, Array("NAME:ProdOptiSetupData", "SaveFields:=", true, "CopyMesh:=", false), Array("NAME:StartingPoint"), "Sim. Setups:=", Array( _
"Setup1"), Array("NAME:Sweeps", Array("NAME:SweepDefinition", "Variable:=", "poles", "Data:=",_
"LIN 1 3 1", "OffsetF1:=", false, "Synchronize:=", 0), Array("NAME:SweepDefinition", "Variable:=",_
"sn", "Data:=", "LIN 6 12 3", "OffsetF1:=", false, "Synchronize:=", 0)), Array("NAME:Sweep Operations"), Array("NAME:Goals", Array("NAME:Goal", "ReportType:=",_
"Transient", "Solution:=", "Setup1 : Transient", Array("NAME:SimValueContext", "Context:=",_
"Moving1"), "Calculation:=", "rms(abs(FluxLinkage(Ayellow)))", "Name:=",_
"FluxLinkage(Ayellow)", Array("NAME:Ranges", "Range:=", Array("Var:=", "Time", "Type:=",_
"a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",_
"Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",_
"rms(FluxLinkage(Bgreen))", "Name:=", "rms(FluxLinkage(Bgreen))", Array("NAME:Ranges", "Range:=", Array("Var:=",_
"Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",_
"Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",_
"rms(FluxLinkage(Cblue))", "Name:=", "rms(FluxLinkage(Cblue))", Array("NAME:Ranges", "Range:=", Array("Var:=",_
"Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",_
"Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",_
"rms(InducedVoltage(Ayellow))", "Name:=", "rms(InducedVoltage(Ayellow))", Array("NAME:Ranges", "Range:=", Array("Var:=",_
"Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",_
"Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",_
"rms(InducedVoltage(Bgreen))", "Name:=", "rms(InducedVoltage(Bgreen))", Array("NAME:Ranges", "Range:=", Array("Var:=",_
"Time", "Type:=", "a"))), Array("NAME:Goal", "ReportType:=", "Transient", "Solution:=",_
"Setup1 : Transient", Array("NAME:SimValueContext", "Context:=", "Moving1"), "Calculation:=",_
"rms(InducedVoltage(Cblue))", "Name:=", "rms(InducedVoltage(Cblue))", Array("NAME:Ranges", "Range:=", Array("Var:=",_
"Time", "Type:=", "a")))))
oProject.Save
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
'------------------------------------------stator----------------------------------
oEditor.CreateUserDefinedPart Array("NAME:UserDefinedPrimitiveParameters", "DllName:=",_
"RMxprt/SlotCore.dll", "Version:=", "12.1", "NoOfParameters:=", 19, "Library:=",_
"syslib", Array("NAME:ParamVector", Array("NAME:Pair", "Name:=", "DiaGap", "Value:=",_
"19.4mm"), Array("NAME:Pair", "Name:=", "DiaYoke", "Value:=", "3mm"), Array("NAME:Pair", "Name:=",_
"Length", "Value:=", "0mm"), Array("NAME:Pair", "Name:=", "Skew", "Value:=", "0deg"), Array("NAME:Pair", "Name:=",_
"Slots", "Value:=", "sn"), Array("NAME:Pair", "Name:=", "SlotType", "Value:=", "1"), Array("NAME:Pair", "Name:=",_
"Hs0", "Value:=", "0.5mm"), Array("NAME:Pair", "Name:=", "Hs01", "Value:=", "0mm"), Array("NAME:Pair", "Name:=",_
"Hs1", "Value:=", "0.6mm"), Array("NAME:Pair", "Name:=", "Hs2", "Value:=",_
"3mm"), Array("NAME:Pair", "Name:=", "Bs0", "Value:=", "1mm"), Array("NAME:Pair", "Name:=",_
"Bs1", "Value:=", "3mm"), Array("NAME:Pair", "Name:=", "Bs2", "Value:=", "0.3mm"), Array("NAME:Pair", "Name:=",_
"Rs", "Value:=", "0mm"), Array("NAME:Pair", "Name:=", "FilletType", "Value:=", "0"), Array("NAME:Pair", "Name:=",_
"HalfSlot", "Value:=", "0"), Array("NAME:Pair", "Name:=", "SegAngle", "Value:=",_
"15deg"), Array("NAME:Pair", "Name:=", "LenRegion", "Value:=",_
"200mm"), Array("NAME:Pair", "Name:=", "InfoCore", "Value:=", "0"))), Array("NAME:Attributes", "Name:=",_
"SlotCore1", "Flags:=", "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",_
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",_
true)
Set oDefinitionManager = oProject.GetDefinitionManager()
oDefinitionManager.AddMaterial Array("NAME:mysteel_1009", "CoordinateSystemType:=",_
"Cartesian", Array("NAME:AttachedData"), Array("NAME:ModifierData"), Array("NAME:permeability", "property_type:=",_
"nonlinear", "BType:=", "normal", "HUnit:=", "A_per_meter", "BUnit:=", "tesla", Array("NAME:BHCoordinates", Array("NAME:Coordinate", "X:=",_
0, "Y:=", 0), Array("NAME:Coordinate", "X:=", 159.2, "Y:=", 0.2402), Array("NAME:Coordinate", "X:=",_
318.3, "Y:=", 0.8654), Array("NAME:Coordinate", "X:=", 477.5, "Y:=", 1.1106), Array("NAME:Coordinate", "X:=",_
636.6, "Y:=", 1.2458), Array("NAME:Coordinate", "X:=", 795.8, "Y:=", 1.331), Array("NAME:Coordinate", "X:=",_
1591.5, "Y:=", 1.5), Array("NAME:Coordinate", "X:=", 3183.1, "Y:=", 1.6), Array("NAME:Coordinate", "X:=",_
4774.6, "Y:=", 1.683), Array("NAME:Coordinate", "X:=", 6366.2, "Y:=", 1.741), Array("NAME:Coordinate", "X:=",_
7957.7, "Y:=", 1.78), Array("NAME:Coordinate", "X:=", 15915.5, "Y:=", 1.905), Array("NAME:Coordinate", "X:=",_
31831, "Y:=", 2.025), Array("NAME:Coordinate", "X:=", 47746.5, "Y:=", 2.085), Array("NAME:Coordinate", "X:=",_
63662, "Y:=", 2.13), Array("NAME:Coordinate", "X:=", 79577.5, "Y:=", 2.165), Array("NAME:Coordinate", "X:=",_
159155, "Y:=", 2.28), Array("NAME:Coordinate", "X:=", 318310, "Y:=", 2.485), Array("NAME:Coordinate", "X:=",_
397887, "Y:=", 2.5851))), "conductivity:=", "0", "magnetic_loss_tangent:=", "0", Array("NAME:magnetic_coercivity", "property_type:=",_
"VectorProperty", "Magnitude:=", "0A_per_meter", "DirComp1:=", "1", "DirComp2:=",_
"0", "DirComp3:=", "0"), "thermal_conductivity:=", "45", Array("NAME:core_loss_type", "property_type:=",_
"ChoiceProperty", "Choice:=", "Electrical Steel"), "core_loss_kh:=", "190", "core_loss_kc:=",_
"0.822", "core_loss_ke:=", "0", "core_loss_kdc:=", "0", "mass_density:=", "7872", Array("NAME:stacking_type", "property_type:=",_
"ChoiceProperty", "Choice:=", "Lamination"), "stacking_factor:=", "0.96", Array("NAME:stacking_direction", "property_type:=",_
"ChoiceProperty", "Choice:=", "V(3)"), "specific_heat:=", "481", "youngs_modulus:=",_
"200000000000", "poissons_ratio:=", "0.25", "thermal_expansion_coeffcient:=",_
"1.26e-005")
oProject.Save
'-------------------------------------------coil--------------------------------------------
oEditor.CreateRectangle Array("NAME:RectangleParameters", "IsCovered:=", false, "XStart:=",_
"7.4mm", "YStart:=", "1.4mm", "ZStart:=", "0mm", "Width:=", "-0.4mm", "Height:=",_
"0.4mm", "WhichAxis:=", "Z"), Array("NAME:Attributes", "Name:=", "Rectangle1", "Flags:=",_
"", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",_
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "mysteel_1009" & Chr(34) & "", "SolveInside:=",_
true)
oEditor.CoverLines Array("NAME:Selections", "Selections:=", "Rectangle1", "NewPartsModelFlag:=",_
"Model")
oEditor.DuplicateMirror Array("NAME:Selections", "Selections:=", "Rectangle1", "NewPartsModelFlag:=",_
"Model"), Array("NAME:DuplicateToMirrorParameters", "DuplicateMirrorBaseX:=", "0mm", "DuplicateMirrorBaseY:=",_
"0mm", "DuplicateMirrorBaseZ:=", "0mm", "DuplicateMirrorNormalX:=", "0mm", "DuplicateMirrorNormalY:=",_
"1mm", "DuplicateMirrorNormalZ:=", "0mm"), Array("NAME:Options", "DuplicateAssignments:=",_
false)
oEditor.Renamepart Array("NAME:Rename Data","Old Name:=", "Rectangle1","New Name:=", "Rectanglem1")
oEditor.Renamepart Array("NAME:Rename Data","Old Name:=", "Rectangle1_1","New Name:=", "Rectangles1")
oDefinitionManager.AddMaterial Array("NAME:mycopper", "CoordinateSystemType:=",_
"Cartesian", Array("NAME:AttachedData"), Array("NAME:ModifierData"), "permeability:=",_
"0.999991", "conductivity:=", "58000000", "thermal_conductivity:=", "400", "mass_density:=",_
"8933", "specific_heat:=", "385", "youngs_modulus:=", "120000000000", "poissons_ratio:=",_
"0.38", "thermal_expansion_coeffcient:=", "1.77e-005")
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",_
"Rectanglem1", "Rectangles1"), Array("NAME:ChangedProps", Array("NAME:Material", "Value:=",_
"" & Chr(34) & "mycopper" & Chr(34) & ""))))
oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=",_
"Rectanglem1,Rectangles1", "NewPartsModelFlag:=", "Model"), Array("NAME:DuplicateAroundAxisParameters", "CreateNewObjects:=",_
true, "WhichAxis:=", "Z", "AngleStr:=", "360deg/sn", "NumClones:=", "sn"), Array("NAME:Options", "DuplicateAssignments:=",_
false)
'------------------------------------------windings--------------------------------------
oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",_
"LocalVariables"), Array("NAME:NewProps", Array("NAME:nocoils", "PropType:=",_
"VariableProp", "UserDef:=", true, "Value:=", "60"))))'define coil numbers
Set oModule = oDesign.GetModule("BoundarySetup")
loopsn=CInt(oDesign.GetVariableValue("sn"))
for j=0 to (loopsn/3-1)
oModule.AssignCoil Array("NAME:Ain_"&j+1, "Objects:=", Array( AinRectanglem1(j) ), "Conductor number:=",_
"nocoils", "PolarityType:=", "Positive")
oModule.AssignCoil Array("NAME:Aout_"&j+1, "Objects:=", Array( AoutRectangles1(j) ), "Conductor number:=",_
"nocoils", "PolarityType:=", "Negative")
oModule.AssignCoil Array("NAME:Bin_"&j+1, "Objects:=", Array( BinRectanglem1(j) ), "Conductor number:=",_
"nocoils", "PolarityType:=", "Positive")
oModule.AssignCoil Array("NAME:Bout_"&j+1, "Objects:=", Array( BoutRectangles1(j) ), "Conductor number:=",_
"nocoils", "PolarityType:=", "Negative")
oModule.AssignCoil Array("NAME:Cin_"&j+1, "Objects:=", Array( CinRectanglem1(j) ), "Conductor number:=",_
"nocoils", "PolarityType:=", "Positive")
oModule.AssignCoil Array("NAME:Cout_"&j+1, "Objects:=", Array( CoutRectangles1(j) ), "Conductor number:=",_
"nocoils", "PolarityType:=", "Negative")
Next
oModule.AssignWindingGroup Array("NAME:Ayellow", "Type:=", "Current", "IsSolid:=",_
false, "Current:=", "0mA", "Resistance:=", "0ohm", "Inductance:=", "0nH", "Voltage:=",_
"0mV", "ParallelBranchesNum:=", "1")
oModule.AssignWindingGroup Array("NAME:Bgreen", "Type:=", "Current", "IsSolid:=",_
false, "Current:=", "0mA", "Resistance:=", "0ohm", "Inductance:=", "0nH", "Voltage:=",_
"0mV", "ParallelBranchesNum:=", "1")
oModule.AssignWindingGroup Array("NAME:Cblue", "Type:=", "Current", "IsSolid:=",_
false, "Current:=", "0mA", "Resistance:=", "0ohm", "Inductance:=", "0nH", "Voltage:=",_
"0mV", "ParallelBranchesNum:=", "1")
oProject.Save
'--------------------addcoilstowinding---------------------------------------------
for j=0 to (loopsn/3-1)
oModule.EditCoil Ain(j), Array("NAME:Ain_"&j+1, "ParentBndID:=", "Ayellow", "Conductor number:=",_
"nocoils", "Winding:=", "Ayellow", "PolarityType:=", "Positive")
oModule.EditCoil Aout(j), Array("NAME:Aout_"&j+1, "ParentBndID:=", "Ayellow", "Conductor number:=",_
"nocoils", "Winding:=", "Ayellow", "PolarityType:=", "negative")
oModule.EditCoil Bin(j), Array("NAME:Bin_"&j+1, "ParentBndID:=", "Bgreen", "Conductor number:=",_
"nocoils", "Winding:=", "Bgreen", "PolarityType:=", "Positive")
oModule.EditCoil Bout(j), Array("NAME:Bout_"&j+1, "ParentBndID:=", "Bgreen", "Conductor number:=",_
"nocoils", "Winding:=", "Bgreen", "PolarityType:=", "negative")
oModule.EditCoil Cin(j), Array("NAME:Cin_"&j+1, "ParentBndID:=", "Cblue", "Conductor number:=",_
"nocoils", "Winding:=", "Cblue", "PolarityType:=", "Positive")
oModule.EditCoil Cout(j), Array("NAME:Cout_"&j+1, "ParentBndID:=", "Cblue", "Conductor number:=",_
"nocoils", "Winding:=", "Cblue", "PolarityType:=", "negative")
Next
'-------------------------------------------band and region---------------------------------
oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", false, "XCenter:=",_
"0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "9.80mm", "WhichAxis:=",_
"Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle1", "Flags:=",_
"", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",_
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",_
true)
oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", false, "XCenter:=",_
"0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "12.7mm", "WhichAxis:=",_
"Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle2", "Flags:=",_
"", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",_
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",_
true)
oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", false, "XCenter:=",_
"0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "20mm", "WhichAxis:=",_
"Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle3", "Flags:=",_
"", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",_
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",_
true)
oEditor.CoverLines Array("NAME:Selections", "Selections:=", "Circle1,Circle2,Circle3", "NewPartsModelFlag:=",_
"Model")
oEditor.Subtract Array("NAME:Selections", "Blank Parts:=", "Circle2", "Tool Parts:=",_
"Circle1"), Array("NAME:SubtractParameters", "KeepOriginals:=", false)
Set oModule = oDesign.GetModule("BoundarySetup")
edgeid =oEditor.GetEdgeByPosition(Array("NAME:EdgeParameters", "BodyName:=", "Circle3", "XPosition:=", "20mm", _
"YPosition:=", "0mm", "ZPosition:=", "0mm"))
oModule.AssignVectorPotential Array("NAME:VectorPotential1", "Edges:=",Array(edgeid) ,"Value:=",_
"0", "CoordinateSystem:=", "")
Set oModule = oDesign.GetModule("ModelSetup")
oModule.AssignBand Array("NAME:Data", "Move Type:=", "Rotate", "Coordinate System:=",_
"Global", "Axis:=", "Z", "Is Positive:=", true, "InitPos:=", "0deg", "HasRotateLimit:=",_
false, "NonCylindrical:=", false, "Consider Mechanical Transient:=", false, "Angular Velocity:=",_
"60rpm", "Objects:=", Array("Circle2"))
Set oModule = oDesign.GetModule("MeshSetup")
'---------------------------------------mesh-------------------------------------------
oModule.AssignLengthOp Array("NAME:Length1", "RefineInside:=", false, "Enabled:=",_
true, "Objects:=", Array("Circle3"), "RestrictElem:=", false, "NumMaxElem:=",_
"1000", "RestrictLength:=", true, "MaxLength:=", "0.5mm") 在GUI中操作的时候,旋转复制数量必须是整数,且不能是参数,脚本还真不清楚。 luomu 发表于 2017-8-1 15:53
在GUI中操作的时候,旋转复制数量必须是整数,且不能是参数,脚本还真不清楚。
是啊,所以转向了脚本,然后尝试了还是不行。论坛也没有相关的问题,期待高手
页:
[1]