Plugin Help - modify Add Section Cut Face
-
I need a bit of help with TIGs 'Add Section Cut Face'.
I want to limit my choices with the script, have it default to width of 2, unlocked group, do not hide edges, and fill be 'DarkGray'.I managed to get all the variables sorted - but I cannot get 'DarkGray' to default for color of the fill. I still get black:
### ############################## def dialog(sfix) ### get colours and layer model = Sketchup.active_model mlayers = model.layers alayer=model.active_layer model.active_layer=nil deflayer=model.active_layer.name model.active_layer=alayer dlayer = "CUT-"+sfix layers = [] mlayers.each{|layer|layers << layer.name if layer.name != deflayer} layers=[dlayer,deflayer]+layers.sort! layers = layers.join('|') colours = Sketchup;;Color.names.join('|') cedges = colours ###v1.3 colours = "<Default>|<No_Face>|"+colours ###v1.3###v2.5 ### prompts = ["Cut-Face Color; ", "Cut-Edge Color; ", "Cut-Edge Width", "Keep Un-Faced Edges; ", "Hide Edges; ", "Lock Cut; ", "Cut Layer; "] ###v2.2/2.5 title = "Section-Cut Parameters" @@colour = Sketchup;;Color.names[7] if not @@colour ### DarkGray @@edge = Sketchup;;Color.names[7] if not @@edge ### Black @@width = 2 if not @@width @@edges = "No" if not @@edges ###v2.2 @@hide = "No" if not @@hide ###v2.2 @@lock = "No" if not @@lock @@layer = dlayer ### default values = [@@colour, @@edge, @@width, @@edges, @@hide, @@lock, @@layer]### ###v2.2/2.5 popups = [colours, cedges, "", "Yes|No", "Yes|No", "Yes|No", layers] ###v2.2 results = inputbox( prompts, values, popups, title ) return nil if not results ### do processing of results @@colour = results[0] @@edge = results[1] @@width = results[2] @@width = 1 if @@width < 1 @@width = 20 if @@width > 20 @@edges = results[3] ###v2.2 @@hide = results[4] ###v2.2 @@lock = results[5] ###v2.5 @@layer = results[6] ###v2.2 if @@colour=="<No_Face>" ###v2.5 @@edges="Yes" @@hide="No" end#if return true end #def dialog
I think this is the relevant line:
@@colour = Sketchup::Color.names[7] if not @@colour ### DarkGray
I've played around with the 7 in brackets, it certainly changes the color... but i cannot find reference to how the colors are numbered... going to the materials palette brought back 0135, which is 'Moccasin'.
Any help?
-
@@colour = Sketchup::Color.names[7] if not @@colour
'7
' is 'Black' - find which number is 'DarkGray
' - remembering that the list starts at 0...Hint - try '
24
'This one-liner in the Ruby Console lists all built-in colors and their 'index'...
Sketchup::Color.names.each_with_index{|e,i|puts e+" = "+i.to_s}
-
Thanks much...!
I tried counting in the list that pops up in the plugin, that didn't seem to correspond, then I went to the materials palette and learned that the numbers there don't seem to mean anything...
All set now. Put in '24' and it is working fine.
I can now just slide the layer toggle and I'm good to go.
Makes for updating a document set much easier. -
you are one of the best supporters ... when we want to modify a TIG's code which teacher is better than author himself ?
Advertisement