Getting attributed solids / edges from drawing

Getting attributed solids / edges from drawing

NachoShaw
Advisor Advisor
258 Views
1 Reply
Message 1 of 2

Getting attributed solids / edges from drawing

NachoShaw
Advisor
Advisor

Hey

I have created attributes to some geometry edges in my parts and am looking for a way to find them at drawing level.

 

Basically, I need to get the edges with attributes and change the layer to FP_L

 

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
259 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor

Try this code.

Dim drwDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim layer = drwDoc.StylesManager.Layers.Item("hole 10")

For Each sheet As Sheet In drwDoc.Sheets
    For Each view As DrawingView In sheet.DrawingViews
        Dim doc As PartDocument = view.ReferencedDocumentDescriptor.ReferencedDocument
        Dim foundObjects As ObjectCollection = doc.AttributeManager.FindObjects("MyAttributeSet", "MyAttribute")
        For Each obj As Object In foundObjects
            If (TypeOf obj Is Edge) Then
                For Each curve As DrawingCurve In view.DrawingCurves(obj)
                    For Each segment As DrawingCurveSegment In curve.Segments
                        segment.Layer = layer
                    Next
                Next
            End If
        Next
    Next
Next

it will crash if you have any view in any sheet of an assembly. (that could be fixed easy.)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes