As the title of my topic says, I, like others before me, want to change edge colors from code. I have read all the relevant threads on this forum going back years, and there have been several people inquiring about the same issue, so I’m not alone in this quest, but I have not seen anything that would answer our need. Some advise to do it with PaintBucket but that’s a manual operation. That’s not what we want. So, could anyone tell me please, why this snippet does not work (line color remains black), and how to go about it?
require ‘sketchup.rb’
SKETCHUP_CONSOLE.show
Sketchup.active_model.rendering_options[“EdgeColorMode”]=0
model = Sketchup.active_model
entities = model.entities
view = model.active_view
So, the first puts prints a blank line because the material has has not been set yet, then after: line2.material = “red”
the second puts prints it as something. Is that something a black color and that’s why it is drawn black, or is it a red color but disregarded because of some setting, or is it red but the line was drawn first with black color and then not redrawn even though I tried to refresh the view and the problem lies with the refresh, or is it something else?
I’m on a Win7 machine, using Sketchup Make 16.1.1449 64-bit
The system changed the way my question appears!!! What’s with the big red font? That’s not how I pasted it in! Also, stuff got lost. Here we go, second try …
Ok, I give up. I paste the output in this text window and then click “Create Topic” or “Reply” and your website just deletes three lines of text!!! Hm.
The forum software processes your input as if html, so if your input contains things that look like html it will act accordingly. To avoid this, put a triple backquote on blank lines before and after your text:
<now this shows without html swallowing the brackets>
Edit: as @DanRathbun notes below, the forum’s software actually uses the Markdown language, not html.
That’s because you just puts’d the Ruby objects. You need to access a property of the object and likely use its to_s method to get a printable string. For example,
EDIT: I had previously said (and already deleted) that I could see the same problem in SU 2014. I was wrong, 2014 is working fine for me. I had commented out the code that set the color to red in my testing. My fault! This is working fine for me in 2014, 2016, Mac and Win.
And then it just stopped. I suppose it reached some limit and it timed out. Restarting Sketchup temporarily fixed this behavior, so the next session did not exhibit it at first run. Then the second and subsequent runs did the same thing (scrolling). At the end, it complains abut the stack level being too deep. Hm, I don’t have any recursion, at least not intentionally. Any ideas what’s going on here, guys? It looks like it’s stuck in an infinite loop fetching the same material until finally a higher level supervisory routine cuts it off.