API: Copying a Sketch from one part file to another

API: Copying a Sketch from one part file to another

IT-Fundilusa
Explorer Explorer
380 Views
2 Replies
Message 1 of 3

API: Copying a Sketch from one part file to another

IT-Fundilusa
Explorer
Explorer

Hi, 

Does anybody have any guidance on copying a sketch from one part file to another? 

 

Thanks

 

0 Likes
381 Views
2 Replies
Replies (2)
Message 2 of 3

GeorgK
Advisor
Advisor
Sub VBAMain()
   Dim oPart1 As PartDocument
   Set oPart1 = ThisApplication.Documents.Open("c:\part1.ipt", False)
   
   Dim oSketch_inPart1 As Sketch
   Set oSketch_inPart1 = oPart1.ComponentDefinition.Sketches(1)
   
   Dim oPart2 As PartDocument
   Set oPart2 = ThisApplication.Documents.Open("c:\part2.ipt", False)
   
   Dim oSketch_inPart2 As Sketch
   Set oSketch_inPart2 = oPart2.ComponentDefinition.Sketches(1)
   
   Call oSketch_inPart1.CopyContentsTo(oSketch_inPart2)
    
   Call oPart1.Close(True)
   
   oPart2.Update
   oPart2.Save
   Call oPart2.Close(True)
   
End Sub
0 Likes
Message 3 of 3

IT-Fundilusa
Explorer
Explorer

 

Thank you.

 

It worked

0 Likes