I'm not sure about Excel driven, but I have a copy of a macro that drives point location froms a text file (that you could create from an Excel file if you want). Maybe it will help. Ken
----------------------------------------------------------------------- These will be your X, Y, and Z points respectively. Save this section (including the "-END-") as: C:/temp/pointcloud.txt.
1.25
1.125 .6325
0
1
0
2
3
5
8
3
4
7
3
9
4
2
9
-END-
-----------------------------------------------------------------------
Here's the macro:
' *** ' 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:/temp/pointcloud.txt" Const swDocPART = 1 Const swDocASSEMBLY = 2 Dim nextLine As String Dim xVal, yVal, zVal 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 Set point = currentDoc.CreatePoint2(xVal * 0.0254, yVal *
0.0254, zVal * 0.0254) Line Input #1, nextLine Loop Close #1 ' Close file. Else 'must be a drawing swApp.SendMsgToUser (errorString) End If End Sub