How to Exclude WorkFeatures in Parts in a Derived Assembly(Shrink Wrap) ?

How to Exclude WorkFeatures in Parts in a Derived Assembly(Shrink Wrap) ?

hariharanhZXJ8L
Contributor Contributor
300 Views
2 Replies
Message 1 of 3

How to Exclude WorkFeatures in Parts in a Derived Assembly(Shrink Wrap) ?

hariharanhZXJ8L
Contributor
Contributor

Hello Friends,

I am facing a problem in my program. I need to Shrink Warp my Assembly file but after finishing all the WorkFeatures of subparts/ subassemblies are available in simplified parts.ipart.JPG

 

I have provided my code below, please help to resolve my issue.

 

 

 

public static void CreateSimplifiedPartFile(AssemblyDocument assemDoc, string targetFolderName)
        {
            AssemblyComponentDefinition oCompDef = assemDoc.ComponentDefinition;            
            UtilResx.TemplatePath = UtilResx.TemplatePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string tempFileName = System.IO.Path.Combine(UtilResx.TemplatePath, "Templates", UtilResx.PartTemplateName);
            PartDocument oPartDoc = (PartDocument)InventorModelGenerator.InventorApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, tempFileName, false);
            PartComponentDefinition oPartCompDef = oPartDoc.ComponentDefinition;

            DerivedAssemblyDefinition oDrivedAssyDef = oPartCompDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(assemDoc.FullDocumentName);
            oDrivedAssyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams;
            oDrivedAssyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll;
            oDrivedAssyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll;
            oDrivedAssyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll;
            oDrivedAssyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll;
            oDrivedAssyDef.SetHolePatchingOptions(DerivedHolePatchEnum.kDerivedPatchAll);
            oDrivedAssyDef.SetRemoveByVisibilityOptions(DerivedGeometryRemovalEnum.kDerivedRemovePartsAndFaces, 35);           
            oDrivedAssyDef.ReducedMemoryMode = true;
            
            DerivedAssemblyComponent oDrivedAssy = oPartCompDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDrivedAssyDef);
            string fileName = String.Format("{0}{1}",assemDoc.FullDocumentName.Substring(0,assemDoc.FullDocumentName.Length -4),"-SimplifiedPart.ipt");
            oPartDoc.SaveAs(fileName, false);
            oPartDoc.ReleaseReference();
        }

 

 

 

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

tyler.warner
Advocate
Advocate

Hey @hariharanhZXJ8L , try this additional function, it has worked in my commands.

 

 

public static void CreateSimplifiedPartFile(AssemblyDocument assemDoc, string targetFolderName)
{
    AssemblyComponentDefinition oCompDef = assemDoc.ComponentDefinition;            
    UtilResx.TemplatePath = UtilResx.TemplatePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    string tempFileName = System.IO.Path.Combine(UtilResx.TemplatePath, "Templates", UtilResx.PartTemplateName);

    ObjectVisibility(assemDoc, false);

    PartDocument oPartDoc = (PartDocument)InventorModelGenerator.InventorApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, tempFileName, false);
    PartComponentDefinition oPartCompDef = oPartDoc.ComponentDefinition;

    DerivedAssemblyDefinition oDrivedAssyDef = oPartCompDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(assemDoc.FullDocumentName);
    oDrivedAssyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams;
    oDrivedAssyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll;
    oDrivedAssyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll;
    oDrivedAssyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll;
    oDrivedAssyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll;
    oDrivedAssyDef.SetHolePatchingOptions(DerivedHolePatchEnum.kDerivedPatchAll);
    oDrivedAssyDef.SetRemoveByVisibilityOptions(DerivedGeometryRemovalEnum.kDerivedRemovePartsAndFaces, 35);           
    oDrivedAssyDef.ReducedMemoryMode = true;
            
    DerivedAssemblyComponent oDrivedAssy = oPartCompDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDrivedAssyDef);
    string fileName = String.Format("{0}{1}",assemDoc.FullDocumentName.Substring(0,assemDoc.FullDocumentName.Length -4),"-SimplifiedPart.ipt");
    oPartDoc.SaveAs(fileName, false);
    oPartDoc.ReleaseReference();
}

private static void ObjectVisibility(AssemblyDocument oAsmDoc, Boolean oToggle)
{
    ObjectVisibility oSubCompVis = oAsmDoc.ObjectVisibility;
    oSubCompVis.Sketches = oToggle;
    oSubCompVis.Sketches3D = oToggle;
    oSubCompVis.UserWorkPlanes = oToggle;
    oSubCompVis.UserWorkAxes = oToggle;
    oSubCompVis.UserWorkPoints = oToggle;
    oSubCompVis.OriginWorkPlanes = oToggle;
    oSubCompVis.OriginWorkAxes = oToggle;
    oSubCompVis.OriginWorkPoints = oToggle;
}

 

 

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes
Message 3 of 3

hariharanhZXJ8L
Contributor
Contributor

Hello @tyler.warner ,

 

Thanks for your reply. your Code is Hiding the work features on the assembly not on the Derived assembly. 

Actually, my requirement is to do not include the Work features in my derived assembly part file(Simplified Part)

hariharanhZXJ8L_0-1663303830836.png

I need the output as below.

hariharanhZXJ8L_1-1663303934346.png

There is no Work features available on this Part file.

I hope you got my requirement.

 

I have gone through the API, there is options to exclude the Work Features on the Top-level only. There is no option to exclude the work features on sub-part level.

 

If some one found the solution, please let me know.

Thanks

HARI.

0 Likes