Using the shrinkwrap API causes Inventor to crash when run in Forge

Using the shrinkwrap API causes Inventor to crash when run in Forge

Anonymous
Not applicable
1,044 Views
5 Replies
Message 1 of 6

Using the shrinkwrap API causes Inventor to crash when run in Forge

Anonymous
Not applicable

Hi!

 

I have created an Inventor addin in C#. The addin is bundled as an AppBundle and is executed using Forge. Apologies if I'm in the wrong forum, but I didn't see a Forge option.

 

When the addin uses the shrinkwrap API, I get:

 

[04/28/2021 05:32:40] End Inventor Core Engine standard output dump.
[04/28/2021 05:32:40] Error: InventorCoreConsole.exe found crash.
[04/28/2021 05:32:40] Error: Reading DUMP file:
[04/28/2021 05:32:40] Error: 2021-04-28 05:32:38 GDI_Objects 23  USEROBJECTS 7  GDIOBJECTSPEAK 25  USEROBJECTSPEAK 7 | SVxApp::CareForAllExceptions() (SVxApp.cpp L2866): |SEH exception caught while executing request!
stack = _NA_	_NA_	[NULL]	
_NA_	UTxCERLog::LogCallStack [NULL]	
_NA_	SVxApp::CanMigrateCustomSettings [NULL]	
_NA_	VBAxApp::TerminateVBA [NULL]	
_NA_	_C_specific_handler [NULL]	
_NA_	_chkstk [NULL]	
_NA_	RtlWalkFrameChain [NULL]	
_NA_	KiUserExceptionDispatcher [NULL]	
_NA_	PMxIFxPartFeature::SetState [NULL]	
_NA_	PMxRootDANode::ApplyShrinkwrap [NULL]	
_NA_	PMxSrvRootDANode::ApplyShrinkwrap [NULL]	
_NA_	RDxDerivedAssembly::SimplificationSettings [NULL]	
_NA_	RDxDerivedCopier::UpdateStructure [NULL]	
_NA_	RDxDerivedAssembly::SimplificationSettings [NULL]	
_NA_	RDxDerivedCopier::Compute [NULL]	
_NA_	RDxDerivedAssembly::Compute [NULL]	
_NA_	RDxFragment::DoComputeThisSet [NULL]	
_NA_	RDxFragment::DoCompute [NULL]	
_NA_	RDxFragment::ComputeMinimum [NULL]	
_NA_	RDxPart::Update [NULL]	
_NA_	RDxComponent::UpdateComponentActual [NULL]	
_NA_	RDxComponent::UpdateComponent [NULL]	
_NA_	RDxPart::UpdateComponent [NULL]	
_NA_	RQxDerivedAssemblyRequest::_Execute [NULL]	
_NA_	FWxChangeRequest::Execute [NULL]	
_NA_	AMxProcessShrinkwrapRequest::CreateDoc [NULL]	
_NA_	FWxChangeRequest::Execute [NULL]	
_NA_	SVxApp::Destruct [NULL]	
_NA_	SVxApp::TranscriptingOn [NULL]	
_NA_	SVxApp::ProcessChangeRequest [NULL]	
_NA_	FWxSceneDoc::ProcessChangeRequest [NULL]	
_NA_	CRxDocument<PresentationDocument>::ProcessChangeRequest [NULL]	
_NA_	CRxDocument<PresentationDocument>::OnReleaseReference [NULL]	
_NA_	_NA_	[NULL]	
_NA_	SetErrorInfo [NULL]	
_NA_	DispCallFunc [NULL]	
_NA_	VarNumFromParseNum [NULL]	
_NA_	RxDispatch::Invoke [NULL]	
_NA_	_NA_	[NULL]	
_NA_	TranslateSecurityAttributes [NULL]	
_NA_	TranslateSecurityAttributes [NULL]	
_NA_	TranslateSecurityAttributes [NULL]	
_NA_	TranslateSecurityAttributes [NULL]	
_NA_	_NA_	[NULL]	
_NA_	_NA_	[NULL]	
_NA_	LogHelp_TerminateOnAssert [NULL]	
_NA_	LogHelp_TerminateOnAssert [NULL]	
_NA_	LogHelp_TerminateOnAssert [NULL]	
_NA_	TranslateSecurityAttributes [NULL]	
_NA_	TranslateSecurityAttributes [NULL]	
_NA_	_NA_	[NULL]	
_NA_	_NA_	[NULL]	
_NA_	_NA_	[NULL]	
_NA_	_NA_	[NULL]	
_NA_	_NA_	[NULL]	

2021-04-28 05:32:39 GDI_Objects 23  USEROBJECTS 7  GDIOBJECTSPEAK 25  USEROBJECTSPEAK 7 | DumpAndSend() (ErrorReporter.cpp L1465): |Inventor Crash log!
[04/28/2021 05:32:40] Error: API method ShrinkwrapComponents.Add caught an unhandled exception.
Memory may have been left in an inconsistent state.
[04/28/2021 05:32:40] Error: API method caught an unhandled exception.  Memory may have been left in an inconsistent state.

 

The code looks like this:

 

private PartDocument Shrinkwrap(AssemblyDocument inputDoc)
{
    var shrinkwrapDoc = NewPartDocument();
    var shrinkwrapDef =
        shrinkwrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(
            inputDoc.FullDocumentName);
    var objectColl = _inventorServer.TransientObjects.CreateObjectCollection();

    foreach (ComponentOccurrence occurrence in inputDoc.ComponentDefinition.Occurrences)
    {
        objectColl.Add(occurrence);
    }

    shrinkwrapDef.AdditionalIncludedOccurrences = objectColl;
    shrinkwrapDef.RemoveInternalParts = true;
    shrinkwrapDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyWithSeams;
    shrinkwrapDef.BreakLink = true;

    LogTrace("Adding shrinkwrap definition to shrinkwrap components...");
    shrinkwrapDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.Add(shrinkwrapDef);
    LogTrace("Done adding shrinkwrap definition to shrinkwrap components.");

    return shrinkwrapDoc;
}

 

I can see the "Adding shrinkwrap definition" message in the Forge report, but not the "Done adding" message.

 

When I run the code locally in Inventor 2022, there is no error. In Forge using engine Autodesk.Inventor+2022, the error occurs. The error also occurs when I use Autodesk.Inventor+2021 as engine.

 

Any ideas?

 

Thanks,

Per

 

0 Likes
1,045 Views
5 Replies
Replies (5)
Message 2 of 6

adam.nagy
Autodesk Support
Autodesk Support

I cannot see what you are doing inside 

NewPartDocument

Can you please make sure that the document is opened invisible?

Opening/Creating documents with OpenVisible True seems to be causing issues on Design Automation - also mentioned here: https://forge.autodesk.com/blog/dealing-suppressed-components 

Another issue could be file resolution: https://forge.autodesk.com/blog/resolving-referenced-inventor-files 

 

Note: Forge support is on stackoverflow using the right tags: https://forge.autodesk.com/en/support/get-help 
Or sending email to forge.help@autodesk.com 



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Adam,

 

Thank you for your reply!

 

NewPartDocument contains:

 

public PartDocument NewPartDocument()
{
    if (!(_inventorServer.Documents.Add(DocumentTypeEnum.kPartDocumentObject) is PartDocument partDoc))
        throw new InvalidOperationException("Failed to create a new part document");
    return partDoc;
}

 

I tried to set CreateVisible to false, but that didn't help.

 

I also tried adding /p to the command line, which also didn't help.

 

I'm not doing anything related to suppressed components in the code - but maybe the shrinkwrap API does that?

 

0 Likes
Message 4 of 6

adam.nagy
Autodesk Support
Autodesk Support

Just to clarify: you're testing with the exact same model, same code and same version of Inventor both locally and on Design Automation (DA) - on the desktop all is fine, but on DA you get this error?
Then I guess we'll have to debug it.

 

Would you be able to simplify the model as much as possible (removing parts/assemblies from it), but making sure the error is still reproducible with it?

 

If you don't have a model you're comfortable with sharing here you can email me directly.



Adam Nagy
Autodesk Platform Services
0 Likes
Message 5 of 6

Anonymous
Not applicable

Yes, the models are the same.

 

Version information from Forge is:

 

InventorCoreConsole.exe: 25.0.18300.0, 461-7e71832
Starting Inventor Server.
Started Inventor Server 2022 (Build 260153000, 153) (26, 0, 15300, 0000)

 

I don't know how to check my local version, but the file version of Inventor.exe is 26.0.15300.0, so it appears to be the same as the Forge version.

 

I managed to shrinkwrap in a different way using the following code:

 

private PartDocument Shrinkwrap(AssemblyDocument inputDoc)
{
    var shrinkwrapDoc = NewPartDocument();
    var componentDef = shrinkwrapDoc.ComponentDefinition;
    var derivedAssemblyDef =
        componentDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(inputDoc.FullDocumentName);

    derivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyWithSeams;
    derivedAssemblyDef.InclusionOption = DerivedComponentOptionEnum.kDerivedIncludeAll;
    derivedAssemblyDef.ReducedMemoryMode = true;

    LogTrace("Adding to DerivedAssemblyComponents");
    var assemblyComp = componentDef.ReferenceComponents.DerivedAssemblyComponents.Add(derivedAssemblyDef);
    LogTrace("Added to DerivedAssemblyComponents");
    
    assemblyComp.BreakLinkToFile();

    return shrinkwrapDoc;
}

 

This code works both locally and in Forge. I'm still waiting for confirmation that the resulting file is ok, but it looks promising.

 

Do you see any downside of using the DerivedAssemblyComponent approach instead?

 

0 Likes
Message 6 of 6

adam.nagy
Autodesk Support
Autodesk Support

ShrinkwrapDefinition has many more options than DerivedAssemblyComponent: see https://github.com/adamenagy/ModelSimplificationDA/blob/master/ShrinkWrap/ShrinkWrapPlugin/SampleAut... If you don't need them then just use DerivedAssemblyComponent 

Live version: https://forge-modelsimplification.herokuapp.com/ 

Do you have a 2021 version of your model you could test with my above sample?



Adam Nagy
Autodesk Platform Services
0 Likes