Copying a SketchSpline from one sketch to another

By Philippe Leefsma

Q:

How to copy a SketchSpline from one Sketch to another one?

A:

The following VB.Net code snippet illustrates how to do that. Note that for clarity error checking has been omitted.

    Sub TestCopy(ByVal app As Inventor.Application)

 

        Dim doc As PartDocument = app.ActiveDocument

        Dim compDef As PartComponentDefinition = doc.ComponentDefinition

 

        Dim sketchTo As PlanarSketch = compDef.Sketches.Item(2)

        Dim spline As SketchSpline =

            compDef.Sketches.Item(1).SketchSplines.Item(1)

 

        CopySpline(app, sketchTo, spline)

 

    End Sub

 

    Sub CopySpline(ByVal app As Inventor.Application,

                   ByRef sketchTo As PlanarSketch,

               &#16
0;  
ByRef spline As SketchSpline)

 

        Dim col As ObjectCollection = app.TransientObjects.CreateObjectCollection

 

        Dim i As Integer

        For i = 1 To spline.FitPointCount

            col.Add(spline.FitPoint(i).Geometry)

        Next

 

        sketchTo.SketchSplines.Add(col, spline.FitMethod)

 

    End Sub

<

p style=”line-height: normal;margin: 0in 0in 0pt” class=”MsoNormal”> 


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading