Solidworks Macro - Create a Spline

22 minute read

In this post, I tell you about how to create a Spline through Solidworks VBA Macros in a sketch.

This post take some functionality from previous Sketch - Create Create a Point post.

Hence if you have not read Sketch - Create Create a Point post, then it is recommended that please read it 1st.


Video of Code on YouTube

Please see below video how visually we can create a Spline from Solidworks VBA macro.

Please note that there are no explaination given in the video.

Explaination of each line and why we write code this way is explained here.


For Experience Macro Developer

If you are an experience Solidworks Macro developer, then you are looking for a specific code sample.

Below is the code for creating A Spline from Solidworks VBA Macro.

' Creating variable for Solidworks Sketch Segment
Dim swSketchSegment As SldWorks.SketchSegment
      
' Set the value of Solidworks Sketch segment by "CreateSpline2" method from Solidworks sketch manager
Set swSketchSegment = swSketchManager.CreateSpline2((pointArray), True)

For creating a Spline first you need to Create a variable of SketchSegment type.

After creating variable, you need to set the value of this variable.

For this you used CreateSpline2 method from Solidworks Sketch Manager.

This CreateSpline2 method set the value of SketchSegment type variable.

This CreateSpline2 method takes following parameters as explained:

  • PointData : Array of X,Y,Z point coordinates to use in creating the spline.

  • SimulateNaturalEnds : True to simulate natural ends, false to not simulate natural ends.

If you want a more detail explaination then please read further otherwise this will help you to Create a Spline From VBA Macro.


For Beginners Macro Developers

In this post, I tell you about CreateSpline2 method from Solidworks SketchManager object.

By this method we create a simple Spline from a sequence of points.

This method is most updated method, I found in Solidworks API Help.

So use this method if you want to create a new Spline.

Below is the code sample for creating a Spline.

Please don’t get distracted by length of code, I just want to do everything programatically. So that you have some sort of experience in developing logic.

Option Explicit

' Creating variable for Solidworks application
Dim swApp As SldWorks.SldWorks

' Creating variable for Solidworks document
Dim swDoc As SldWorks.ModelDoc2

' Boolean Variable
Dim BoolStatus As Boolean

' Creating variable for Solidworks Sketch Manager
Dim swSketchManager As SldWorks.SketchManager

' Creating variable for Solidworks Sketch
Dim swSketch As SldWorks.Sketch

' Creating variable for Solidworks Sketch Point
Dim swSketchPoint As SldWorks.SketchPoint

' Creating variable for Solidworks Sketch Segment
Dim swSketchSegment As SldWorks.SketchSegment

' Main function of our VBA program
Sub main()

  ' Set Solidworks application variable to Solidworks application
  Set swApp = Application.SldWorks
  
  ' Creating string type variable for storing default part location
  Dim defaultTemplate As String
  
  ' Set value of this string type variable to "Default part template"
  defaultTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplatePart)

  ' Set Solidworks document to new part document
  Set swDoc = swApp.NewDocument(defaultTemplate, 0, 0, 0)

  ' Select Front Plane
  BoolStatus = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)
  
  ' Set Sketch manager for our sketch
  Set swSketchManager = swDoc.SketchManager
  
  ' Insert a sketch into selected plane
  swSketchManager.InsertSketch True
  
  ' Create integer type local variable
  Dim i As Integer
  
  ' Loop through 0 to 10
  For i = 0 To 10
    
    ' Create integer type variables
    Dim x, y, z, incrementFactor As Integer
    
    ' Set value of incrementFactor
    incrementFactor = i * 0.5
    
    ' Set value of x co-ordinate
    x = i
    ' Set value of y co-ordinate
    y = x + incrementFactor
    ' Set value of z co-ordinate
    z = 0

    ' Create a Sketch Point using x, y & z variables
    Set swSketchPoint = swSketchManager.CreatePoint(x, y, z)

  Next i
  
  ' De-select the points after creation
  swDoc.ClearSelection2 True
  
  ' Set Solidworks Sketch variable to active sketch
  Set swSketch = swSketchManager.ActiveSketch
  
  ' Create variant type variable named "sketchPointArray"
  Dim sketchPointArray As Variant
  
  ' Get all the points in this active sketch and store them into our variant type variable
  sketchPointArray = swSketch.GetSketchPoints2()
  
  ' Creating a new Collection,
  ' we use this collecction to store x,y,z co-ordinates of all sketch points
  Dim pointCollection As New Collection
  
  ' Loop through all points in "sketchPointArray"
  For i = 0 To UBound(sketchPointArray)
    ' Set Solidworks sketch point variable to current point
    Set swSketchPoint = sketchPointArray(i)
    
    ' Add X co-ordinate of current point into collection
    pointCollection.Add (swSketchPoint.x)
    
    ' Add Y co-ordinate of current point into collection
    pointCollection.Add (swSketchPoint.y)
    
    ' Add Z co-ordinate of current point into collection
    pointCollection.Add (swSketchPoint.z)
  Next i
  
  ' Create an array variable, this is Double type variable
  Dim point() As Double
  
  ' Define the size of array Dynamically
  ReDim point(0 To pointCollection.Count) As Double
  
  ' Loop through the collection we have
  For i = 0 To (pointCollection.Count - 1)
    ' Add each item of collection into our array variable
    point(i) = pointCollection(i + 1)
  Next i
  
  ' Create a local variable name "pointArray" of variant type
  Dim pointArray As Variant
  
  ' Set the new created variable equal to point array variable
  pointArray = point
  
  ' Exit the sketch
  swSketchManager.InsertSketch True
  
  ' De-select the sketch
  swDoc.ClearSelection2 True
  
  ' Select Front Plane
  BoolStatus = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)
  
  ' Insert a sketch into "Front Plane"
  swSketchManager.InsertSketch True
  
  ' Set the value of Solidworks Sketch segment by "CreateSpline2" method from Solidworks sketch manager
  Set swSketchSegment = swSketchManager.CreateSpline2((pointArray), True)

  ' De-select the Spline after creation
  swDoc.ClearSelection2 True
  
  ' Zoom to fit screen in Solidworks Window
  swDoc.ViewZoomtofit2

  ' Exit the sketch
  swSketchManager.InsertSketch True

  ' Force Re-build the model
  swDoc.Rebuild (swRebuildOptions_e.swForceRebuildAll)

End Sub

Understanding the Code

Now let us walk through each line in the above code, and understand the meaning of every line.

Option Explicit

This line forces us to define every variable we are going to use.

For more information please visit Solidworks Macros - Open new Part document post.

' Creating variable for Solidworks application
Dim swApp As SldWorks.SldWorks

In this line, we are creating a variable which we named as swApp and the type of this swApp variable is SldWorks.SldWorks.

' Creating variable for Solidworks document
Dim swDoc As SldWorks.ModelDoc2

In this line, we are creating a variable which we named as swDoc and the type of this swDoc variable is SldWorks.ModelDoc2.

' Boolean Variable
Dim BoolStatus As Boolean

In this line, we create a variable named BoolStatus as Boolean object type.

' Creating variable for Solidworks Sketch Manager
Dim swSketchManager As SldWorks.SketchManager

In above line, we create variable swSketchManager for Solidworks Sketch Manager.

As the name suggested, a Sketch Manager holds variours methods and properties to manage Sketches.

To see methods and properties related to SketchManager object, please visit this page of Solidworks API Help

' Creating variable for Solidworks Sketch
Dim swSketch As SldWorks.Sketch

In this line, we are creating a variable which we named as swSketch and the type of this swSketch variable is SldWorks.Sketch.

We create variable swSketch for Solidworks Sketches.

To see methods and properties related to Sketch object, please visit this page of Solidworks API Help

' Creating variable for Solidworks Sketch Point
Dim swSketchPoint As SldWorks.SketchPoint

In this line, we are creating a variable which we named as swSketchPoint and the type of this swSketchPoint variable is SldWorks.SketchPoint.

We create variable swSketchPoint for Solidworks Sketch Points.

To see methods and properties related to SketchPoint object, please visit this page of Solidworks API Help

' Creating variable for Solidworks Sketch Segment
Dim swSketchSegment As SldWorks.SketchSegment

In this line, we are creating a variable which we named as swSketchSegment and the type of this swSketchSegment variable is SldWorks.SketchSegment.

We create variable swSketchSegment for Solidworks Sketch Segments.

To see methods and properties related to swSketchSegment object, please visit this page of Solidworks API Help

These all are our global variables.

As you can see in code sample, they are Solidworks API Objects.

So basically I group all the Solidworks API Objects in one place.

I have also place boolean type object at top also, because after certain point we will need this variable frequently.

Thus, I have started placing it here.

Next is our Sub procedure named as main. This procedure hold all the statements (instructions) we give to computer.

' Setting Solidworks variable to Solidworks application
Set swApp = Application.SldWorks

In this line, we are setting the value of our Solidworks variable swApp which we defined earlier to Solidworks application.

' Creating string type variable for storing default part location
Dim defaultTemplate As String

' Setting value of this string type variable to "Default part template"
defaultTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplatePart)

In 1st statement of above example, we are defining a variable of string type and named it as defaultTemplate.

This variable defaultTemplate, holds the location the location of Default Part Template.

In 2nd line of above example. we assign value to our newly define defaultTemplate variable.

We assign the value by using a Method named GetUserPreferenceStringValue().

This method is a part of our main Solidworks variable swApp.

' Setting Solidworks document to new part document
Set swDoc = swApp.NewDocument(defaultTemplate, 0, 0, 0)

In this line, we set the value of our swDoc variable to new document.

For more detailed information about above lines please visit Solidworks Macros - Open new Part document post.

I have discussed them thoroghly in Solidworks Macros - Open new Part document post, so do checkout this post if you don’t understand above code.

' Selecting Front Plane
BoolStatus = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)

In above line, we select the front plane by using SelectByID2 method from Extension object.

For more information about selection method please visit Solidworks Macros - Selection Methods post.

I have discussed about different Selection methods in details in Soldworks Macros - Selection Methods post, so do visit this post for more Selection methods.

' Setting Sketch manager for our sketch
Set swSketchManager = swDoc.SketchManager

In above line, we set the Solidworks Sketch manager variable to current document’s sketch manager.

' Inserting a sketch into selected plane
swSketchManager.InsertSketch True

In above line, we use InsertSketch method of SketchManager and give True value.

This method allows us to insert/exit a sketch in selected plane.

Now I have created a sequence of Points for our Spline.

Because if you already have co-ordinates of points in your machine somewhere you can use the approach I shown here to create a Spline.

TIP: I like to save co-ordinates in MS Excel file and then use it.


Creating sequence of Points

Below code shows how to create Sequence of Points.

' Create integer type local variable
Dim i As Integer

' Loop through 0 to 10
For i = 0 To 10
  
  ' Create integer type variables
  Dim x, y, z, incrementFactor As Integer
  
  ' Set value of incrementFactor
  incrementFactor = i * 0.5
  
  ' Set value of x co-ordinate
  x = i
  ' Set value of y co-ordinate
  y = x + incrementFactor
  ' Set value of z co-ordinate
  z = 0

  ' Create a Sketch Point using x, y & z variables
  Set swSketchPoint = swSketchManager.CreatePoint(x, y, z)

Next i

' De-select the points after creation
swDoc.ClearSelection2 True

Let us understand each line of code and how above Lines of code creates a number of points.

' Create integer type local variable
Dim i As Integer

In above line, we create a local variable named i of integer type.

' Looping through 1 to 10
For i = 0 To 10
  
Next

In above lines, we create a For loop.

This loop iterate the value of i variable from 0 -> 10.

I use max value of 10, because I want to create 10 points.

' Create integer type variables
Dim x, y, z, incrementFactor As Integer

' Set value of incrementFactor
incrementFactor = i * 0.5

' Setting values of x, y and z
x = i
y = x + incrementFactor
z = 0

In above lines, we 1st declare 4 variable x, y, z and incrementFactor of integer type.

x, y and z are co-ordinates of a single point in X, Y and Z direction.

incrementFactor is the factor by which I want to increase the value of Y co-ordinate of a single point.

' Set value of incrementFactor
incrementFactor = i * 0.5

In above line, I set the value of incrementFactor.

This value is 0.5 times of value of i variable.

Example: i = 3 then incrementFactor = 3 * 0.5 => incrementFactor = 1.5

In next 3 lines, we set the values of x, y and z.

For all points, we set the value of z to 0 because we want to place our points in X-Y plane.

If the value of i = 0, then we set the value of x equal to i.

This makes x = 0 also.

Now, we set the value of y which is equal to SUM of x and incrementFactor.

Hence for i = 0, x = 0, y = 0 and incrementFactor = 0.

For i = 1, x = 1, y = 1.5 and incrementFactor = 0.5.

' Create a Sketch Point using x, y & z variables
Set swSketchPoint = swSketchManager.CreatePoint(x, y, z)

In above line, we create a Point using CreatePoint function of swSketchManager variable with the values of x, y and z.

' De-select the Points after creation
swDoc.ClearSelection2 True

In the this line of code, we de-select the created Points.

For de-selecting, we use ClearSelection2 method from our Solidworks document variable swDoc.


Create a Collection of Points Co-ordinates

After creating points, I want to do following things:

  1. Get all points in this sketch

  2. Add co-ordinates of each point into a collection

Why I want to do this when I already know co-ordinates of all points in previous section?

It is because I create points from this macro hence I know their co-ordinates.

I can add them to collection there BUT I want to take this opportunity to show following things:

  • How you get points of an Sketch.

  • How to create a Collection and Add values in it.

Below code shows how to do all those things.

' Set Solidworks Sketch variable to active sketch
Set swSketch = swSketchManager.ActiveSketch

' Create variant type variable named "sketchPointArray"
Dim sketchPointArray As Variant

' Get all the points in this active sketch and store them into our variant type variable
sketchPointArray = swSketch.GetSketchPoints2()

' Creating a new Collection,
' we use this collecction to store x,y,z co-ordinates of all sketch points
Dim pointCollection As New Collection

' Loop through all points in "sketchPointArray"
For i = 0 To UBound(sketchPointArray)
  ' Set Solidworks sketch point variable to current point
  Set swSketchPoint = sketchPointArray(i)
  
  ' Add X co-ordinate of current point into collection
  pointCollection.Add (swSketchPoint.x)
  
  ' Add Y co-ordinate of current point into collection
  pointCollection.Add (swSketchPoint.y)
  
  ' Add Z co-ordinate of current point into collection
  pointCollection.Add (swSketchPoint.z)
Next i

Let us understand each line of code.

' Set Solidworks Sketch variable to active sketch
Set swSketch = swSketchManager.ActiveSketch

In the above line, I set the value of Solidworks Sketch variable swSketch to active sketch.

For this we use ActiveSketch method of Solidworks Sketch Manager variable swSketchManager.

This method give us a SldWorks.Sketch type return value which we store into swSketch variable.

' Create variant type variable named "sketchPointArray"
Dim sketchPointArray As Variant

' Get all the points in this active sketch and store them into our variant type variable
sketchPointArray = swSketch.GetSketchPoints2()

In 1st line of above code, I create a variable sketchPointArray.

This variable is Variant type variable.

In 2nd line of above code, I set the value of variable sketchPointArray using GetSketchPoints2() method.

We use GetSketchPoints2() method from our Solidworks Sketch type variable swSketch.

GetSketchPoints2() method gives us all points in this sketch and we store those points into sketchPointArray variable.

' Creating a new Collection,
' we use this collecction to store x,y,z co-ordinates of all sketch points
Dim pointCollection As New Collection

In the above line, I create variable pointCollection of Collection type.

' Loop through all points in "sketchPointArray"
For i = 0 To UBound(sketchPointArray)

Next i

In above lines, we create a For loop.

This loop iterate the value of i variable from 0 -> UBound(sketchPointArray).

I use max value of UBound(sketchPointArray), because I want to iterate through Maximum number of points we get from the GetSketchPoints2() method.

If number of points are other than 10, then UBound(sketchPointArray) method return only that number of points.

Hence it is useful to know for future use.

' Set Solidworks sketch point variable to current point
Set swSketchPoint = sketchPointArray(i)

Now inside, this loop in 1st line we set Solidworks sketch point variable to current point of sketchPointArray.

' Add X co-ordinate of current point into collection
pointCollection.Add (swSketchPoint.x)

' Add Y co-ordinate of current point into collection
pointCollection.Add (swSketchPoint.y)

' Add Z co-ordinate of current point into collection
pointCollection.Add (swSketchPoint.z)

In above 3 lines, we add X, Y and Z co-ordinates of current point into our collection.

Preparing Co-ordinates of Points

You know from For Experience Macro Developers section, we need an Array of PointData.

This array contains X, Y and Z co-ordinates for Spline Points.

Now I tried to add X, Y and Z co-ordinates directly into an Array and then use this array to create Spline.

But it did not work, hence I had to store all X, Y and Z co-ordinates 1st into Collection.

Now I have all co-ordinates in my Collection and I have to create an Array for Spline from this Collection.

Below code sample show how to prepare Co-ordinate points for Spline.

' Create an array variable, this is Double type variable
Dim point() As Double

' Define the size of array Dynamically
ReDim point(0 To pointCollection.Count) As Double

' Loop through the collection we have
For i = 0 To (pointCollection.Count - 1)
  ' Add each item of collection into our array variable
  point(i) = pointCollection(i + 1)
Next i

' Create a local variable name "pointArray" of variant type
Dim pointArray As Variant

' Set the new created variable equal to point array variable
pointArray = point

' Exit the sketch
swSketchManager.InsertSketch True

' De-select the sketch
swDoc.ClearSelection2 True

Let us understand each line of above code sample.

' Create an array variable, this is Double type variable
Dim point() As Double

' Define the size of array Dynamically
ReDim point(0 To pointCollection.Count) As Double

In above code, 1st line creates an Array variable. This is double type variable.

If you don’t know what an array is, then please visit VBA Arrays post.

In 2nd line, we define the size of array. This size is dynamic means it automatic in nature.

We don’t have to give exact value every time, this code adjust the values if there is any change in our Collection.

This size of this array is from 0 to Number of Co-ordinates in the collection.

In our case size of array is 0 -> 30.

' Loop through the collection we have
For i = 0 To (pointCollection.Count - 1)
  ' Add each item of collection into our array variable
  point(i) = pointCollection(i + 1)
Next i

In above code we 1st create a Loop.

This Loop iterate from 0 to pointCollection.Count - 1.

Why pointCollection.Count - 1 ? It is because pointCollection.Count starts from 1 and our loop start with 0.

Because of additional 1 count in pointCollection, we need to remove 1 from the count.

Inside this loop, we add every item of pointCollection into our point() array.

' Create a local variable name "pointArray" of variant type
Dim pointArray As Variant

' Set the new created variable equal to point array variable
pointArray = point

In 1st line of above code, we create local variable “pointArray”. This variable is Variant type.

In 2nd line of above code, we set the value of variable “pointArray” to value of variable “point”.

' Exit the sketch
swSketchManager.InsertSketch True

' De-select the sketch
swDoc.ClearSelection2 True

In 1st line of above code, we Exit the sketch.

In 2nd line of above code, we De-select the sketch.

Create Spline

Now we have all information available for creating a Spline.

Below code sample shows how to create a Spline.

' Select Front Plane
BoolStatus = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)

' Insert a sketch into "Front Plane"
swSketchManager.InsertSketch True

' Set the value of Solidworks Sketch segment by "CreateSpline2" method from Solidworks sketch manager
Set swSketchSegment = swSketchManager.CreateSpline2((pointArray), True)

' De-select the Spline after creation
swDoc.ClearSelection2 True

' Zoom to fit screen in Solidworks Window
swDoc.ViewZoomtofit2

' Exit the sketch
swSketchManager.InsertSketch True

' Force Re-build the model
swDoc.Rebuild (swRebuildOptions_e.swForceRebuildAll)

Let us understand each line of above code sample.

' Selecting Front Plane
BoolStatus = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, swSelectOption_e.swSelectOptionDefault)

In above line, we select the front plane by using SelectByID2 method from Extension object.

For more information about selection method please visit Solidworks Macros - Selection Methods post.

I have discussed about different Selection methods in details in Soldworks Macros - Selection Methods post, so do visit this post for more Selection methods.

' Inserting a sketch into selected plane
swSketchManager.InsertSketch True

In above line, we use InsertSketch method of SketchManager and give True value.

This method allows us to insert/exit a sketch in selected plane.

' Set the value of Solidworks Sketch segment by "CreateSpline2" method from Solidworks sketch manager
Set swSketchSegment = swSketchManager.CreateSpline2((pointArray), True)

In above line we set the value of Solidworks Sketch segment variable swSketchSegment.

For this we use, CreateSpline2 method from Solidworks sketch manager variable swSketchManager.

This CreateSpline2 method takes following parameters as explained:

PointData : Array of X,Y,Z point coordinates to use in creating the spline.

SimulateNaturalEnds : True to simulate natural ends, false to not simulate natural ends.

Below Image described the Parameters for a Spline.

spline_parameters

In this CreateSpline2 method, we pass our pointArray variable as PointData.

We want our spline to simulate natural ends. Hence we True as second parameter.


NOTE

It is very important to remember that, when you give distance or any other numeric value in Solidworks API, Solidworks takes that numeric value in Meter only.

Solidworks API does not care about your application’s Unit systems.

For example, I works in ANSI system means “inches” for distance.

But when I used Solidworks API through VBA macros or C#, I have to use converted numeric values.

Because Solidworks API output the distance in Meter only; which is not my requirement.

' De-select the Spline after creation
swDoc.ClearSelection2 True

In above line, we de-select the created Spline.

For de-selecting, we use ClearSelection2 method from our Solidworks document variable swDoc.

' Zoom to fit screen in Solidworks Window
swDoc.ViewZoomtofit

In above line we use zoom to fit command.

For Zoom to fit, we use ViewZoomtofit method from our Solidworks document variable swDoc.

' Exit the sketch
swSketchManager.InsertSketch True

In above line, we exit the sketch.

' Force Re-build the model
swDoc.Rebuild (swRebuildOptions_e.swForceRebuildAll)

In above line, we Force Re-build the model the model.

For “Force Re-build” we use Rebuild method from Solidworks Document variable swDoc.

In this Rebuild method, we use swRebuildOptions_e.swForceRebuildAll option for re-build all.

This is it !!!

It is a BIG post but I tried to explain all.

If you found anything to add or update, please let me know on my e-mail.


VBA Language feature used in this post

In this post used some features of VBA programming language.

This section of post, has some brief information about the VBA programming language specific features.

  1. We use Option Explicit for capturing un-declared variables. If you want to read more about Option Explicit then please visit Declaring and Scoping of Variables.

  2. Then we create variable for different data types. If you don’t know about them, then please visit Variables and Data-types posts of this blog. These posts will help you to understand what Variables are and how to use them.

  3. Then we create main Sub procedure for our macro. If you don’t know about the Sub procedure, then I suggest you to visit VBA Sub and Function Procedures and Executing Sub and Function Procedures posts of this blog. These posts will help you to understand what Procedures are and how to use them.

  4. In most part we create some variables and set their values. We set those values by using some functions provided from objects. If you don’t know about the functions, then you should visit VBA Functions and VBA Functions that do more posts of this blog. These posts will help you to understand what functions are and how to use them.

  5. For creating a sequence of points and data for Spline, we use a For-Next loop. We use a loop to set values of x, y and z co-ordinates of each points. If you don’t know about the For-Next loop, then you should visit VBA Looping post of this blog. This posts will help you to understand what For-Next loop are and how to use them.

  6. For storing co-ordinates of points we use Collection. In an Collection, we store objects or data. This is very helpful and important language feature. If you don’t know about the Collection, then you should visit Collections (Visual Basic) from Microsoft Official Document Website. This will help you to understand what Collection are and how to use them.

  7. For creating Spline we use an Array. An Array is similar to Collection, in which we store objects or data. But Array is more basic version actually Array is a basic programming feature and used frequently C and C++ programming languages. This is also very helpful and important language feature. If you don’t know about the Array, then you should visit Arrays in Visual Basic from Microsoft Official Document Website. This will help you to understand what Array are and how to use them.


Solidworks API Objects

In this post, for creating a Point, we use Solidworks API objects and their methods.

This section contains the list of all Solidworks Objects used in this post.

I have also attached links of these Solidworks API Objects in API Help website.

If you want to explore those objects, you can use these links.

These Solidworks API Objects are listed below:

  • Solidworks Application Object

If you want explore Properties and Methods/Functions of Solidworks Application Object object you can visit this link.

  • Solidworks Document Object

If you want explore Properties and Methods/Functions of Solidworks Document Object object you can visit this link.

  • Solidworks Sketch Manager Object

If you want explore Properties and Methods/Functions of Solidworks Sketch Manager Object you can visit this link.

  • Solidworks Sketches Object

If you want explore Properties and Methods/Functions of Solidworks Sketches Object you can visit this link.

  • Solidworks Sketch Point Object

If you want explore Properties and Methods/Functions of Solidworks Sketch Point Object you can visit this link.

  • Solidworks Sketch Segment Object

If you want explore Properties and Methods/Functions of Solidworks Sketch Segment Object you can visit this link.


Hope this post helps you to create a Spline in Sketches with Solidworks VB Macros.

For more such tutorials on Solidworks VBA Macros, do come to this blog after sometime.

Till then, Happy learning!!!

Updated: