如何自动执行应力分析

目前没有应力分析的API,能做的只是直接执行相关的命令。例如若要执行分析,则命令名是:“FeaSimulateCmd”

image

而即便如此,只是弹出对话框。要让 【运行】自动执行,还需要模拟点击了【运行】按钮。这里可以用到VB中的一个技巧SendKeys。即发送【Enter】键给这个对话框,因为该对话框弹出时默认的焦点按钮时【运行】。【Enter】 则意味着按下了这个按钮。


image


另外,还需要首先激活应力分析的环境。 请参考如下代码:

Public Sub DoFea()

     Dim oDoc As Document

     Set oDoc = ThisApplication.ActiveDocument

     ‘if stress simulation is activated 
     Dim UIManager As UserInterfaceManager

    Set UIManager = ThisApplication.UserInterfaceManager

If UIManager.ActiveEnvironment.InternalName <> "FEA Environment Internal Name" Then

        ‘if it is not activated

        Dim environmentMgr As EnvironmentManager

        Set environmentMgr = oDoc.EnvironmentManager

        Dim dsEnv As Environment

        Set dsEnv = UIManager.Environments.Item("FEA Environment Internal Name")

        Call environmentMgr.SetCurrentEnvironment(dsEnv)

    End If

   ‘get [simulation] command

    Dim oCol As ControlDefinition

    Set oCol = ThisApplication.CommandManager.ControlDefinitions("FeaSimulateCmd")

    ‘send [enter] key to the dialog to mimic the clicking [Run]

SendKeys "{ENTER}"

‘execute the command. The dialog will pop out and execute run automatically. 
    oCol.Execute

End Sub


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值