找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

Flux电机有限元分析教程西莫团购入口 | 奖励入口当当网购物入口 | 奖励入口欢迎使用!西莫论坛App开放下载Motor-CAD电机多物理域设计教材购买入口 | 奖励入口
★新会员论坛须知★《西莫电机技术》第39期发售火热进行中Flux电机电磁阀有限元分析教程团购入口 | 奖励入口论坛微信公众平台欢迎入驻
西莫电机及相关产品供需交流群开放邀请★ 论坛VIP会员申请 ★Motor-CAD.MANATEE电磁热振动噪声教程 | 奖励入口西莫团队欢迎您的加盟!
宣传推广合作请联系QQ:25941174西莫电机论坛微信群正式开放Flux变压器与电抗器有限元分析团购入口 | 奖励入口西莫电机论坛技术版区QQ群汇总
查看: 2251|回复: 4

如何反复用VBS调用ANSOFT命令做重复运算

[复制链接]

该用户从未签到

发表于 2012-6-23 13:44 | 显示全部楼层 |阅读模式 来自: 新加坡

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

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

×
我原本想变换不同不同转角运算不同力然后结果存入不同文件, 希望大家帮忙
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftMaxwell.MaxwellScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.OpenProject  _
  "C:/study-Ansoft/DUMP-0.4-0-acuratedegP.mxwl"
Set oProject = oDesktop.SetActiveProject("DUMP-0.4-0-acuratedegP")
Set oDesign = oProject.SetActiveDesign("0.4eccentricity")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.Delete Array("NAME:Selections", "Selections:=", "air_gap")


for i=199 to 200

rangledeg=i*1.8

oEditor.Rotate Array("NAME:Selections", "Selections:=",  _
  "N1,N2,N3,N4,N5,S1,S2,S3,S4,S5,rotor_core,axis", "NewPartsModelFlag:=", "Model"), Array("NAME:RotateParameters", "RotateAxis:=",  _
  "Z", "RotateAngle:=", "rangledeg")
oEditor.CreateCircle Array("NAME:CircleParameters", "IsCovered:=", true, "XCenter:=",  _
  "0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm", "Radius:=", "20.0000000000000mm", "WhichAxis:=",  _
  "Z", "NumSegments:=", "0"), Array("NAME:Attributes", "Name:=", "Circle7", "Flags:=",  _
  "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=",  _
  true)
oEditor.Subtract Array("NAME:Selections", "Blank Parts:=", "Circle7", "Tool Parts:=",  _
  "axis,N1,N2,N3,N4,N5,rotor_core,S1,S2,S3,S4,S5"), Array("NAME:SubtractParameters", "KeepOriginals:=",  _
  true)
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",  _
  "Circle7"), Array("NAME:ChangedProps", Array("NAME:Name", "Value:=", "air_gap"), Array("NAME:Material", "Value:=",  _
  "" & Chr(34) & "air" & Chr(34) & ""))))
Set oModule = oDesign.GetModule("MeshSetup")
oModule.AssignLengthOp Array("NAME:air_gap", "RefineInside:=", false, "Enabled:=",  _
  true, "Objects:=", Array("air_gap"), "RestrictElem:=", true, "NumMaxElem:=",  _
  "1512", "RestrictLength:=", false, "MaxLength:=", "8.00000005342773mm")

oDesign.ApplyMeshOps Array("Setup1")

oDesign.Analyze "Setup1"
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CreateFieldPlot Array("NAME:Mesh1", "SolutionName:=", "Setup1 : LastAdaptive", "QuantityName:=",  _
  "Mesh", "PlotFolder:=", "MeshPlots", "FieldType:=", "Fields", "UserSpecifyName:=",  _
  0, "UserSpecifyFolder:=", 0, "StreamlinePlot:=", false, "IntrinsicVar:=", "", "PlotGeomInfo:=", Array( _
  1, "Surface", "FacesList", 26, "7", "7316", "7317", "7318", "7319", "7320",  _
  "7321", "7322", "7323", "7324", "7325", "7326", "7327", "11890", "11894",  _
  "11905", "11916", "11927", "11938", "11949", "11960", "11971", "11982", "11996",  _
  "12002", "12327"), "FilterBoxes:=", Array(0), "Real time mode:=", true, Array("NAME:MeshSettings", "Scale factor:=",  _
  100, "Transparency:=", 0, "Mesh type:=", "Shaded", "Surface only:=", true, "Add grid:=",  _
  true, "Refinement:=", 0, "Use geometry color:=", true, "Mesh line color:=", Array( _
  0, 0, 255), "Filled color:=", Array(255, 255, 255)))
oModule.CreateFieldPlot Array("NAME:Flux_Lines1", "SolutionName:=",  _
  "Setup1 : LastAdaptive", "QuantityName:=", "Flux_Lines", "PlotFolder:=", "A", "UserSpecifyName:=",  _
  0, "UserSpecifyFolder:=", 0, "StreamlinePlot:=", false, "IntrinsicVar:=", "", "PlotGeomInfo:=", Array( _
  1, "Surface", "FacesList", 26, "7", "7316", "7317", "7318", "7319", "7320",  _
  "7321", "7322", "7323", "7324", "7325", "7326", "7327", "11890", "11894",  _
  "11905", "11916", "11927", "11938", "11949", "11960", "11971", "11982", "11996",  _
  "12002", "12327"), "FilterBoxes:=", Array(1, ""), Array("NAME:PlotOnSurfaceSettings", "Filled:=",  _
  false, "IsoValType:=", "Line", "SmoothShade:=", true, "AddGrid:=", false, "MapTransparency:=",  _
  true, "Refinement:=", 0, "Transparency:=", 0, Array("NAME:Arrow3DSpacingSettings", "ArrowUniform:=",  _
  true, "ArrowSpacing:=", 0, "MinArrowSpacing:=", 0, "MaxArrowSpacing:=", 0), "GridColor:=", Array( _
  255, 255, 255)))
oModule.CreateFieldPlot Array("NAME:Mag_B1", "SolutionName:=",  _
  "Setup1 : LastAdaptive", "QuantityName:=", "Mag_B", "PlotFolder:=", "B", "UserSpecifyName:=",  _
  0, "UserSpecifyFolder:=", 0, "StreamlinePlot:=", false, "IntrinsicVar:=", "", "PlotGeomInfo:=", Array( _
  1, "Surface", "FacesList", 26, "7", "7316", "7317", "7318", "7319", "7320",  _
  "7321", "7322", "7323", "7324", "7325", "7326", "7327", "11890", "11894",  _
  "11905", "11916", "11927", "11938", "11949", "11960", "11971", "11982", "11996",  _
  "12002", "12327"), "FilterBoxes:=", Array(1, ""), Array("NAME:PlotOnSurfaceSettings", "Filled:=",  _
  false, "IsoValType:=", "Fringe", "SmoothShade:=", true, "AddGrid:=", false, "MapTransparency:=",  _
  true, "Refinement:=", 0, "Transparency:=", 0, Array("NAME:Arrow3DSpacingSettings", "ArrowUniform:=",  _
  true, "ArrowSpacing:=", 0, "MinArrowSpacing:=", 0, "MaxArrowSpacing:=", 0), "GridColor:=", Array( _
  255, 255, 255)))
oProject.SaveAs  _
  "C:\study-Ansoft\DUMP-0.4-rangledeg-acuratedegP.mxwl",  _
  true

next
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过

该用户从未签到

 楼主| 发表于 2012-6-23 13:46 | 显示全部楼层 来自: 新加坡
出错行为:
oEditor.Rotate Array("NAME:Selections", "Selections:=",  _
  "N1,N2,N3,N4,N5,S1,S2,S3,S4,S5,rotor_core,axis", "NewPartsModelFlag:=", "Model"), Array("NAME:RotateParameters", "RotateAxis:=",  _
  "Z", "RotateAngle:=", "rangledeg")

oProject.SaveAs  _
  "C:\study-Ansoft\DUMP-0.4-rangledeg-acuratedegP.mxwl",  _
  true
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2012-6-23 14:25 | 显示全部楼层 来自: 新加坡
"RotateAngle:=", "rangledeg")中的rangledeg是字符还是变量?
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

该用户从未签到

发表于 2012-10-5 17:59 | 显示全部楼层 来自: 中国河北石家庄

既然加“”号了,自然是字符串,如果想用变量的话,直接写变量名字即可
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2012-10-11 09:09 | 显示全部楼层 来自: 新加坡
问题已解决, 谢谢
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

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

本版积分规则

西莫电机论坛微信公众平台欢迎您的关注!

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

GMT+8, 2024-12-23 13:10 , Processed in 0.881270 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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