Issue
Is there a way to determine if a given part occurrence is a tube?
Solution
For tube part occurrence, there is an attribute set called “IFC_ATTRIBUTER_SET” on the occurrence object and there is an attribute called PATHCOMPTYPE. If the value of the attribute is 9, it means this is an occurrence of a tube part.
Otherwise you can check the PropertySets of the document. There is a PropertySet called "Content Library Component Properties" in which "Member" Property contains data in XML format that also contains whether the Document is a TubeAndPipeComponent.
Below is a code that checks a Document’s PropertySets and lists them in the Debug (Immediate) window in the VBA environment, and prints the property value mentioned above.
VB .NET
Sub PropTest()
Dim oDoc As Inventor.Document = oApp.ActiveDocument
For Each oPS As PropertySet In oDoc.PropertySets
Debug.Print("")
&#
160; Debug.Print("=======> " & oPS.Name)
For Each oP As Inventor.Property In oPS
Try
If VarType(oP.Value) = vbString Then
Dim oValue As String = oP.Value.ToString
If oValue <> "" Then
Debug.Print(oP.Name & " ==> " & oValue & vbNewLine)
End If
End If
Catch
End Try
Next
Next
Debug.Print("=======================")
Dim oPV As String = Nothing
Try
oPV = oDoc.PropertySets( _
"{B9600981-DEE8-4547-8D7C-E525B3A1727A}") _
.Item("Member").Value.ToString
Debug.Print(oPV & vbNewLine)
Dim oXML As System.Xml.XmlDocument _
= New System.Xml.XmlDocument
oXML.LoadXml(oPV)
Dim oNode As System.Xml.XmlNode _
= oXMLSelectSingleNode( _
"MemberData/family/internalName")
Debug.Print("Type name = " & oNode.InnerText)
Catch
MsgBox("The property is not there…")
End Try
End Sub
VBA
Sub PropTest()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
On Error Resume Next
Dim oPS As Inventor.PropertySet
For Each oPS In oDoc.PropertySets
Debug.Print ""
Debug.Print "=======> " & oPS.Name
Dim oP As Inventor.Property
For Each oP In oPS
Dim oValue
If VarType(oP.Value) <> vbString Then
oValue = "NO_VALUE"
Else
oValue = oP.Value
Debug.Print oP.Name
Debug.Print oP.Value
End If
Debug.Print ""
Next
Debug.Print ""
Next
Debug.Print "======================="
On Error Resume Next
Dim oPV As String
oPV = oDoc.PropertySets( _
"{B9600981-DEE8-4547-8D7C-E525B3A1727A}") _
.Item("Member").Value
If Err Then
MsgBox "The property is not there…"
Else
Debug.Print oPV & vbCr
‘ if you reference Microsoft XML,
‘ then you can do the following
On Error GoTo 0
Dim oXML As MSXML2.DOMDocument
Set oXML = New DOMDocument
If oXML.loadXML(oPV) Then
Debug.Print "Type name = " & _
oXML.selectSingleNode( _
"MemberData/family/internalName").Text
End If
End If
On Error GoTo 0
<
p style=”line-height: normal;margin: 0cm 0cm 0pt” class=”MsoNormal”>End Sub

Leave a Reply