Project Sketch from part to another part in an Assembly

Project Sketch from part to another part in an Assembly

Anonymous
Not applicable
579 Views
2 Replies
Message 1 of 3

Project Sketch from part to another part in an Assembly

Anonymous
Not applicable

I can't seem to find how to use the Inventor 2012 API to project an entire sketch profile from one .ipt to another .ipt file from within an .iam file. Any ideas on how to do this?

 

 

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

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Sketch.CopyContentsTo can do this. 

 

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)
   
   'remember to update!
    oPart2.Update
   oPart2.Save
   Call oPart2.Close(True)
   
End Sub

 

Message 3 of 3

Anonymous
Not applicable

Hi,

 

I'm trying to do the same operation, inside an assembly, but the difference is that I try to copy sketch content from a part to an assembly. Not the "main" assembly, but a sub assembly (occurrence representing an assembly).

 

But nothing get copied with the "CopyContentsTo()" function. The sketch in the assembly is still empty. Works great when copying from a part to a part !

 

Is there any limitation / bug known about that ?

 

Thanks in advance !

0 Likes