Another enhancement in the Inventor 2013 API related to transient geometry allows you to get partial curves from splines. You will find two new methods called ExtractPartial and Split on the BSplineCurve and BSplineCurve2d objects. These new methods make it easier to create new curves based on existing curves. Using ExtractPartial you can extract any portion of the curve as a new transient geometry spline. Using Split will get two transient curves from the original.

**New 2013 methods used to extract a partial curve from a Spline**

- BSplineCurve.ExtractPartial
- BSplineCurve.Split
- BSplineCurve2d.ExtractPartial
- BSplineCurve2d.Split

**VBA Example: **

Keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production.

Note: This example is only using ExtractPartial. (Not Split)

Before running this procedure create a Sketch with a spline. When you run this example it will prompt you to select a “2d spline”. If you select a spline the selected entity will be a SketchSpline and the BSplineCurve2d is returned from the Geometry property of that object.

Remember that these methods are creating transient geometry so it is not affecting the real Inventor geometry. This example uses that transient geometry to create real Inventor geometry (3 splines) using Sketch.SketchFixedSplines.Add(). The code deletes the original spline. After running the procedure notice the three new splines:

**VBA Code:**

' Demonstrates the ability to extract partial

' curves from a transient geometry curve. This

' sample has you select an existing sketch

' spline and extracts three curves from the curve.

' It then creates real curves using the extracted

' curves and deletes the original sketch curve.

Public Sub ExtractPartialCurves2D()

Dim partDoc As PartDocument

Set partDoc = ThisApplication.ActiveDocument

Dim spline As Object

Set spline = ThisApplication.CommandManager _

.Pick(kSketchCurveSplineFilter, "Select 2d spline")

' Get the spline geometry from the entity.

Dim splineCurve As BSplineCurve2d

Set splineCurve = spline.Geometry

' Get the parameter bounds of the curve.

Dim startParam As Double

Dim endParam As Double

Call splineCurve.Evaluator.GetParamExtents _

(startParam, endParam)

' Extract three curves where they are in

' thirds of the original

' relative to the curves parameter space.

Dim curves(2) As BSplineCurve2d

Set curves(0) = splineCurve.ExtractPartial _

(startParam, (startParam + endParam) / 3)

Set curves(1) = splineCurve.ExtractPartial _

((startParam + endParam) / 3, _

((startParam + endParam) / 3) * 2)

Set curves(2) = splineCurve.ExtractPartial _

(((startParam + endParam) / 3) * 2, _

endParam)

' Create new sketch curves using

' the extracted splines.

Dim splineSketch As sketch

Set splineSketch = spline.Parent

Call splineSketch.SketchFixedSplines. _

Add(curves(0))

Call splineSketch.SketchFixedSplines. _

Add(curves(1))

Call splineSketch.SketchFixedSplines. _

Add(curves(2))

' Delete the original curve.

spline.Delete

End Sub

-Wayne