Create derive file from active assembly or active part

Create derive file from active assembly or active part

k14348
Advocate Advocate
382 Views
1 Reply
Message 1 of 2

Create derive file from active assembly or active part

k14348
Advocate
Advocate

Sub CreateDerivedPart()

Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2015\Templates\English\Standard (in).ipt", True)

Dim oPartDef As PartComponentDefinition
Set oPartDef = oPartDoc.ComponentDefinition

Dim oRefComp As ReferenceComponents
Set oRefComp = oPartDef.ReferenceComponents

Dim oDerAsmComp As DerivedAssemblyDefinition
Set oDerAsmComp = oRefComp.DerivedAssemblyComponents.CreateDefinition(oAsmDoc.FullDocumentName)


oDerAsmComp.DeriveStyle = kDeriveAsMultipleBodies
oDerAsmComp.IncludeAllTopLevelWorkFeatures = kDerivedExcludeAll
oDerAsmComp.IncludeAllTopLevelSketches = kDerivedExcludeAll
oDerAsmComp.IncludeAllTopLevelParameters = kDerivedExcludeAll
oDerAsmComp.IncludeAllTopLeveliMateDefinitions = kDerivedExcludeAll

oDerAsmComp.DeriveStyle = kDeriveAsSingleBodyNoSeams

Call oDerAsmComp.SetHolePatchingOptions(kDerivedPatchNone)
Call oDerAsmComp.SetRemoveByVisibilityOptions(kDerivedRemoveNone)

Dim oDerAsm As DerivedAssemblyComponent
Set oDerAsm = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerAsmComp)

Call oDerAsm.SuppressLinkToFile

End Sub

 

Please help me to solve this error.

 

Thanks

-karthik

0 Likes
383 Views
1 Reply
Reply (1)
Message 2 of 2

HermJan.Otterman
Advisor
Advisor

this will only work with an assembly, because the say that the active document is an assembly...

the last line is missing "= true" or "= false"

maybe you allso need to delete the call... I tested it in VB.net, not in VBA...

but the line  Call oDerAsm.SuppressLinkToFile  gives or sets a boolean

so:

 

oDerAsm.SuppressLinkToFile = False

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes