A-A+

CATIA VBA(VBS) 二次开发中选择集的复制粘贴

2019年07月14日 CAD 阅读 1,813 views 次

在CATIA VBA(VBS)二次开发中可以使用Copy、PasteSpecial方法对选择集进行复制粘贴。示例代码如下:

Sub CATMain()

Dim Doc, Prt, SF, Slct, BodyO, BodyN

Set Doc = CATIA.ActiveDocument

Set Prt = Doc.Part

Set Slct = Doc.Selection

Dim Status, lType(0)

lType(0) = "Body"

Status = Slct.SelectElement2(lType,"Select the body to be copy", True)'这里是让用户选择实体

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

   Exit Sub

End If

Set BodyO = Slct.Item(1).Value'获取用户选择的实体

Slct.Copy

Slct.Add Prt

Slct.PasteSpecial("CATPrtResultWithOutLink")'复制目标实体,然后以AsResult的方式粘贴一个副本实体出来

Set BodyN = Slct.Item(1).Value

BodyN.Name = BodyO.Name &"_www.leanwind.com"'副本实体的命名

Slct.Clear

Prt.InWorkObject = BodyN

End Sub

代码运行结果如下:

PasteSpecial方法采用的粘贴格式如下:

(1)通用格式

"CATIA_LINK_FORMAT" to paste"Catia Link Source",

"OLE_LINK_FORMAT" to paste"Ole Link Source",

"OLE_EMBED_FORMAT" to paste"Ole Embed Source".

(2)在Part中

"CATPrtCont" to paste "AsSpecified In Part Document",

"CATPrtResultWithOutLink" topaste "AsResult",

"CATPrtResult" to paste"AsResultWithLink",

"CATMaterialCont" to paste"As material",

"AsMaterialLink" to paste"As material link",

"CATMechProdCont" to paste"As specified in Assembly",

"CATProdCont" to paste "Asspecified in Product Structure",

"CATIA_SPEC" to paste"CATIA_SPEC",

"CATIA_RESULT" to paste"CATIA_RESULT".

(3)在Product中

"CATProdCont" to paste "Asspecified in Product Structure",

"CATSpecBreakLink" to paste"Break Link".

(4)在Catalog中

"CATDescriptionFormat" to paste"As defined in catalog instanciation",

"CATCtlgChapterFormat" to paste"As defined in catalog document".

坐倚北风网站福利:本站用户可联系“HyperMesh钉子户”,免费获取Altair内部学习资料,包含HyperMesh,OptiStruct拓扑优化,HyperStudy(DOE+优化),电磁,流体等软件。联系微信cae-max
为您推荐:

给我留言

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

用户登录

分享到: