Sketch Copy Not working: Any transform missing?

Sketch Copy Not working: Any transform missing?

Anonymous
Not applicable
614 Views
3 Replies
Message 1 of 4

Sketch Copy Not working: Any transform missing?

Anonymous
Not applicable

In Sheet Metal Environment I wish to extract CUT's profile and create a new body by EXTRUDing that profile. But when I copy sketch contents from old to a new one, they appear somewhere else. Why? Am I not looking at certain transforms. 

 

Here is the code I am trying:

 

        Private Function CreateNewSketch(faceSketch As PlanarSketch) As PlanarSketch
            CreateNewSketch = Nothing
            Dim pl As WorkPlane = GetWorkPlane(faceSketch.PlanarEntity)

            Dim newsketch As PlanarSketch = Nothing
            Try
                newsketch = m_compDef.Sketches.Add(pl)
                faceSketch.CopyContentsTo(newsketch)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            CreateNewSketch = newsketch
        End Function

And here is the result:

 

SketchCopyProblem.png

 

0 Likes
Accepted solutions (1)
615 Views
3 Replies
Replies (3)
Message 2 of 4

Jef_E
Collaborator
Collaborator

My guess is that it looses it's constraint points?



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 3 of 4

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

Not sure why you are using "GetWorkPlane". Because of that the new sketch will be based on a different entity and so its origin point will be different. 

 

If you really need to do that then either move the copied entities based on the origin difference, or you could even set the OriginPoint property of the new skecth so that it will line up with the origin of the original skecth.

 

E.g. this VBA code works fine - just select the original skecth in the UI first:

Sub CopySketch3()
    Dim faceSketch As PlanarSketch
    Set faceSketch = ThisApplication.ActiveDocument.SelectSet(1)

    Dim pl As Object
    Set pl = faceSketch.PlanarEntity

    Dim compDef As PartComponentDefinition
    Set compDef = ThisApplication.ActiveDocument.ComponentDefinition

    Dim newsketch As PlanarSketch
    Set newsketch = compDef.Sketches.Add(pl)
    Call faceSketch.CopyContentsTo(newsketch)
End Sub

Cheers,

 



Adam Nagy
Autodesk Platform Services
Message 4 of 4

Anonymous
Not applicable
Perfect!!! Different Origin must have been the reason. Thanks a lot for precise help.
0 Likes