Invalid Parameter exception while opening Assembly. How to deal?

Invalid Parameter exception while opening Assembly. How to deal?

Anonymous
Not applicable
782 Views
3 Replies
Message 1 of 4

Invalid Parameter exception while opening Assembly. How to deal?

Anonymous
Not applicable

The exception message is: 'The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))'.

 

I'm trying to open Assembly using next code:

 

NameValueMap options = inventorApplication.TransientObjects.CreateNameValueMap();
options.Add("ExpressModeBehavior", "OpenExpress");

assembly = (AssemblyDocument)inventorApplication.Documents.OpenWithOptions(
    assemblyFileName, // full/path/to/assembly.iam
    options
);

 

 

And it works well except for one case.

When I create subassembly in the root assembly (and in this subassembly add some parts) using Assemble->Create button, this code gets this exception while trying open saved subassembly file.

If I create subassembly using File->New->Assembly, this code works as expected.

 

Does someone have any idea why it throws an exception and how to deal with this? 🙂

Thanks! 🙂

0 Likes
Accepted solutions (1)
783 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

It looks like you may be using C#, which I'm not very familiar with, but if you are trying to open the sub-assembly of an already active parent assembly, the sub-assembly, technically, is already open, but perhaps just not visibly.  But if you are opening the parent assembly in 'express mode', the sub-assembly may only be partially loading, to conserve system resources (memory), and could be blocking your interactions with that sub-assembly.

If you open things without the express mode, will it work then?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Anonymous
Not applicable

Technically, when I open subassembly, parent assembly already closed. I keep open only one assembly per time, collect necessary data, and then close the assembly.

 

Looks like the difference is in the saving process. If I just open "problemed" subassembly and just press ctrl+s, and then run my addin again - all goes well.

 

Hmm... maybe it just doesn't save an assembly in express mode while creating using "Assemble->Create"... Will check this 🙂

 

 


@WCrihfield wrote:

If you open things without the express mode, will it work then?


Anyway, I need data from express mode...

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Yep, Inventor doesn't save Cached Graphics in case of Create button...

As a solution (temporary?), check Cached Graphics status through FileManager.GetExpressGraphicsStatus and if not cached, open and save assembly with cached.

0 Likes