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: 

Simulate 2012 api not setting color.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
deanlyon
603 Views, 4 Replies

Simulate 2012 api not setting color.

I have been using the api to set overrides for a while now. The transparency and hide functions work for me. However the color seems to only override with White.  I have now had a request to override with a color they can set in the progam.  Please look at the code below and see if I am implementing it incorrectly.

 

void SetFileColor(string sFile, double red, double green, double blue)
{
Color color = new Color(red, green, blue);
string pattern = "^" + Regex.Escape(sFile.ToLower()).Replace(@"\*", ".*").Replace(@"\?", ".") + "$";
Regex exp = new Regex(pattern);
IEnumerable<ModelItem> items = Autodesk.Navisworks.Api.Application.ActiveDocument.Models.GetRootItems().
DescendantsAndSelf.Where(x => exp.IsMatch(x.DisplayName.ToLower()));

Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(items, color);
}

4 REPLIES 4
Message 2 of 5
xiaodong_liang
in reply to: deanlyon

Hi,

the color value is in the range of 0 ~ 1. I guess you set the values like 255, 255,0

Hope it is the case.
Message 3 of 5
deanlyon
in reply to: xiaodong_liang

I am passing a color of 0,170,170 for a Teal color, and it still renders white.

Message 4 of 5
ulski1
in reply to: deanlyon

hi,

you need to use r g b code divided by 255

colorVec.Data1 = Rcol/colorfactor
 colorVec.Data2 = Gcol/colorfactor
 colorVec.Data3 = Bcol/colorfactor

where colorfactor =255

 

Ulrik

Message 5 of 5
deanlyon
in reply to: ulski1

Thank you. I now found in the help where Color Property says that the value is between 0 and 1.

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

Post to forums  

Rail Community


Autodesk Design & Make Report