' ****************************************************************************** ' by Jim Sculley, edited by Matt Lombard ' requires a text file with xyz data at the hard coded location below ' ' ****************************************************************************** Dim swApp As Object Dim currentDoc As Object Const fileName = "C:\Users\Toru\Documents\PROXY\ACADEMIC\2008 Summer\pointCloud\testExport.txt" Const swDocPART = 1 Const swDocASSEMBLY = 2 Dim nextLine As String Dim xVal, yVal, zVal, xVal2, yVal2, zVal2 As Double Dim point As Object Sub main() Const errorString = "You must have a part file open to use this feature." Set swApp = CreateObject("SldWorks.Application") Set currentDoc = swApp.ActiveDoc If currentDoc Is Nothing Then swApp.SendMsgToUser (errorString) End End If If (currentDoc.getType = swDocASSEMBLY) Then swApp.SendMsgToUser (errorString) End End If If (currentDoc.getType = swDocPART) Then currentDoc.Insert3DSketch Open fileName For Input As #1 ' Open file. Line Input #1, nextLine 'Read line into variable. nextLine = VBA.Trim(nextLine) Do While Not (nextLine = "-END-") ' Loop until -END- is found. xVal = Val(nextLine) 'convert string to number Line Input #1, nextLine yVal = Val(nextLine) 'convert string to number Line Input #1, nextLine zVal = Val(nextLine) 'convert string to number Line Input #1, nextLine xVal2 = Val(nextLine) 'convert string to number Line Input #1, nextLine yVal2 = Val(nextLine) 'convert string to number Line Input #1, nextLine zVal2 = Val(nextLine) 'convert string to number 'Set point = currentDoc.CreatePoint2(xVal, yVal, zVal) Set point = currentDoc.CreateLine2(xVal, yVal, zVal, xVal2, yVal2, zVal2) Line Input #1, nextLine Loop Close #1 ' Close file. Else 'must be a drawing swApp.SendMsgToUser (errorString) End If End Sub