Coordinate table on drawing

Coordinate table on drawing

jcoveyou
Explorer Explorer
2,090 Views
4 Replies
Message 1 of 5

Coordinate table on drawing

jcoveyou
Explorer
Explorer

I have created some reference points on a part. I have a need to include a table on the drawing of this part that shows the x,y,z coordinate positions of each of those points relative to the coordinate system origin. I have been trying to figure out a way to extract this information from the part to create source data to place into a table on the drawing. Does anyone know of a way to do this?

0 Likes
2,091 Views
4 Replies
Replies (4)
Message 2 of 5

Ralf_Krieg
Advisor
Advisor

Hello

 

I don't know if your points are CenterMarks in your Drawing. If so, try this (quick and dirty) one:

 

Public Sub CreateCustomCenterMarkTable()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    ' Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    ' Set the column titles
    Dim oTitles(1 To 3) As String
    oTitles(1) = "X"
    oTitles(2) = "Y"
    oTitles(3) = "Z"
    
    ' Set the contents of the custom table (contents are set row-wise)
    Dim oCenterMark As Centermark
    Dim oPoint As Point
    Dim i As Integer
    i = oSheet.Centermarks.Count * 3
    ReDim oContents(1 To i) As String
    i = 1
    
    For Each oCenterMark In oDrawDoc.ActiveSheet.Centermarks
        Set oPoint = oCenterMark.ModelWorkFeature.Point
        oContents(i) = oPoint.X
        i = i + 1
        oContents(i) = oPoint.Y
        i = i + 1
        oContents(i) = oPoint.Z
        i = i + 1
        'Debug.Print oPoint.X & ", " & oPoint.Y & ", " & oPoint.Z
    Next
    
    ' Set the column widths (defaults to the column title width if not specified)
    Dim oColumnWidths(1 To 3) As Double
    oColumnWidths(1) = 2.5
    oColumnWidths(2) = 2.5
    oColumnWidths(3) = 4
      
    ' Create the custom table
    Dim oCustomTable As CustomTable
    Set oCustomTable = oSheet.CustomTables.Add("My Table", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), 3, oSheet.Centermarks.Count, oTitles, oContents, oColumnWidths)

End Sub


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 5

Frodl
Advocate
Advocate

Hi,

 

is it also possible to get the name of each Point (centermark)?

 

Thank you.

0 Likes
Message 4 of 5

Ralf_Krieg
Advisor
Advisor

Hello

 

Now with first column "Name"

 

Public Sub CreateCustomCenterMarkTable()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    ' Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    ' Set the column titles
    Dim oTitles(1 To 4) As String
    oTitles(1) = "Name"
    oTitles(2) = "X (cm)"
    oTitles(3) = "Y (cm)"
    oTitles(4) = "Z (cm)"
    
    
    ' Set the contents of the custom table (contents are set row-wise)
    Dim oCenterMark As Centermark
    Dim oPoint As Point
    Dim i As Integer
    i = oSheet.Centermarks.Count * 4
    ReDim oContents(1 To i) As String
    i = 1
    
    For Each oCenterMark In oDrawDoc.ActiveSheet.Centermarks
        Set oPoint = oCenterMark.ModelWorkFeature.Point
        oContents(i) = oCenterMark.ModelWorkFeature.Name
        i = i + 1
        oContents(i) = Round(oPoint.X, 2)
        i = i + 1
        oContents(i) = Round(oPoint.Y, 2)
        i = i + 1
        oContents(i) = Round(oPoint.Z, 2)
        i = i + 1
        'Debug.Print oPoint.X & ", " & oPoint.Y & ", " & oPoint.Z
    Next
    
    ' Set the column widths (defaults to the column title width if not specified)
    Dim oColumnWidths(1 To 4) As Double
    oColumnWidths(1) = 8
    oColumnWidths(2) = 2.5
    oColumnWidths(3) = 2.5
    oColumnWidths(4) = 2.5
      
    ' Create the custom table
    Dim oCustomTable As CustomTable
    Set oCustomTable = oSheet.CustomTables.Add("My Table", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), 4, oSheet.Centermarks.Count, oTitles, oContents, oColumnWidths)

End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 5 of 5

Anonymous
Not applicable

I tried that code in Inventor 2014, and it states it needs a sub main

0 Likes