Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Reset Color" gets broken when setting textures #331

Open
noelwarren opened this issue Sep 5, 2019 · 5 comments
Open

"Reset Color" gets broken when setting textures #331

noelwarren opened this issue Sep 5, 2019 · 5 comments

Comments

@noelwarren
Copy link

  1. SketchUp Version: 2019
  2. OS Platform: Windows

When setting textures via the ruby API the "Reset Color" functionality does not work. This only happens if there has been a previous texture with colorization.

Do not copy and paste this as a whole. Certain actions have to be performed at give moment. Please read the comments
colorize_bug.zip

# Set the following variable
COLORIZE_BUG_PATH = "C:/Users/Noel/Dropbox/vray/texures"

# Create a material
foo = Sketchup.active_model.materials.add("foo")

# Assign a texture
foo.texture = "#{COLORIZE_BUG_PATH}/texturemap_a.png"

# Manually colorize through SketchUp UI

# Assign a different texture
foo.texture = "#{COLORIZE_BUG_PATH}/texturemap_b.png"

# Manually colorize through SketchUp UI

# And now, even though the ruby api returns the correct average_color,
# the "Reset Color" button resets to the wrong color (That of the previous texture)

This is a nuisance for our V-Ray for SketchUp users as it breaks our material binding. Users will not be able to reset their textures if they colorize them.

@noelwarren
Copy link
Author

On reading the documentation more carefully I see you are meant to set the color to nil to reset the
https://ruby.sketchup.com/Sketchup/Material.html#color=-instance_method
"To reset the color of a Material with a texture, set the color to nil."

When I do this I get the correct output in the viewport but the material editor seems to be out of sync:
image

@thomthom
Copy link
Member

thomthom commented Oct 1, 2019

When I do this I get the correct output in the viewport but the material editor seems to be out of sync:

So the issues are:

  • Documentation could need clarification? (Any suggestions?)
  • The UI doesn't update when the API modifies the material?

@noelwarren
Copy link
Author

Personally I think this shows two problems:

  1. Setting a texture through Material#texture=(path) should reset the colorization. I find the current behavior unpredictable as it depends on whether or not there was previously a colorized texture and whether or not the ruby api is used to set this up.
  2. Setting the color to nil should update the SketchUp material thumbnail properly.

@taustin73
Copy link

SU-44282

@DanRathbun
Copy link

So, as a workaround, before setting a material's texture to a new file ... is it recommended to always call #color= nil ?

matl.color= nil
matl.texture= filepath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants