Single Object Color Change initiated from Visual Basic code

Single Object Color Change initiated from Visual Basic code

Anonymous
Not applicable
482 Views
1 Reply
Message 1 of 2

Single Object Color Change initiated from Visual Basic code

Anonymous
Not applicable

Does anyone have sample code that outlines how to use the "OverridePermanentColor" included in the NavAPI?

Have been playing with this code for a few days now and cannot get it to trigger anything.  I am trying to see if I can create code that will change the active color to RED for a single object within a model. 

I can, and have linked Excel to the model and can trigger and event change via the appearance profiler, but the profiler has to be manually triggered.  I guess that would be another option/question: Is there a way through the API to trigger the Appearance Profiler to execute via a VB timer? 

Any direction, literature, sample code to look over, etc. would be greatly appreciated.

0 Likes
483 Views
1 Reply
Reply (1)
Message 2 of 2

ulski1
Collaborator
Collaborator
Very few people in the forum use vb - most people here use csharp - that being said the syntax should be very similar.
What you need is something like this (sorry in csharp):
Autodesk.Navisworks.Api.Color mycolor = new Autodesk.Navisworks.Api.Color(r / 255, g / 255, b / 255); //define rgb as double
ModelItemCollection MyCollection = Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems;//you can create a modelitemcollection via search as well
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(MyCollection, mycolor);

Br
Ulrik