Navisworks API

Reply
Active Contributor
sd1036770
Posts: 29
Registered: ‎01-08-2013
Message 1 of 6 (433 Views)
Accepted Solution

some question about 2013 .net api

433 Views, 5 Replies
01-08-2013 09:14 PM

Hello,I hava some question about Navisworks 2013 .Net API,please help me

1.I have *.nwd file,I can open it with Navisworks,but I can't open it with .Net API or COM API,is .NET api can only open special type file?

2.Is there any api about View Cube,NavigationBar and Steering Wheel just like Navisworks in .NET API,the View Cube is a greate tool,i want it

TKS~~~

hi,

 

- yes, COM API to zoom. I have replied you in the other thread:

  how to zoom to the modelitem

 

- see API help reference:

 

  The Application's MainDocument property is null until SetAsMainDocument is called. However SetAsMainDocument must only be called once during the runtime of applications as there can only be one main document running at a time. The DocumentControl which has the Main Document assigned must not be disposed until the end of the application.

 

In addition, remember to take a look at API samples! There are some demos of .NET control. If you have taken a look, you would have found the reason above yourself.

ADN Support Specialist
xiaodong.liang
Posts: 1,305
Registered: ‎06-12-2011
Message 2 of 6 (422 Views)

Re: some question about 2013 .net api

01-10-2013 11:57 PM in reply to: sd1036770

Hi,

 

1. nwd is the native format of Navisworks. the API should work. Could you share a demo code to reproduce the problem?

 

2. no API for view cube, NavigationBar and Steering Wheel. I agree they are nice :smileyhappy: but no API. However, API allows you to manipulate navigation mode and camera. So you will just need to implement your own interfaces with the corresponding abilities.  I even believe your interfaces would be more cool than Navisworks :smileyhappy:



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Active Contributor
sd1036770
Posts: 29
Registered: ‎01-08-2013
Message 3 of 6 (417 Views)

Re: some question about 2013 .net api

01-11-2013 12:58 AM in reply to: xiaodong.liang

Hello,Mr.Liang,can i ask you some other questions?

i want search some modelitems and i find them ,then i want to zoom to the modelitem,but i find .NET api has no related api ,the com api has ,so i use ComApiBridge to use the com api but it throw a exception called

"Application::MainDocument is Null,COM API  not available",what's wrong?

i find the Autodesk.Navisworks.Api.Application.MainDocument is always null,how to solve this problem

the code is below,the project is in attachment

 

Search s = new Search();

 

s.SearchConditions.Add(SearchCondition.HasCategoryByName("LcRevitId"));               

 

s.SearchConditions.Add(SearchCondition.HasPropertyByName("LcRevitId", "LcOaNat64AttributeValue").EqualValue(VariantData.FromDisplayString(txtModelID.Text.Trim())));

 

s.Selection.SelectAll();

 

s.Locations = SearchLocations.DescendantsAndSelf;

ModelItemCollection mic = s.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false);
                if (mic == null || mic.Count == 0)
                {
                    MessageBox.Show("没有对应ID的元素");
                }
                else
                {
                    ModelItem item = mic.First();
                    Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
                    Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Add(item);

                    InwOpState10 oState = ComApiBridge.State;
                    //InwOaPath3 path = ComApiBridge.ToInwOaPath(item) as InwOaPath3;
                    //oState.ZoomInCurViewOnBoundingBox(path.GetBoundingBox(), 1);
                    oState.ZoomInCurViewOnCurSel();
                }

ADN Support Specialist
xiaodong.liang
Posts: 1,305
Registered: ‎06-12-2011
Message 4 of 6 (409 Views)

Re: some question about 2013 .net api

01-13-2013 10:57 PM in reply to: sd1036770

hi,

 

- yes, COM API to zoom. I have replied you in the other thread:

  how to zoom to the modelitem

 

- see API help reference:

 

  The Application's MainDocument property is null until SetAsMainDocument is called. However SetAsMainDocument must only be called once during the runtime of applications as there can only be one main document running at a time. The DocumentControl which has the Main Document assigned must not be disposed until the end of the application.

 

In addition, remember to take a look at API samples! There are some demos of .NET control. If you have taken a look, you would have found the reason above yourself.



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Active Contributor
sd1036770
Posts: 29
Registered: ‎01-08-2013
Message 5 of 6 (399 Views)

Re: some question about 2013 .net api

01-16-2013 10:00 PM in reply to: xiaodong.liang
Mr.Liang Thanks for your help.I have resolve this problem,but here is another new question about clash,the code is below Document document = Autodesk.Navisworks.Api.Application.MainDocument; if (document == null || document.IsClear) { return; } DocumentClash documentClash = DocumentExtensions.GetClash(document); if (documentClash == null || documentClash.TestsData == null) { return; } the program catch an exception 未能加载文件或程序集"AutoDesk.Navisworks.Clash.dll"或它的某一个依赖项。找不到指定的模块 the screenshot is in the attachment,please help TKS
ADN Support Specialist
xiaodong.liang
Posts: 1,305
Registered: ‎06-12-2011
Message 6 of 6 (388 Views)

Re: some question about 2013 .net api

01-17-2013 11:44 PM in reply to: sd1036770

Hi,

 

It is best you log a new post for new question, instead of adding new questions more and more within one thread. Glad to see you have logged a new case. I will reply you there.

 

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!