- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys,
I'm quite inexperienced with VBA so if any of you can help me get this macro to work will be very much appreciated. I am trying to extract X Y Z of work points in the 3D model and create a General table into a drawing with the info, 1st column to be with the name of the work point, 2nd column empty, the rest are X Y Z. It's highlighting the last row but I don't know how to fix it
Set oCustomTable = oSheet.CustomTables.Add("", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), 5, oSheet.Centermarks.Count, oTitles, oContents, oColumnWidths)
The whole code is this
Public Sub CreateGLOBALtest()
' 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 5) As String
oTitles(1) = "RPS"
oTitles(2) = "Note"
oTitles(3) = "X (mm)"
oTitles(4) = "Y (mm)"
oTitles(5) = "Z (mm)"
' 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 * 5
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 + 2
oContents(i) = Round((oPoint.X * 10), 10)
i = i + 1
oContents(i) = Round((oPoint.Y * 10), 10)
i = i + 1
oContents(i) = Round((oPoint.Z * 10), 10)
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 5) As Double
oColumnWidths(1) = 3
oColumnWidths(2) = 6
oColumnWidths(3) = 2.3
oColumnWidths(4) = 2.3
oColumnWidths(5) = 2.3
' Create the custom table
Dim oCustomTable As CustomTable
Set oCustomTable = oSheet.CustomTables.Add("", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), 5, oSheet.Centermarks.Count, oTitles, oContents, oColumnWidths)
End Sub
Thanks in advance!
Solved! Go to Solution.