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: 

API: Copying a SketchBlockDefinition from one part file to another

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mike.ponti
479 Views, 2 Replies

API: Copying a SketchBlockDefinition from one part file to another

hi, Does anybody have any guidance on copying a sketch block defintion from one part file to another? So far as I can see, I will have to go through each property in the source sketch block defintion and create equivalent objects to place in the destination sketch block definition. Any ideas on a more efficient way to handle this would be appreciated! Thanks Mike
2 REPLIES 2
Message 2 of 3
ekinsb
in reply to: mike.ponti

You can use the CopyTo method to copy a sketch block definition from one document to another.  Below is a very basic example that illustrates it.

 

Public Sub CopyBlocks()
    ' Somehow get a reference to the document you want to copy from and the
    ' one you're copying to.
    Dim sourceDoc As PartDocument
    Dim targetDoc As PartDocument
    Set sourceDoc = ThisApplication.Documents.Item(4)
    Set targetDoc = ThisApplication.Documents.Item(5)
    
    ' Get the sketch block definition you want to copy.
    Dim sourceBlockDef As SketchBlockDefinition
    Set sourceBlockDef = sourceDoc.ComponentDefinition.SketchBlockDefinitions.Item(1)
    
    ' Copy the sketch block definition into the other document.
    Call sourceBlockDef.CopyTo(targetDoc)
End Sub

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3
mike.ponti
in reply to: ekinsb

Thanks, not sure how I missed that call in the api file. Smiley Frustrated

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

Post to forums  

Autodesk Design & Make Report