' MacroRecorder-compatible VB Script to print out the vertices of all selected objects ' Written Feb. 17, 2010 by Kevan Chapman for IMSI/Design ' Version 1.1.0 - changed to be compatible with Macro Recorder palette. ' Error-checking is minimal -- there may be some objects for which this doesn't work ' The script currently doesn't try to handle compound objects -- only top-level graphics are processed.' ' Usage notes: ' Select the objects to be "dumped" before running the macro. ' option explicit sub Main On Error Resume Next Dim TCSel ' the current selection. If nothing is selected the script will exit Dim TCGrf ' used to cycle through each selected graphic' Dim TCVertices ' gets the list of vertices for each graphic Dim TCVert ' used to cycle through each vertex Dim VertFile ' file used to store the results Dim FilePath ' path to the output file. Normally the same folder as the open drawing. Dim FSO ' FileSystemObject for access to file operations Dim i ' counter for each selected graphic Dim j ' counter for each vertex in each graphic ' get the current selection. If empty, complain and exit. Set TCSel = ActiveDrawing.Selection If TCSel.Count < 1 Then Application.MessageBox "Nothing selected. Nothing to do." Exit Sub End If ' start up the FileSystemObject for access to file operations. Set FSO = CreateObject("Scripting.FileSystemObject") ' determine the path for the output file FilePath = ActiveDrawing.Path(0) If Len(FilePath) = 0 Then 'file hasn't been saved, so it has no path yet. Use the program folder in this case. FilePath = Application.Path(0) & "\" Else Dim endpath ' strip the drawing filename off of the drawing's path, and append the output filename"' endpath = InStrRev(FilePath, "\") FilePath = Left(FilePath, endpath) End If ' open the output file for text operations Set VertFile = FSO.CreateTextFile(FilePath & "verts.txt") VertFile.WriteLine "# Vertices of selected objects" 'process each of the selected objects, and print its vertices to the file For i = 0 to TCSel.Count - 1 Set TCGrf = TCSel.Item(i) Set TCVertices = TCGrf.Vertices TCVertices.UseWorldCS = True ' this allows us to get the World UCS coordinates rather than the graphic's local coordinates For j = 0 to TCVertices.Count - 1 Set TCVert = TCVertices.Item(j) VertFile.WriteLine TCVert.X & ";" & TCVert.Y & ";" & TCVert.Z Next VertFile.WriteBlankLines(1) Next 'Close the output file' VertFile.Close Application.MessageBox "File saved to: " & FilePath & "verts.txt" 'cleanup objects TCVert = Nothing TCVertices = Nothing TCGrf = Nothing TCSel = Nothing End Sub Main