Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sketch Copy Not working: Any transform missing?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
472 Views, 3 Replies

Sketch Copy Not working: Any transform missing?

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

 

Tags (1)
3 REPLIES 3
Message 2 of 4
Jef_E
in reply to: Anonymous

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
Message 3 of 4
adam.nagy
in reply to: Anonymous

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
in reply to: adam.nagy

Perfect!!! Different Origin must have been the reason. Thanks a lot for precise help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report