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();
}
}
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();
}
}
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
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.