Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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
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