cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to get featId from the method compConstraint.AssemblyReference.SelModel ? vb

AB_9712131
4-Participant

How to get featId from the method compConstraint.AssemblyReference.SelModel ? vb

Hi I need to extract the component featID from the method ..compConstraint.AssemblyReference.SelModel (vb api)

 

Please, can you give me a tip?

 

For example, from the constraints of the component (SCREW_1), I want to read the Model feat ID (HW00293664-00)  owner of the assembly reference side

AB_9712131_1-1631732729554.png

 

 

Below the function that I built  to retrieve a dictionary of (ModelOwnerAssemblyRef Feat ID, ModelOwner AssemblyRef FileName)


Public Function getModelRefAsm(ByRef session As IpfcBaseSession, ByRef component As IpfcModelItem) As Dictionary(Of String, String)


Dim item As IpfcModelItem
Dim asmComp As IpfcComponentFeat

Dim compConstraints As CpfcComponentConstraints
Dim compConstraint As IpfcComponentConstraint

Dim asmReference As IpfcSelection

Dim modelNameRefAsm As String
Dim idModelNameRefAsm As String

Dim compInfoFun As New fastenerInfo


Try

item = CType(component, IpfcModelItem)
asmComp = CType(item, IpfcComponentFeat)
compConstraints = asmComp.GetConstraints()

If compConstraints Is Nothing OrElse compConstraints.Count = 0 Then
Throw New Exception("The component has no constraints")
End If

'======================================================================
'Loop through all the constraints
'======================================================================
For i = 0 To compConstraints.Count - 1

compConstraint = compConstraints.Item(i)

'======================================================================
'Model - Assembly reference geometry
'======================================================================
asmReference = compConstraint.AssemblyReference

'filename
If Not asmReference Is Nothing Then

modelNameRefAsm = compConstraint.AssemblyReference.SelModel.FileName
Else
modelNameRefAsm = "Not Found"
End If

'Feat id?
If Not asmReference Is Nothing Then

idModelNameRefAsm = compConstraint.AssemblyReference.SelModel '********* I need its component id
Else
idModelNameRefAsm = "Not Found"
End If


If Not compInfoFun.ModelAsmRefs.ContainsKey(idModelNameRefAsm) Then
compInfoFun.ModelAsmRefs.Add(idModelNameRefAsm, modelNameRefAsm)
End If
Next

'dic (hashcode,modelName)
Return compInfoFun.ModelAsmRefs

Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
Return Nothing
End Try


End Function

 

Thank you a lot in advance

0 REPLIES 0
Top Tags