Curve passing through XYZ points

Hello

I created a macro that allows me to create a curve passing through XYZ points retrieved from a txt file, in solidworks,

But I can't edit this function to change the shape of my curve with other points.

How should I do it? because I don't want to recreate a new curve every time, I want to start from the existing one.

 

Thank you in advance for your answers.

Could you post your macro? And locate us where do you block?

1 Like

Well in the macro I created I don't block anywhere in fact,

Just the one I created only allows me to create my curve and it works very well.

But it was simply a way to properly take control of how to make macros.

What I want to do is from my already created curve function, I would like my macro to edit my XYZ curve function and retrieve new points to change the shape of my curve.

In the end, I simply can't find the language that is suitable for editing a function.

 

Hello

 

Maybe a solution here, you have to use:

FreePointCurveFeatureData::P ointArray property to edit the definition of XYZ-curve. Refer the API Help for additional information how the feature data should be modified.

 

https://forum.solidworks.com/thread/59437

 

Hi ha.ta.ca

See this tutorial

to create curves via X.Y.Z points

http://www.lynkoa.com/tutos/3d/video-tutorial-creating-curves-importing-point-data-text-file-solidworks

@+ ;-))

Hello

To answer ".PL": 

I can't integrate your "words" into my macro, "FreePointcurveFeatureData:: PointArray".

 

To answer "gt22":

I have already created a macro that creates a XYZ curve FUNCTION, attached,

 

Otherwise I tried to create a macro that creates a curve VIA a sketch but it doesn't work :(,

(I wanted to create a curve via a sketch because it's easier to edit later"

 

macro FUNCTION curve: (works)

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim skiP As Object
Dim myRefPlane As Object
Dim skSegment As Object


Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

Open "Folder Path\TC.txt" For Input As #1

Part.InsertCurveFileBegin
                                                                    
Do While Not EOF(1)
Input #1, X, Y, Z
boolstatus = Part.InsertCurveFilePoint(X / 1000, Y / 1000, Z / 1000)
Loop
Close #1

boolstatus = Part.InsertCurveFileEnd()   
                                                    
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, True, False, "spline stem") 'NAME SPLINE 'spline stem'

End Sub

 

macro SKETCH curve :(not working) Help!

Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim skSegment As Object
Dim pointArray As Variant
Dim points() As Object

Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

Open "Folder Path\TC2.txt" For Input As #1

boolstatus = Part.Extension.SelectByID2("Face Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
ReDim points(0 To 2) As Object

Do While Not EOF(1)
Input #1, X, Y, Z
points(0) = X / 1000
points(1) = Y / 1000
points(2) = Z / 1000
Loop
Close #1
Set skSegment = Part.SketchManager.CreateSpline((pointArray))


Part.SketchManager.InsertSketch True

End Sub

Hello

 

There was an error in the syntax of the function I gave, it is  :

IFreePointCurveFeatureData

And the link that gives its attributes:

http://help.solidworks.com/2013/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IFreePointCurveFeatureData_members.html

 

Hello

Impossible to integrate the words "Ifreepointcurvefeaturedata",

So I try to use the words "feateditdef" it seems pretty good to me but I can't get the dialog window to close  on my own afterwards. So not yet very conclusive.