This method of apply color working?
-
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 endYou 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::Colorclass.` 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement