- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm playing with attributes and I've run into a wall of finding where some of them are located. I think I've found every property in part files that can have an attribute but I know I'm missing some at the assembly level. At the assembly level I cannot figure out how to access attributes attached to the proxy whatever it's actually called that is an extruded surface inside of a part. Unlike what chatgpt thinks, I do not want attributes from the part level.
I have a test assembly and part attached. I know Nifty Attributes is a thing (and it's sweet), but this is a learning experience and a foundation for future things so I can't just rely on that. If I'm missing any other attributes please let me know.
Private Sub LoadAttributes()
Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oCompDef As ComponentDefinition = oDoc.ComponentDefinition
AttributeAdd(oDoc.AttributeSets, "Document")
AttributeAdd(oCompDef.AttributeSets, "Component Definition")
If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
For Each oBody As SurfaceBody In oCompDef.SurfaceBodies
AttributeAdd(oBody.AttributeSets, "Surface Body")
AttributeProcess(oBody, "Surface Body")
Next
For Each oWorkSurface As WorkSurface In oCompDef.worksurfaces
AttributeAdd(oWorkSurface.AttributeSets, "Work Surface")
For Each oBody As SurfaceBody In oWorkSurface.SurfaceBodies
AttributeAdd(oBody.AttributeSets, "Work Surface: Surface Body")
AttributeProcess(oBody, "Work Surface")
Next
Next
ElseIf oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
For Each oCompOccur As ComponentOccurrence In oCompDef.Occurrences
AttributeAdd(oCompOccur.AttributeSets, "Component Occurance")
For Each oBody As SurfaceBody In oCompOccur.SurfaceBodies
AttributeAdd(oBody.AttributeSets, "Surface Body")
AttributeProcess(oBody, "Surface Body")
Next
Next
End If
End Sub
Private Sub AttributeAdd(AttribSets As AttributeSets, Type As String)
If AttribSets Is Nothing OrElse AttribSets.Count = 0 Then Exit Sub
Dim TypeSetNode As TreeNode = TV_Attributes.Nodes.Add(Type)
TypeSetNode.Tag = AttribSets
For Each AttribSet As AttributeSet In AttribSets
Dim AttribSetNode As TreeNode = TypeSetNode.Nodes.Add(AttribSet.Name)
AttribSetNode.Tag = AttribSet
For Each Attrib As Attribute In AttribSet
Dim AttribNode As TreeNode
If Attrib.ValueType = ValueTypeEnum.kByteArrayType Then
AttribNode = AttribSetNode.Nodes.Add(Attrib.Name & " = (Byte Array)")
Else
AttribNode = AttribSetNode.Nodes.Add(Attrib.Name & " = " & If(Attrib.Value.ToString.Length > 31, Attrib.Value.ToString.Substring(0, 30) & "...", Attrib.Value.ToString))
End If
AttribNode.Tag = Attrib
Next
Next
End Sub
Private Sub AttributeProcess(oBody As SurfaceBody, ParentType As String)
For Each oFace As Face In oBody.Faces
AttributeAdd(oFace.AttributeSets, ParentType & ": Face")
Next
For Each oEdge As Edge In oBody.Edges
AttributeAdd(oEdge.AttributeSets, ParentType & ": Edge")
Next
For Each oVertex As Vertex In oBody.Vertices
AttributeAdd(oVertex.AttributeSets, ParentType & ": Vertex")
Next
End Sub
pball's Autodesk Forum Style
Userscript to edit forum links to jump to first unread post
Jump To First Post Userscript
Solved! Go to Solution.