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: 

Inventor 2022 shrinkwrap hide occurences doesn't work with model states

1 REPLY 1
Reply
Message 1 of 2
Anonymous
312 Views, 1 Reply

Inventor 2022 shrinkwrap hide occurences doesn't work with model states

Anonymous
Not applicable

Hi there,

 

I want to create a shrinkwrap of my assembly via api. Some parts are not needed  for this (content center), so I want to exclude those occurrences. Essentially this works, but once I have more than one model state in my assembly it stops working.

 

I also tried to derive from the assembly, but the same problem there. 

 

Here is my code:

 

public void ExportMesh(AssemblyDocument asmDoc, ObjectCollection ignoreOccurences, StreamWriter streamWriter) {
    PartDocument shrinkWrapDoc = InventorApp.Instance.Documents.Add(DocumentTypeEnum.kPartDocumentObject) as PartDocument;
    try {
        ShrinkwrapDefinition shrinkWrapDef = shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(asmDoc.FullFileName);
        shrinkWrapDef.ActiveDesignViewRepresentation = "Standard";
        //shrinkWrapDef.ActiveLevelOfDetailRepresentation = meshDetailSettings.ActiveLevelOfDetailRepresentation;
        //shrinkWrapDef.ActiveModelState = meshDetailSettings.ActiveLevelOfDetailRepresentation;
        //LOD Settings
        shrinkWrapDef.ActiveLevelOfDetailRepresentation = "Hauptansicht";
        shrinkWrapDef.ActivePositionalRepresentation = "Hauptansicht";
        shrinkWrapDef.ActiveModelState = "Hauptansicht";
        shrinkWrapDef.RemoveAllInternalVoids = true; 
        shrinkWrapDef.RemoveChamfersStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemoveChamfersDistanceRange = 0;
        shrinkWrapDef.RemoveHolesStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemoveHolesDiameterRange = 2;
        shrinkWrapDef.RemoveFilletsStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemoveInternalParts = meshDetailSettings.true;
        shrinkWrapDef.RemovePocketsStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemovePocketsMaxFaceLoopRange = 0;
        shrinkWrapDef.DeriveStyle = meshDetailSettings.DeriveStyle;
        shrinkWrapDef.AdditionalExcludedOccurrences = ignoreOccurences;
        shrinkWrapDef.CreateIndependentBodiesOnFailedBoolean = true;
        shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.Add(shrinkWrapDef);

        var test = shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents[1].Definition;
        test.AdditionalExcludedOccurrences = ignoreOccurences;
        shrinkWrapDoc.Update2();
        InventorApp.Instance.UserInterfaceManager.DoEvents();

        shrinkWrapDoc.SaveAs(Path.Combine(@"c:\tmp", Path.ChangeExtension(Path.GetFileName(asmDoc.FullFileName), ".ipt")), false);

        WavefontObjExport wavefontObjExport = new WavefontObjExport(InventorApp.Instance);
        wavefontObjExport.Export(meshDetailSettings, shrinkWrapDoc, streamWriter);
    } catch (Exception ex) {

    } finally {
        InventorApp.Instance.UserInterfaceManager.DoEvents();
        shrinkWrapDoc.Close(true);
        InventorApp.Instance.UserInterfaceManager.DoEvents();
    }
}

 

Inventor 2022 shrinkwrap hide occurences doesn't work with model states

Hi there,

 

I want to create a shrinkwrap of my assembly via api. Some parts are not needed  for this (content center), so I want to exclude those occurrences. Essentially this works, but once I have more than one model state in my assembly it stops working.

 

I also tried to derive from the assembly, but the same problem there. 

 

Here is my code:

 

public void ExportMesh(AssemblyDocument asmDoc, ObjectCollection ignoreOccurences, StreamWriter streamWriter) {
    PartDocument shrinkWrapDoc = InventorApp.Instance.Documents.Add(DocumentTypeEnum.kPartDocumentObject) as PartDocument;
    try {
        ShrinkwrapDefinition shrinkWrapDef = shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(asmDoc.FullFileName);
        shrinkWrapDef.ActiveDesignViewRepresentation = "Standard";
        //shrinkWrapDef.ActiveLevelOfDetailRepresentation = meshDetailSettings.ActiveLevelOfDetailRepresentation;
        //shrinkWrapDef.ActiveModelState = meshDetailSettings.ActiveLevelOfDetailRepresentation;
        //LOD Settings
        shrinkWrapDef.ActiveLevelOfDetailRepresentation = "Hauptansicht";
        shrinkWrapDef.ActivePositionalRepresentation = "Hauptansicht";
        shrinkWrapDef.ActiveModelState = "Hauptansicht";
        shrinkWrapDef.RemoveAllInternalVoids = true; 
        shrinkWrapDef.RemoveChamfersStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemoveChamfersDistanceRange = 0;
        shrinkWrapDef.RemoveHolesStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemoveHolesDiameterRange = 2;
        shrinkWrapDef.RemoveFilletsStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemoveInternalParts = meshDetailSettings.true;
        shrinkWrapDef.RemovePocketsStyle = ShrinkwrapRemoveStyleEnum.kShrinkwrapRemoveNone;
        shrinkWrapDef.RemovePocketsMaxFaceLoopRange = 0;
        shrinkWrapDef.DeriveStyle = meshDetailSettings.DeriveStyle;
        shrinkWrapDef.AdditionalExcludedOccurrences = ignoreOccurences;
        shrinkWrapDef.CreateIndependentBodiesOnFailedBoolean = true;
        shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.Add(shrinkWrapDef);

        var test = shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents[1].Definition;
        test.AdditionalExcludedOccurrences = ignoreOccurences;
        shrinkWrapDoc.Update2();
        InventorApp.Instance.UserInterfaceManager.DoEvents();

        shrinkWrapDoc.SaveAs(Path.Combine(@"c:\tmp", Path.ChangeExtension(Path.GetFileName(asmDoc.FullFileName), ".ipt")), false);

        WavefontObjExport wavefontObjExport = new WavefontObjExport(InventorApp.Instance);
        wavefontObjExport.Export(meshDetailSettings, shrinkWrapDoc, streamWriter);
    } catch (Exception ex) {

    } finally {
        InventorApp.Instance.UserInterfaceManager.DoEvents();
        shrinkWrapDoc.Close(true);
        InventorApp.Instance.UserInterfaceManager.DoEvents();
    }
}

 

1 REPLY 1
Message 2 of 2
CattabianiI
in reply to: Anonymous

CattabianiI
Collaborator
Collaborator

I confirm the issue and this could be tested with iLogic.

 

Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument

Dim ignoreOccurences As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each occ As ComponentOccurrence In ThisApplication.ActiveDocument.SelectSet
	ignoreOccurences.Add(occ)
Next

Dim shrinkWrapDoc As PartDocument = TryCast(ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject), PartDocument)
Dim shrinkWrapDef As ShrinkwrapDefinition = shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(asmDoc.FullDocumentName)

shrinkWrapDef.ActiveModelState = asmDoc.ModelStateName

shrinkWrapDef.AdditionalExcludedOccurrences = ignoreOccurences

shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.Add(shrinkWrapDef)

 

 

Could Autodesk confirm this issue and give us an INVGEN? @johnsonshiue 

0 Likes

I confirm the issue and this could be tested with iLogic.

 

Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument

Dim ignoreOccurences As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each occ As ComponentOccurrence In ThisApplication.ActiveDocument.SelectSet
	ignoreOccurences.Add(occ)
Next

Dim shrinkWrapDoc As PartDocument = TryCast(ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject), PartDocument)
Dim shrinkWrapDef As ShrinkwrapDefinition = shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(asmDoc.FullDocumentName)

shrinkWrapDef.ActiveModelState = asmDoc.ModelStateName

shrinkWrapDef.AdditionalExcludedOccurrences = ignoreOccurences

shrinkWrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.Add(shrinkWrapDef)

 

 

Could Autodesk confirm this issue and give us an INVGEN? @johnsonshiue 

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

Post to forums  

Autodesk Design & Make Report