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