Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi Rikard,

 

Please find the following sample code to copy 2 part bodies to another part.

 

    Dim oAssemblyDoc As AssemblyDocument = ThisApplication.ActiveDocument

    Dim oAssemblyDef As AssemblyComponentDefinition = oAssemblyDoc.ComponentDefinition

    Dim oOccurrence1 As ComponentOccurrence = Component.InventorComponent("CopyObject2_1")
Dim oPartDef1 As PartComponentDefinition = oOccurrence1.Definition Dim oOccurrence2 As ComponentOccurrence = Component.InventorComponent("CopyObject1") Dim oPartDef2 As PartComponentDefinition = oOccurrence2.Definition Dim oOccurrence3 As ComponentOccurrence = Component.InventorComponent("CopyObject2_2") Dim oPartDef3 As PartComponentDefinition = oOccurrence3.Definition Dim oSourceBody As SurfaceBody = oPartDef1.Worksurfaces.Item(1).Surfacebodies(1) Dim oSourceBody1 As SurfaceBody = oPartDef3.Worksurfaces.Item(1).Surfacebodies(1) Dim oMatrix1 As Matrix oMatrix1 = oOccurrence1.Transformation Dim oMatrix3 As Matrix oMatrix3 = oOccurrence3.Transformation Dim oMatrix2 As Matrix oMatrix2 = oOccurrence2.Transformation oMatrix2.PreMultiplyBy(oMatrix1) Call oPartDef2.Features.NonParametricBaseFeatures.Add(oSourceBody, oMatrix2) oMatrix2 = Nothing oMatrix2 = oOccurrence2.Transformation oMatrix2.PreMultiplyBy(oMatrix3) Call oPartDef2.Features.NonParametricBaseFeatures.Add(oSourceBody1, oMatrix2) oAssemblyDoc.Update

Please feel free to contact if there is any doubt.

 

If solves your problem Accept as Solution / give a Kudo.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network