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:
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
My guess is that it looses it's constraint points?
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,