- 积分
- 720
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 25
- 最后登录
- 1970-1-1
该用户从未签到
|
楼主 |
发表于 2019-4-23 17:25
|
显示全部楼层
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftMaxwell.MaxwellScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.GetActiveDesign()
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Dim points(), segments()
Dim NumPoints, R(2), P(2), PointsPerTurn, Turns, Units
Pi = 4*Atn(1)
Units = InputBox("Select the units:"&Chr(13)& "(cm,mm,um,in,mil)", "Variable Helix","mil",50,50)
Select Case Units
Case "m"
Units = ""
Case "cm"
Case "mm"
Case "um"
Case "in"
Case "mil"
Case Else
MsgBox("Invalid Units - defaults to m")
Units = ""
End Select
Turns = InputBox("Select the number of turns (must be integer):","Variable Helix", 2,50,50)
PointsPerTurn = InputBox("Select the points per turn:", "Variable Helix",16,50,50)
R(0) = InputBox("Select the initial Radius: ", "Variable Helix",10,50,50)
R(1) = InputBox("Select the final Radius: ", "Variable Helix",10,50,50)
P(0) = InputBox("Select the initial Pitch: ", "Variable Helix", 4,50,50)
P(1) = InputBox("Select the final Pitch: ", "Variable Helix", 4,50,50)
NumPoints = Turns*PointsPerTurn
Redim points(NumPoints+1)
Redim segments(NumPoints)
points(0) = "NAME:PolylinePoints"
segments(0) = "NAME:PolylineSegments"
For n = 1 To (NumPoints+1)
Angle = (n-1)*2*Pi/PointsPerTurn
Radius = R(0) + ((n-1)/NumPoints)*(R(1)-R(0))
Pitch = P(0) + ((n-1)/NumPoints)*(P(1)-P(0))
Rise = (n-1)*Pitch/PointsPerTurn
XValue = cstr(Radius*cos(Angle)) & Units
YValue = cstr(Radius*sin(Angle)) & Units
ZValue = cstr(Rise) & Units
points(n) = Array("NAME:PLPoint", "X:=", XValue, "Y:=", YValue, "Z:=", ZValue)
If n<=NumPoints Then
segments(n) = Array("NAME:PLSegment", "SegmentType:=", "Line", "StartIndex:=", (n-1), "NoOfPoints:=", 2)
End If
Next
oEditor.CreatePolyline Array("NAME:PolylineParameters", "IsPolylineCovered:=", true, "IsPolylineClosed:=", false, points, segments), Array("NAME:Attributes", "Name:=", "Line_Helix","Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=",0.4, "PartCoordinateSystem:=", "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", true, "XCenter:=",cstr(R(0))&Units, "YCenter:=", 0, "ZCenter:=", 0, "Radius:=", "1"&Units, "WhichAxis:=", "Y"), Array("NAME:Attributes", "Name:=", "Circle_Helix", "Flags:=", "", "Color:=", "(132 132 193)", "Transparency:=", 0.4, "PartCoordinateSystem:=", "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
oEditor.SweepAlongPath Array("NAME:Selections", "Selections:=", "Circle_Helix,Line_Helix"), Array("NAME:PathSweepParameters", "DraftAngle:=", "0deg", "DraftType:=", "Round", "TwistAngle:=", "0deg") |
|