Community
Navisworks Forum
Welcome to Autodesk’s Navisworks Forums. Share your knowledge, ask questions, and explore popular Navisworks topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Override colour but no shading applied...

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
ticodi
849 Views, 5 Replies

Override colour but no shading applied...

Overriding the colour of object works, but does not apply shading.

 

I am using the following code to override the elements passed in the ModelItemColection variable called "items".  This works but for some reason it does not apply shading to the items.  I am using the below code to change the colour of the items:

 

Dim newColor As New Autodesk.Navisworks.Api.Color(255, 0, 0)

'Override the Color

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

 

As you can see from the below image it applies the colour, in this case RED, but no shading:

 

noShaing.png

 

However it I do it through the Navisworks forms it works, see image below:

 

shading.png

 

It's as if I need to tell Navisworks to apply the rendering to the active document agian?

 

Can anyone offer some assistance.

 

Thanks

 

Simon

5 REPLIES 5
Message 2 of 6
IanBadcoe
in reply to: ticodi

Hi Simon,

 

In computer graphics, colour isn't as simple as a single shade.  There are different components that can be specified to control:

 

1) the ambient colour (a base colour that shows whether it is illuminated or not)

2) the diffuse colour that interacts with light but is totally matte

3) the colour for specular (shiny) highlights

 

Your completely red objects look as if they have had all the colour applied as a ambient colour.  So they appear completely red irrsepective of the light direction.  This is why they look flat.

 

The NW UI is almost certainly doing something more sophisticated than that API call currently does.

 

There's three possibilities here:

 

1) there may be a more sophisticated API you could use (I had a quick look and nothing leaps out in "Models", I do not know whether there is public API for controlling Autodesk Rendering in NW, but if there is then that would certainly permit more sophistication)

2) or this could be a bug, and it may be that OverridePermanentColor is supposed to set a mix of ambient and diffuse color (what happens if you use less than 256 red?)

3) or, if this is behaving as expected, you could make an enhancement request for an improved override method

 

I am asking a colleague what the expected behaviour is here...

 

I realise I haven't actually solved your problem, but I hope that something in here might help move you forward.

 

Regards,

 

Ian

Message 3 of 6
ticodi
in reply to: IanBadcoe

Ian,

 

Thank you for your reply, some good points there.

 

However, even if I use a different colour, or ensure it is not a true primary colour i.e. instead true RED a variation, it still does not display any type of shading.  The thing is that when using the Naviswork GUI it works, even if I use true RED, I can only assume that it must be calling some class after overriding the colour to get Navisworks to re-apply shading to components.  I don't know if this is the case, or how to do it, it must be in the source code for Navisworks???

 

I will keep looking through the API to see if there is anything else that can help me, but like you found nothing jumped out.

 

If you could let me know if you get anymore info, as this is quite important as I am writing a plugin for a big client, and obviously cannot supply it with the current method of colouring as you cannot see any definition on model elements.

 

What about a different approach of creating custom materials e.g. a material which is RED, and then applying this material to item instead of colour? Don't know if this is even possible, just thinking out load.  If it is do you have some sample code?

 

Thanks for your help

 

Simon

Message 4 of 6
tim.wiegand
in reply to: ticodi

Check the documentation for the Color class. In Navisworks the R, G and B parts of a color are defined as floating point values in the range 0.0 to 1.0. A color of (1,0,0) should do what you want.


Tim Wiegand
Software Architect

Message 5 of 6
ticodi
in reply to: tim.wiegand

Tim,

 

Actually saw that a bit ago and was just testing, and I can confirm you are correct this solved the issue.  Thanks for all your help guys.

 

Simon

Message 6 of 6
mpriestman
in reply to: ticodi

Hiya,

 

I had a quick look at this and was unable to reproduce it. Calling the API function did just the same as using the UI. Can you provide a sample model and some source code that reproduces this issue?

 

Michael

Navisworks Principal Engineer
Autodesk Inc.

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

Post to forums  

Rail Community


Autodesk Design & Make Report