How to Get Spline Coordinates?
How to Get Spline Coordinates?
(OP)
I have multiple complex splines that I have joined together using a fit spline. I need to get the xyz coordinates of that fit spline in 0.5 meter increments to a text file. The fit spline is 2000 meters long. I tried using reference points which I converted into a 3d sketch and exported using a macro but I can only place 100 reference points at a time which is very time consuming. Anyone have any ideas? Thanks.






RE: How to Get Spline Coordinates?
RE: How to Get Spline Coordinates?
Link
Video
Chris, CSWA
SolidWorks 14
ctopher's home
SolidWorks Legion
RE: How to Get Spline Coordinates?
RE: How to Get Spline Coordinates?
Link
I have not done this for several years.
Chris, CSWA
SolidWorks 14
ctopher's home
SolidWorks Legion
RE: How to Get Spline Coordinates?
RE: How to Get Spline Coordinates?
There is no error handling, and it should be possible to extend the macro to create the point and delete it afterward. See http://help.solidworks.com/2012/English/api/sldworksapi/insert_reference_points_example_vb.htm
Eric
CODE
'------------------------------------------------ ' ' Preconditions: ' (1) Part, or assembly is open. ' (2) Reference point defined by distance feature is selected. ' ' Postconditions: ' swModel.GetPathName.txt is created with xyz locations of point. ' Reference point likely moved. '----------------------------------------------- Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSelMgr As SldWorks.SelectionMgr Dim swFeat As SldWorks.Feature Dim swRefPt As SldWorks.RefPoint Dim swRefPtData As SldWorks.RefPointFeatureData Dim swMathPt As SldWorks.MathPoint Dim i As Integer Dim fileSystem As Variant Dim textFile As Variant Dim nPoints As Integer Dim stepSize As Double nPoints = 10 stepSize = 0.0254 Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set swFeat = swSelMgr.GetSelectedObject5(1) Set swRefPt = swFeat.GetSpecificFeature2 Set swRefPtData = swFeat.GetDefinition Set swMathPt = swRefPt.GetRefPoint Set fileSystem = CreateObject("Scripting.FileSystemObject") Set textFile = fileSystem.CreateTextFile(swModel.GetPathName & ".txt", True) For i = 0 To nPoints - 1 swRefPtData.Distance = stepSize * i swRefPt.ModifyDefinition swRefPtData, swModel, Nothing Set swMathPt = swRefPt.GetRefPoint textFile.writeline Format(swMathPt.ArrayData(0)) & "," & _ Format(swMathPt.ArrayData(1)) & "," & _ Format(swMathPt.ArrayData(2)) Next textFile.Close End Sub '-----------------------------------------------------RE: How to Get Spline Coordinates?