Export selection as jpg?
-
Is there a plugin that enables me to export a selection as jpg image?
-
@john2 said:
Is there a plugin that enables me to export a selection as jpg image?
This should do it.
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection vue = mod.active_view ent.each{|e| sel.toggle e} tmp = sel.to_a;sel.clear tmp.each{|e| e.hidden=true} vue.zoom_extents vue.write_image "test.jpg" tmp.each{|e| e.hidden=false} vue.zoom_extents
-
Plugin ruby file.. How can I make from this?
Sent from my IQ 446 using Tapatalk
-
@john2 said:
Plugin ruby file.. How can I make from this?
You don't need to.
Just copy+paste all of those lines in one go, into the Ruby Console + <enter>
On MACs or PCs using at least v2014 multi-line entries are allowed. -
@john2 said:
Plugin ruby file.. How can I make from this?
Sent from my IQ 446 using Tapatalk
As simply as wrapping it in a def and end statement and copying it to the Plugins folder. Hiding/un-hiding can be a little slow.
module SDM def self.expsel2jpg mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection vue = mod.active_view @name ||= "expsel2.jpg" inp=UI.inputbox(["Image Name;"],[@name],"Export Selection to jpg") if inp @name=inp[0];@name += ".jpg" if File.extname(@name)=="" Sketchup.set_status_text "Toggling the selection";vue.refresh ent.each{|e| sel.toggle e} tmp = sel.to_a;sel.clear Sketchup.set_status_text "Hiding non-selected";vue.refresh tmp.each{|e| e.hidden=true} vue.zoom_extents vue.write_image @name Sketchup.set_status_text "Un-hiding non-selected";vue.refresh tmp.each{|e| e.hidden=false} vue.zoom_extents end end end UI.menu("Plugins").add_item("Export Selection to jpg"){SDM.expsel2jpg}
-
Not forgetting... that the file you add into the Plugins folder, must be called something like "
SDM-expsel2jpg**.rb**
" - in order for it to auto-load as SketchUp starts... AND also, equally importantly, it must be encoded as "UTF-8_without_BOM
".
On a PC -Notepad.exe
will NOT do this - it will be encoded asANSI
, this will break SketchUp >v8 !
But if you have a free tool installed likeNotepad++.exe
- then that will either encode its as you need [depending on the app's settings], OR you can at least change the file's encoding to suit using menu items.
On a Mac,TextEdit
/TextWrangler
should pre-encode the file as you need...
Advertisement