This method of apply color working?
-
Hi,
I was testing the following;
face.material = "#ff0000"
Why is this not working?
Here is the link on SketchUP API... http://www.sketchup.com/intl/en/developer/docs/ourdoc/color.php
Cheers!
-
Works for me...
Sketchup.active_model.selection[0].material = "#ff0000"
What happens for you?
-
Works fine for me too...
Perhaps your reference 'face
' is invalid ? -
Hi, here is an example of what I a did...
model = Sketchup.active_model ents = model.active_entities faces = ents.grep(Sketchup;;Face) materials = model.materials m = materials.add "shadow" faces.each do |e| e.material = [255, 0, 0] # <--This Works e.material = "#ff0000" # <--This Do Not end
You can see full code on here...http://sketchucation.com/forums/viewtopic.php?f=323&t=52871
Since I had the input result come in hex mode thru web-dialog what I did to make it work on Ruby was to first change it into RGB in Javascript.
Cheers!
-
What happens when it "doesn't work"? Error messages?
Your snippet works for me...
-
Interesting...
Doesn't work on SU 8 but works on SU 2013.
Is that suppose to happen?
-
Probably a new feature then.
Which explain why I couldn't remember seeing that way of assigning material. (Which I'd written about in my blog: http://www.thomthom.net/thoughts/2012/03/the-secrets-of-sketchups-materials/#hexadecimal-notation )
-
Seems to be a new feature of the
Sketchup::Color
class.` Sketchup::Color.new '#ff0000'
Color(255, 0, 0, 255)Sketchup::Color.new '#f00'
Color(255, 0, 0, 255)`Works in SU2013 - but not SU8. And Not documented in the docs when it was implemented.
-
I see that explains everything.
It is very good that SketchUp API is being updated...hope to see more changes in the future.
cheers!
-
Yea - I've noticed some changes here and there recently.
-
It has been shown in the API for years, but I think it was broken until v2013...
-
0x0000FF has always worked. Was it not that that was displayed?
-
ah... I just checked the Way Back Machine... it was there before SU2013.
-
That was and is displayed.
But it think the string equivalent was always shown but just didn't work until now
Advertisement