by Rich O Brien » Tue Apr 17, 2012 3:48 pm
Colour N-Gons
Description: Paints N-Gons in a selection
Usage: Run 'Colour N-Gon' from the 'Plugin' menu.
Versions:
1.0 17/4/2012 - First Release
Color_N_Gon.rb
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 3:56 pm
Rich O'Brien wrote: Is it possible to colour only quad faces via ruby?
Yes - but you do mean native quads - or the non-planar ones that works with QuadFace Tools etc?
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 3:58 pm
Off-Topic: You're such a tease!
Tease.png
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 4:04 pm
Just boring old quads.
Off-Topic: What are you talking about? I'm using v9 on my iPad every day. Did you not see my post in the corner bar?
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 4:12 pm
Code: Select all for face in Sketchup . active_model . selection next unless face . is_a ?( Sketchup :: Face ) face . material = 'red' if face . edges . length == 4 end
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 4:13 pm
Off-Topic: Nice Windows UI your iPad has...
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 4:16 pm
Thanks for the code.
Off-Topic: Have you seen Windows 8 on the iPad with touch recognition? Pretty cool
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 4:51 pm
How do I enter this in the console? I tried but I'm getting errors....
Code: Select all (eval):438 for face in Sketchup.active_model.selection Error: #<SyntaxError: (eval):438: compile error (eval):438: syntax error, unexpected $end, expecting kDO_COND or ':' or '\n' or ';' for face in Sketchup.active_model.selection ^>
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 4:54 pm
Ah, it was just general code. Here is a one-liner:Sketchup.active_model.selection.each{|e|e.material='red' if e.is_a?(Sketchup::Face) && e.edges.length==4}
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by Khai » Tue Apr 17, 2012 6:44 pm
Khai
Posts: 618Joined: Sun Mar 15, 2009 4:53 pmLocation: Onboard his TARDIS
Name: Khai
Operating system: Windows
SketchUp version: 2017
License type: Free/Make
SketchUp use: architecture
Level of SketchUp: Intermediate
by Rich O Brien » Tue Apr 17, 2012 7:45 pm
You're reading my mind Khai. This is beyond my ability but I'll have a stab at it.
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by TIG » Tue Apr 17, 2012 8:02 pm
Easy-peasy... see the part that says e.edges.length==4 Just change it to any value between 3 and 1000000+e.edges.length==3 for triangulated facese.edges.length==6 for hexagonal faces etc...
TIG
TIG
Global Moderator
Posts: 19914Joined: Mon Nov 12, 2007 7:24 pmLocation: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2018
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced
by Khai » Tue Apr 17, 2012 8:23 pm
I get that Tig.. it's having the code handy all the time and where do I enter it?
Khai
Posts: 618Joined: Sun Mar 15, 2009 4:53 pmLocation: Onboard his TARDIS
Name: Khai
Operating system: Windows
SketchUp version: 2017
License type: Free/Make
SketchUp use: architecture
Level of SketchUp: Intermediate
by TIG » Tue Apr 17, 2012 9:02 pm
A 'one-liner' needs to be copied+pasted+<enter> into the Window > Ruby Console to do its stuff. In this case it works on the current Selection, and changes the material of all selected faces that have the given number of edges...
TIG
TIG
Global Moderator
Posts: 19914Joined: Mon Nov 12, 2007 7:24 pmLocation: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2018
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 9:06 pm
does this thing need a module/class etc?
Also does it need a def? All this is still greek to me
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by TIG » Tue Apr 17, 2012 9:09 pm
A 'one-liner' stands as it is - it's just like typing any commands into the Ruby Console. Of course you could make it a 'module' that has a 'menu' item and a 'dialog' for the number of faces etc etc...
TIG
TIG
Global Moderator
Posts: 19914Joined: Mon Nov 12, 2007 7:24 pmLocation: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2018
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 9:15 pm
let's not go there. As much as I need to highlight quads I don't want to tear my hair out. There's not much left after last time
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 9:42 pm
Code: Select all require 'sketchup.rb' module ROB module ColorByNGon unless file_loaded ?( File . basename ( __FILE__ ) ) menu = UI . menu ( 'Plugins' ) menu . add_item ( 'Colour N-Gons' ) { self . colour_ngon } end def self . colour_ngon prompts = [ 'Colour' , 'N-Gon Sides' ] defaults = [ 'Red' , 4 ] title = 'Colour N-Gons' result = UI . inputbox ( prompts , defaults , title ) return if result == false color , ngon = result model = Sketchup . active_model model . start_operation ( 'Colour N-Gons' , true ) for face in model . selection next unless face . is_a ?( Sketchup :: Face ) next unless face . edges . length == ngon face . material = color end model . commit_operation end end end file_loaded ( File . basename ( __FILE__ ) )
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 9:52 pm
Do I delete the orange? cause it ain't firing?
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 10:00 pm
Rich O'Brien wrote: Do I delete the orange? cause it ain't firing?
The orange is just comments - they do nothing.
I didn't test it before posting - because now I can 'fix' it for a grand fee!
Gimme the error message and a wallop of money!
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 10:03 pm
error message below....
Code: Select all ?
There's none?
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by thomthom » Tue Apr 17, 2012 10:08 pm
Ah - found a typo: def self.self.colour_ngon - should be def self.colour_ngon . I updated my post.
thomthom
PluginStore Author
Posts: 19334Joined: Tue Nov 13, 2007 12:47 pmLocation: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 10:10 pm
That little fella was highlighted in Notepad++. So it finds the errors for you.
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by Rich O Brien » Tue Apr 17, 2012 10:47 pm
Updated first post with plugin.
Thanks Thom
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by JClements » Tue Apr 17, 2012 11:20 pm
Ah, neophyte question, what is the defintion of an Ngon?
JohnIllustrator Beaverton, Oregon
JClements
Premium Member
Posts: 955Joined: Wed Nov 14, 2007 4:32 pmLocation: Portland/Beaverton, Oregon
Name: JClements
Operating system: Windows
SketchUp version: 2016
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Intermediate
by Rich O Brien » Tue Apr 17, 2012 11:22 pm
a polygon with n sides
a quad is a 4-gon
a tri is a 3-gon
etc....
Hi John
There's a frontroom and a backroom....reverse faces
Rich O Brien
Administrator
Posts: 12683Joined: Fri Oct 31, 2008 9:05 amLocation: Broadford, Clare, Ireland
Name: Rich O'Brien
Operating system: Windows
SketchUp version: 2017
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced
by Gaieus » Tue Apr 17, 2012 11:25 pm
What about a bi?
Gaieus
Posts: 27379Joined: Sat Oct 20, 2007 8:24 amLocation: Pécs, Hungary
Name: Csaba Pozsárkó
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: historical reconstruction
Level of SketchUp: Advanced
by JClements » Tue Apr 17, 2012 11:28 pm
Gai... Just let bi-gons by bygones.
JohnIllustrator Beaverton, Oregon
JClements
Premium Member
Posts: 955Joined: Wed Nov 14, 2007 4:32 pmLocation: Portland/Beaverton, Oregon
Name: JClements
Operating system: Windows
SketchUp version: 2016
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Intermediate
by Khai » Tue Apr 17, 2012 11:28 pm
Gaieus wrote: What about a bi?
they go either way
Khai
Posts: 618Joined: Sun Mar 15, 2009 4:53 pmLocation: Onboard his TARDIS
Name: Khai
Operating system: Windows
SketchUp version: 2017
License type: Free/Make
SketchUp use: architecture
Level of SketchUp: Intermediate
by pilou » Tue Apr 17, 2012 11:31 pm
a bi-gone = a segment line !
A one gone = a point !
0 gone = void
Last edited by
pilou on Tue Apr 17, 2012 11:32 pm, edited 1 time in total.
pilou
Top SketchUcator
Posts: 19576Joined: Wed Jan 23, 2008 10:33 pm
Name: Pilou
Operating system: Windows
SketchUp version: 2017
License type: Free/Make
SketchUp use: hobby
Level of SketchUp: Advanced
by Ad Machine » 5 minutes ago
Ad Machine
Robot
Posts: 2012
Return to Plugins