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: 

Code to create Virtual part

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

Code to create Virtual part

Good morning!

Can someone give me an idea or code example of how in .iam create a virtual part and save it separately in specific folder?

Any help is appreciated.

 

Thank you.

3 REPLIES 3
Message 2 of 4
alewer
in reply to: Anonymous

This will create a virtual component:

Public Sub AddVirtual()
  Dim oAssemblyDoc As Inventor.AssemblyDocument
  Set oAssemblyDoc = ThisApplication.ActiveDocument
  
  Dim oCompDef As Inventor.ComponentDefinition
  Set oCompDef = oAssemblyDoc.ComponentDefinition
  
  Dim oPosition As Inventor.Matrix
  Set oPosition = ThisApplication.TransientGeometry.CreateMatrix()
  
  Dim oVirtual As ComponentOccurrence
  Set oVirtual = oAssemblyDoc.ComponentDefinition.Occurrences.AddVirtual("TEST", oPosition)
End Sub

 Can you elaborate on your save requirement? Virtual parts can't be saved. Or do you wish to save the assembly?

 

Message 3 of 4
Anonymous
in reply to: alewer

What we have is the switch drawing with iLogic code, that changes the parameters and description only, model stays intact. Then we save it as new #.idw. Now we have to place switch model in the main assembly model. Thats why I was thinking to add a code to an existing drawing  to create a virtual part and save it.

I guess I can modify master switch model and save it as new part # instead virtual part.

Thank you.

Message 4 of 4
ekinsb
in reply to: Anonymous

The previous answer is correct.  Virtual parts only exist in the context of an assembly and are intended to represent items that aren't shown graphically but you still want them listed in the BOM.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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

Post to forums  

Autodesk Design & Make Report