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);
}
Solved! Go to Solution.
Solved by ulski1. Go to Solution.
I am passing a color of 0,170,170 for a Teal color, and it still renders white.
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