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: 

Unable to retrieve all colours from ModelItem with multiple fragments

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
peter_mortonFX5VV
559 Views, 6 Replies

Unable to retrieve all colours from ModelItem with multiple fragments

I have a single model item that is made of 4 fragments which appear to have different colours.

 

peter_mortonFX5VV_0-1713864609099.png

 

I am aware that I am able to retrieve the colour of a ModelItem using Geomtetry.PermanantColour, but this will return a single colour which is not enough here.

 

I tried using the Fragment.Appearance but this also appeared to return the same colour for every fragment.

 

This issue appears to be similar to https://forums.autodesk.com/t5/navisworks-api/can-t-access-the-colour-of-model-lines-on-files-with-s...

 

Note - even the Navsiworks built in FBX exporter will incorrectly export the window as a single grey colour.

 

Is there something I might be missing or is this a bug in the API? NWC file attached.

 

Thanks,

Pete

 

Tags (2)
Labels (2)
6 REPLIES 6
Message 2 of 7

Hi,

 

Nodes in NW can't have different materials (i.e. all the fragments in a model item have to have the same material). What I suspect you're seeing here is an object with no material but per-vertex colours

 

I think you can probably get hold of the per-vertex colours, but you'll need to use the COM API I think


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

Hi @naveen.kumar.t 

 

Thanks for the quick reply! I think you might be right. 

 

I attempted to get the colour of the vertices using

 

peter_mortonFX5VV_0-1713949655657.png

 

I seem to be on the right track as when processing the 4 fragments I see two distinct sets of RGB value (presumably red and grey). However, the values that get returned don't mean much to me

peter_mortonFX5VV_1-1713949818178.png

Am I retrieving the values for vertex colours incorrectly? Is there any example code for how to retrieve vertex colours? 

Thanks,

Pete

Message 4 of 7

Hi @peter_mortonFX5VV ,


I discussed with the Navisworks Engineering team.
I think you have to ask to get per-vertex colours, otherwise the values you get back might be garbage.

Looks like, You need to set ComApi.nwEVertexProperty.eCOLOR to the args
frag.GenerateSimplePrimitives(ComApi.nwEVertexProperty.eCOLOR,callbkListener);
Then, you can get float value as 0 to 1 with the code.
Array array_v1 = (Array)(object)v1.color;
var v1_1 = array_v1.GetValue(1);
var v1_2 = array_v1.GetValue(2);
var v1_3 = array_v1.GetValue(3);
 

Could you please try and let me know?


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 5 of 7

That's solved it. Thanks for your help!

Message 6 of 7

Hi @naveen.kumar.t ,

 

I may have spoken  to soon. That method appears to have solved my issue for model items where the colour is stored in the vertices. As a result  the bits of the model that previously had issues (windows etc) now appear correct:

peter_mortonFX5VV_0-1714049262802.png

 

Yet for the model items that previously worked with Geomtetry.PermanantColour are now returning garbage vertex colour values. (the values tend to be near zero or less than zero)

 

Is there way of identifying when you would use the colour from the vertices vs using the colour from the model item?  I tried adding a check that if rgb values returned from vertex colour were all <= 0 then use the Geometry.PemanantColour. However, this doesn't hold true all of the time.

 

Thanks,

Pete

Message 7 of 7

Hi,

 

Yes, you should have been given some flags to say which vertex parts are valid


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report