A-A+

CATIA在VBA(VBS)二次开发中使用HybridShapeFactory创建标准图形曲面的方法

2019年06月29日 CAD 阅读 1,246 views 次

下面以一个球形曲面的创建为例,介绍在CATIA中使用VBA(VBS)进行二次开发时通过HybridShapeFactory类创建标准图形曲面的方法。示例代码如下:(代码中有关对象选择的详细介绍可参考文章《CATIA使用VBA(VBS)二次开发时用户的交互选择》。)

Sub catmain()

Dim iSelection

Set iSelection =CATIA.ActiveDocument.Selection

Dim iStatus, iType(0)

Dim iHB,iHSF,iPoint,iRadius,iSphere

'选择中心点

iType(0) = "HybridShape"

iStatus = iSelection.SelectElement2(iType,"Please select the Point", False)

If iStatus = "Redo" Or iStatus ="Undo" Or iStatus = "Cancel" Then   

   Exit Sub   

End If

Set iPoint=iSelection.Item2(1).Value

'选择放置曲面的Geometricalset部件集

iType(0) = "HybridBody"

iStatus = iSelection.SelectElement2(iType,"Please select the Geometrical Set", False)

If iStatus = "Redo" Or iStatus ="Undo" Or iStatus = "Cancel" Then   

   Exit Sub   

End If

Set iHB=iSelection.Item2(1).Value

'输入半径

iRadius = InputBox("Please inputradius", "Radios", 3)

Set iHSF =CATIA.ActiveDocument.Part.HybridShapeFactory

'创建球形曲面

Set iSphere = iHSF.AddNewSphere(iPoint,Nothing, iRadius, -45, 45, 0, 180)

iSphere.Limitation = 1

'将曲面添加到元素集

iHB.AppendHybridShape iSphere

'曲面命名

iSphere.Name = iPoint.Name &"_www.leanwind.com"

iSelection.Clear

CATIA.ActiveDocument.Part.Update

End Sub

创建效果如下所示:

个人公众号“数字化设计CAX联盟”,欢迎关注,共同交流
为您推荐:

给我留言

© 坐倚北风 版权所有 严禁镜像复制 苏ICP备15034888号. 基于 Ality 主题定制 AliCMS
联系邮箱:leanwind@163.con,微信公众号:数字化设计CAX联盟

用户登录

分享到: