VBA (IV2018): get all corners of a Part via macro

VBA (IV2018): get all corners of a Part via macro

fullevent
Advisor Advisor
367 Views
1 Reply
Message 1 of 2

VBA (IV2018): get all corners of a Part via macro

fullevent
Advisor
Advisor

Hello,

 

what is the easiest way to read the coordinates from each corner of an ipt?

 

2020-02-19 14_17_52-Window.png

 

Is this even possible or do I have to calculate the coordinates via the sketch elements and extrusions?

Aattached an ipt.

 

I have many such IPTs and they all build up identically.

 

Thanks in advance.

 

Regards,

Aleks

 


Aleksandar Krstic
Produkt- und Projektmanager

0 Likes
Accepted solutions (1)
368 Views
1 Reply
Reply (1)
Message 2 of 2

fullevent
Advisor
Advisor
Accepted solution

I found "Vertices".. didnt know about that property.

 

This works for me:

Private Sub read_all_corner_ipt()
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument
    Dim oCompDef As ComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    Dim oVert As Vertices
    Set oVert = oCompDef.SurfaceBodies.Item(1).Vertices
    sTxt = "x" & vbTab & vbTab & "y" & vbTab & vbTab & "z"
    For Each Item In oVert
        sTxt = sTxt & vbCr & Round(Item.Point.x, 2) & vbTab & vbTab & Round(Item.Point.y, 2) & vbTab & vbTab & Round(Item.Point.z, 2)
    Next
    MsgBox sTxt
End Sub

 

EDIT: Now it works for me

2020-02-19 15_36_47-Window.png

 

 

 


Aleksandar Krstic
Produkt- und Projektmanager

0 Likes