tft每日頭條

 > 科技

 > vba如何添加到catia界面

vba如何添加到catia界面

科技 更新时间:2024-11-29 22:46:52

vba如何添加到catia界面?Function GetFeatureId(ByVal prd As product, ByVal Feature As AnyObject) On Error Resume Next,現在小編就來說說關于vba如何添加到catia界面?下面内容希望能幫助到你,我們來一起看看吧!

vba如何添加到catia界面(CATIA二次開發VBA)1

vba如何添加到catia界面

Function GetFeatureId(ByVal prd As product, ByVal Feature As AnyObject)

On Error Resume Next

Dim prms As parameters

Set prms = prd.parameters

Dim prm As parameter

Set prm = prms.CreateString("FeatureId", "")

Dim rlts As Relations

Set rlts = prd.Relations

Dim prmExp As String

prmExp = prms.GetNameToUseInRelation(Feature)

If left(prmExp, 1) = "`" Then

prmExp = prmExp & "->Id()"

Else

prmExp = "`" & prd.PartNumber & "\" & prmExp & "`->Id()"

End If

Dim frml As Formula

Set frml = rlts.CreateFormula("GetId", "獲取Id", prm, prmExp)

GetFeatureId = prm.ValueAsString

rlts.Remove frml.name

prms.Remove prm.name

End Function

調用示例:Sub test_getFeatId()

Dim doc As Document

Set doc = CATIA.ActiveDocument

Dim prd As product

Set prd = doc.product

Dim prt As Part

Set prt = doc.Part

Dim sel As Selection

Set sel = doc.Selection

Dim selObj As AnyObject

Set selObj = sel.Item(1).value

Debug.Print GetFeatureId(prd, selObj)

Debug.Print selObj.name

End Sub

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved