More mac 'Color' panel woes

there are many ways to end up with <auto> colors in SU…

I wrote an extension that hopes to aleviate the fustration caused…

it assigns new names using a javascript color names library…

but, on my mac, although the colors are renamed, I can’t find a way to refresh the ‘Colors’ panel to indicate the change was successful…

changing to a different ‘Desktop’ and back works [in the gif it looks a mess]…

any ideas?

john

What does …

… do ?

it doesn’t work for ‘Colors’, possibly because it’s a default Cocoa NSPanel…

john

Can the panel be closed and reopened via %x{} script ?

doesn’t update it either…

I spent hours because I thought the code was making copies…

but when I changed ‘desktop’ to tweak it, it was good when i went back…

john

Sounds like a bug report issue in the making …

I think so, maybe in the morning…

does the PC version assign <auto># to all colors…

or is that another mac bug…

john

here is the simplest ‘fail’, straight from the API plus a name change…

model = Sketchup.active_model
materials = model.materials
material = materials.add('Joe')
material.color = 'red'
material.name = 'Red'

# # these don't clear the 'Joe' material...
materials.current = materials['Red']
materials.purge_unused
# but will  purge 'Red' without materials.current line

UI.update_inspectors # 'Colors' is not an inspector panel

# this will expose a closed panel with both materials
Sketchup.send_action('orderFrontColorPanel:') 

## this is the only way found from code to clear 'Joe'
Sketchup.send_action('newDocument:')  ## New  ### ⌘N
Sketchup.send_action('performClose:')  ## Close  ### ⌘W

john

On PC Windows edition(s)…

model = Sketchup.active_model
materials = model.materials
material = materials.add('Joe')
material.color = 'red'
material.name = 'Red'
#=> Red

… at this point, there is only 1 material (“Red”) in the materials collection, and …

materials.size
#=> 1

materials['Joe'].nil?
#=> true

Also, on Windows editions, SketchUp does not use the separate system based color panel (as it generally stinks, especially the old version left over from Windows 3.x/4.x days. Devs need to be careful to explicitly use newer versions of the common dialogs library, normally thru a entry in the dependent assemblies section of the executable’s manifest.)

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.