# How to have Excel driven 3D sketch points?

• posted

Hi All,

I would like to use SWX to demo the results of an Excel calculation. How do I tie the cell value of the spreadsheet to the coordinates of

3D sketch points? If it works out, then the points will constrain a sketched circle through them. I am hoping to see the circle rotate in 3D in SWX.

It is times like this, I realize how limited the help file is.

Thank you all,

Stephen

• posted

Why don't you use animator or equations to rotate the circle in an assembly. Sorry I don't know much about tying the cells to SW points thought.

• posted

Stephen,

Easy enought to do. Start here, should get you rolling.

• posted

Thanks for the pointer. I am glad to know it is possible. I now have a rough idea of what I need to do, but I am having trouble figuring out what I should use to represent the X, Y, Z coordinates in the equation editor. I know the points are refered to as Point1@PtsOnDish and so on, but what does swx call the coordinates of the points? Are these info covered somewhere?

Stephen

• posted

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

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.