Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

COM api question.

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
godbig15
1548 Views, 10 Replies

COM api question.

Hi,Help this.

 

My code.

 

 

 

using comApi = Autodesk.Navisworks.Api.Interop.ComApi;

using ComApiBridge = Autodesk.Navisworks.Api.ComApi;

 

 

ComApi.InwOpState10 state = ComApiBridge.ComApiBridge.State;

 

 

 

 

Error Message -> MainDocument is null | COMApi not available. 

 

What's wrong?

10 REPLIES 10
Message 2 of 11
xiaodong_liang
in reply to: godbig15

Hi,

 

any .NET control based app must call call SetAsMainDocument in order to communicate with COM interop.  

 

Note: 

- only one control can call this method. That means only one control can talk to COM. when you load A document with the control, the COM Bridge returns the info of A, if loading B document, the COM Bridge returnes the info of B

- this method can only been called one time in a life time of one app

Message 3 of 11
godbig15
in reply to: xiaodong_liang

Thank you!
Message 4 of 11
JohnHon
in reply to: godbig15

Dear XiaoDong,

 

May I know why SetAsMainDocument can only be called once?

In our program, we need to Terminate the API and re-initialize it again.

However, we need to use this method again after re-initializing the API.

 

Could you please help?

 

Thanks,

John

Message 5 of 11
xiaodong_liang
in reply to: JohnHon

Hi John,

yes, SetAsMainDocument can only be called once in the lifetime of the application. The same to initialize and terminate.

Could you elaborate why your program needs to terminate Navisworks environment? the only i can think of is the performance cost, but I do not think it is a big problem as the .NET control based application just starts a tiny environment like a Navisworks process in invisible mode, which would not affect much.

anyway, I'd like to get to know your scenario.
Message 6 of 11
JohnHon
in reply to: xiaodong_liang

Hi Xiaodung,

 

Thanks for answering me.

 

We need to switch the ApplicationType (SingleDocument, MultipleDocument), which cannot switch after initializing the API.

That's why we need to reinitialize the API.

 

Could you give us some clues how we can achieve it?

 

Thank you very much.

 

John

Message 7 of 11
xiaodong_liang
in reply to: JohnHon

Hi John,

sorry for the late response!

with current design, the .net based application can only be initialized once. So there is not any way to switching from single document mode to multi document mode. but i am curious why you want to do so? Actually, you have the choice to display one viewer only even if it is a multi-documents mode.
Message 8 of 11
JohnHon
in reply to: xiaodong_liang

Hi Xiaodung,

 

Thanks for your reply.

 

The reason I need to switch the document mode is I cannot view the texture of texture embedded model in Multi document mode.

However, I want to allow user to open multi documents when the model is not embedded texture.

 

Also, I need to allow user switch model between texture model and non texture model.

 

Could you give me some ways to do so?

 

 

Thanks,

John

Message 9 of 11
xiaodong_liang
in reply to: JohnHon

Hi John,

I understand what you are frustrating now. sorry, I have not an idea except logging a wish (# 49482) that multi-document mode can also support texture. Sorry for not being help as this moment.
Message 10 of 11
JohnHon
in reply to: xiaodong_liang

Hi Xiaodong,

 

Thanks for logging it.

Could you please update me if they complete this issue?

 

Thank you,

 

Best Regards,

John

Message 11 of 11
xiaodong_liang
in reply to: JohnHon

sure. I will try to remember when it is available 🙂

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

Post to forums  

Rail Community


Autodesk Design & Make Report