[Request] Create an Edge or Surface using a Predefined Color
-
Wondering if this could be done with a script.
Rather than drawing edges or creating surfaces and then selecting a color (material) to apply, what about being about doing the converse, define the material/color for edges and surfaces before using the drawing tools? Then when geometry is drawn, those material "profiles" are applied automatically.
I think this would come in handy especially when adding geometry to an already densely populated model as it would eliminate zooming in to make selections in order to apply a material. Plus, for some users, it might be more intuitive as it would be similar to what 2D illustrative applications use.
Perhaps the UI could be dialog with matrix 32 or 64 predefined swatches to pick from with a custom color button.
-
I imagine something like that could be done, although it would likely require quite a lot of work, as it isnt possible to alter the default SU tools using the API.
It should be fairly simple to make a line tool that draws in a predefined colour, though, by just adding a material applying element to the line.rb example script. I could have a go if that sounds like roughly the sort of thing you were thinking of...
-
Hi Remus,
If you think you can alter the line.rb sample script that would be nice.
If it works, eventually would it be possible to have a two-icon toolbar; one to change the color and the other to return back to the default color?
John
-
i'll add it to the list of things to do
-
I tried my hand at it, and came up with a version using observers. I have very little experience with observers, but I am wanting to find out if and when they are useful. Perhaps this is an instance of where they could come in handy.
This script is very simple, it just watches the model and anytime a new face is made, it colors the front face with the current color. Select the code and save it into your plugins folder as any name you wich, just end it with .rb
I don't want to upload my own actual rb file because this is not a plugin that is ready for primetime yet. So I don't want to make it too easy for people who don't know what they are getting into to install this one yet But I'm sure you can handle it John, it is your idea after all.
One known quirk is that it only work on the first opened model in SU. If you open a new model, it will stop working. I'll try to get that worked out. I need to get the OnNewModel observer working.
class MyEntitiesObserver < Sketchup;;EntitiesObserver def onElementAdded(entities, entity) current_mat = Sketchup.active_model.materials.current entity.material = current_mat if entity.is_a? Sketchup;;Face end end Sketchup.active_model.entities.add_observer(MyEntitiesObserver.new)
Try that, see what you think of the functionality. It is interesting.
Chris
-
If you do want to get it working in a model that was opened after the first opened model (ie open the first model, then open a second new model and the script stops working). To get it to start working again, just opent he ruby console and enter that last line of code back into the console and it will start again.
Sketchup.active_model.entities.add_observer(MyEntitiesObserver.new)
Chris
-
Didnt tihnk of using observers, a cunning plan indeed chris
Is material.current the material selected in the materials browser?
-
class MyAppObserver < Sketchup;;AppObserver def OnNewModel(model) model.entities.add_observer(MyEntitiesObserver.new) end end
Sketchup.add_observer(MyAppObserver.new)
Seems like it should work...
-
Thanks TIG, I'll try that when I get a few monets to play. I had played with the OnNewModel observer, but I could not get it to fire. I probably was doing something wronge. I mostly just copied and pasted the example from the Docs. Thanks!
Chris
Advertisement