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: 

Save viewpoint with colours?

9 REPLIES 9
Reply
Message 1 of 10
markusvikström
2000 Views, 9 Replies

Save viewpoint with colours?

Hi,

 

I'm trying to colour a Navisworks model (through API) with different colours based on saved views, this works fine manually when I set the "Overide Material" switch in the global options (this allows me to save a viewport with colours based on the actual colours). [Options - Interface - Viewpoint Defaults - Override Material]

 

The issue I am having is that doing the same through Navisworks API doesn't seem to record the colours in the created view. Anyone have a solution to this?

 

1. I'm using something similar to this when creating a saved viepoint:

http://adndevblog.typepad.com/aec/2012/06/navisworks-net-api-2013-new-feature-saved-viewpoint.html

 

2. I'm colouring the objects the same way as this:

http://forums.autodesk.com/t5/Navisworks-API/NavisWorks-API-net-Color-Question/td-p/3174550

 

3) then I save A NEW view again (similar to code from 1)

 

 

=> The result is that the colouring from 2) is applied to both views, by chaning the colours on a object by hand later shows that each view saved by the API uses the new colours, so by this I assume the saved viewpoints do not save the colouring (even though it is set in the options), is there a way by API to do it or is this a feature[bug]?

 

BR,
Markus

9 REPLIES 9
Message 2 of 10

Hi,

If you could provide a small demo code, it will help to address what the problem is. Without a code, it is a bit hard to know the context, whether is is a real problem, or something is missed.
Message 3 of 10

 

 

Here is a short snippet, copied it from parts of the code with some small adjustments, so I hope it can run out of the box...

 

//1
//Create First view with default colours, colours is not saved here either Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; SavedViewpoint oNewViewPt1 = new SavedViewpoint(oDoc.CurrentViewpoint.ToViewpoint()); oNewViewPt1.DisplayName = "FirstView"; oDoc.SavedViewpoints.AddCopy(oNewViewPt1); //2 //Set the colour of selected elements to red for some reason ModelItemCollection selectedItems = new ModelItemCollection(oDoc.CurrentSelection.SelectedItems); Autodesk.Navisworks.Api.Color newColor = new Autodesk.Navisworks.Api.Color(1, 0, 0); Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(newCollection, newColor); //3 //Create Second view with "changed colours", but unfortunatley it is not saved in the view as when done manually. SavedViewpoint oNewViewPt2 = new SavedViewpoint(oDoc.CurrentViewpoint.ToViewpoint()); oNewViewPt2.DisplayName = "SecondView"; oDoc.SavedViewpoints.AddCopy(oNewViewPt2);

 

Both views reflects the colour set in step 2, changing the colours in one of the views will reflect the colour in each of the saved views. If saved manually it will remember the colours.

=> By this I would assume that making a saved viewpoint in code does not save the colour even though the global settings it set to save it!

 

When thinking about it, might be I need to save the viewpoint from something else than the actual CurrentViewpoint, it is probobly a pointer to it...

 

/Markus

 

Edit: some code changes to make it actually work...

Message 4 of 10

 

Does not seem to work to Create a Copy of it either, the same flaw, it do not remember the colours of the saved viewpoint when done in API.

 

new SavedViewpoint(oDoc.CurrentViewpoint.ToViewpoint().CreateCopy());

 

 

Note, I am using Navisworks Simulate 2013, could be you have fixed it in later releases if you can not reproduce the issue... 

 

/Markus

 

Message 5 of 10

and of course, to get it to work further you need to change:

Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(selectedItems, newColor);

 /Markus

Message 6 of 10

This was only a comment to get the code snippet to run, not to get the issue solved...

/Markus

Message 7 of 10

Hi,

After some testing, it looks an issue to me that the API SavedViewpoint does not take [Override Material] into account. The option of each saved viewpoint is NOT checked even though the global option is enabled. So I think this is why the saved viewpoint does not reflect the corresponding status. Sorry I have not got a workaround.
I will research further. If there is any update, I will get back.

Message 8 of 10

sorry, this looks a problem to me. I have to log the issue# NW-48034
Message 9 of 10

the issue applies to hide/show for new savedviewpoints also.

 

how did the logged error issue# NW-48034 progress?


@xiaodong_liang wrote:
sorry, this looks a problem to me. I have to log the issue# NW-48034

 

Message 10 of 10

Hello,

 

is this still an issue in 2016 or 2017?

 

Has issue# NW-48034 been resolved meanwhile?

 

Thanks

 

Wolfgang

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

Post to forums  

Rail Community


Autodesk Design & Make Report