[Plugin] Add Icons [for all SU files on mac]
-
what does this return on retina...
UI;;WebDialog;;new.screen_scale_factor
john
-
UI::WebDialog::new.screen_scale_factor
2.0 -
-
if you paste the code block below first, then
JcB::SetWindowSize::Change.set_2_square
does it 'go' square?
then up arrow in 'Ruby Console' >> return
does it revert?=begin Copyright 2015, john@drivenupthewall.co.uk All Rights Reserved - for now... =end module JcB module SetWindowSize class Change @plist = (ENV["XPC_SERVICE_NAME"]).split('.')[0..-2].join('.') @scale = UI;;WebDialog;;new.screen_scale_factor.to_f #----------------------------------------------------------------------------------------# def self.vpw Sketchup.active_model.active_view.vpwidth / @scale end #----------------------------------------------------------------------------------------# def self.vph Sketchup.active_model.active_view.vpheight / @scale end #----------------------------------------------------------------------------------------# def self.win_read %x(defaults read #{@plist} "NSWindow Frame SketchUpDoc") end #----------------------------------------------------------------------------------------# def self.frame_read %x(defaults read #{@plist} "Sketchup.MainFrameSize") end #----------------------------------------------------------------------------------------# def self.win_write(arry) %x(defaults write #{@plist} "NSWindow Frame SketchUpDoc" #{arry}) end #----------------------------------------------------------------------------------------# def self.frame_write(hash) %x(defaults write #{@plist} "Sketchup.MainFrameSize" -string "#{hash}") end #----------------------------------------------------------------------------------------# def self.su_window win_read.chomp!.split(' ').map{|e| e.to_i} end #----------------------------------------------------------------------------------------# def self.main_frame frame_read.chomp!.gsub(/[\{\}]/, '').split(', ').map{|e| e.to_i} end #----------------------------------------------------------------------------------------# SUD = win_read.dup.chomp! if not defined? SUD SMF = frame_read.dup.chomp! if not defined? SMF @@revert = false if not defined? SUD #----------------------------------------------------------------------------------------# def self.default_paper ##'shipped' ratios with a few international paper sizes... ratios = { 1.0=>'Square', 1.294=>'US Letter', 1.333=>'US Architectural',\ 1.414=>'A Series (ISO 216)', 1.647=>'US Legal'} type = %x(defaults read com.apple.print.PrintingPrefs DefaultPaperID) if type.include? 'Letter' ratio = 1.294 elsif type.include? 'Arch' ratio = 1.333 elsif type.include? 'iso' ratio = 1.414 elsif type.include? 'Legal' ratio = 1.647 else prompts = [($add_icon_strngs["Select your Paper Type"])] defaults = [] ratios.map{|k,v| defaults << v } choose = defaults.join(',').gsub(',', '|') input = UI.inputbox(prompts, [defaults[0]],[choose], ($add_icon_strngs[" You have no 'default' Printer set "])) if input.include? 'Letter' ratio = 1.294 elsif input.include? 'Arch' ratio = 1.333 elsif input.include? 'iso' ratio = 1.414 elsif input.include? 'Legal' ratio = 1.647 else ratio = 1 end end @ratio = ratio end #----------------------------------------------------------------------------------------# def self.process_window su_window sul = su_window[0] # left top corner suo = su_window[1] # left bottom corner suw = su_window[2] # width suh = su_window[3] # mcl = su_window[4] # mco = su_window[5] # mcw = su_window[6] # mch = su_window[7] # new_doc = "#{sul} #{suo} #{@new_width} #{suh} #{mcl} #{mco} #{mcw} #{mch}" main_frame mfa = main_frame[0] mfb = main_frame[1] mfc = main_frame[2] # width mfd = main_frame[3] new_mf = "\{\{#{mfa}, #{mfb}\}, \{#{@new_width}, #{mfd}\}\}" mod_path = Sketchup.active_model.path Sketchup.active_model.select_tool(nil) Sketchup.active_model.close_active Sketchup.send_action('closeDocument;') if not @@revert frame_write(new_mf) win_write(new_doc) @@revert = true else win_revert end mod_path != '' ? Sketchup.open_file(mod_path) ; Sketchup.send_action('newDocument;') end #----------------------------------------------------------------------------------------# def self.win_revert frame_write(SMF) win_write(SUD) @@revert = false end #----------------------------------------------------------------------------------------# def self.set_2_print default_paper @new_width = (vph * @ratio) @@revert = (vpw.between?( @new_width - 3, @new_width + 3 )) process_window end #----------------------------------------------------------------------------------------# def self.set_2_square @new_width = vph @@revert = (vpw.between?( @new_width - 3, @new_width + 3 )) process_window end #----------------------------------------------------------------------------------------# class AddIconWindowObserver < Sketchup;;AppObserver def onQuit revert = JcB;;SetWindowSize;;Change.class_variable_get(;@@revert) || false SetWindowSize;;Change.frame_write(SMF) if revert SetWindowSize;;Change.win_write(SUD) if revert end end # Attach the observer Sketchup.add_observer(AddIconWindowObserver.new) end # change #----------------------------------------------------------------------------------------# end # module end # JcB;;SetWindowSize;;Change.set_2_square
-
- up arrow >> return again
the new blank SketchUp window go square;
up arrow >> return again
the new blank SketchUp window revert its size, but goes to a new position on screen;I kept doing this, results are same: the new blank SketchUp window do go square and revert, but the position on screen is changing.
- up arrow >> return again
-
-
I draw something in the new blank SketchUp window, save the file.
the "square - revert with different position" circle goes on. -
I close SketchUp, open it again (with and without an existing file), I do 1) and 2), the result is same as 3).
-
-
-
I pasted the code, hit return
ruby console return "True"; -
JcB::SetWindowSize::Change.set_2_square, return
ruby console return "True";
and SketchUp ask me if I want to save my current work; -
I click "yes"
ruby console return the following:
Error: #<NoMethodError: undefined methodattribute_dictionary' for nil:NilClass> /Users/zz/Library/Application Support/SketchUp 2015/SketchUp/Plugins/jbb_layers_panel/rb/observers.rb:189:in
onContentsModified'
if I click "no"
ruby console return:
Error: #<TypeError: reference to deleted Attribute>
/Users/zz/Library/Application Support/SketchUp 2015/SketchUp/Plugins/jbb_layers_panel/rb/observers.rb:203:ineach' /Users/zz/Library/Application Support/SketchUp 2015/SketchUp/Plugins/jbb_layers_panel/rb/observers.rb:203:in
block in onContentsModified'
SketchUp:1:in `call'then the window of my current work is closed, while SketchUp is still running;
then I click the SketchUp icon on the Dock, a blank/new SketchUp window pops up, which is square.
- I press up arrow in ruby console then return
the new SketchUp window revert to previous size, but a little different with its position on screen.
-
-
cheers for that comprehensive testing,
Is that the latest version of jbb_layers_panel that's causing the errors?
for some reason it's observers are being triggered by closing and re-opening the SU window...
If you temporarily disable it does this code run without issue?
In Preferences, do you have 'new windows' set to 'cascade'?
If so does after deselecting that does the top corner still move?
I do have a completely different 'new' way of changing the window width, but that also needs more testing...
john
-
the latest version 1.0.2 and a previous version work same;
how to temporarily disable the observers?yes 'new windows' are set to 'cascade', deselecting this solved the window moving problem
-
@greatoe said:
the latest version 1.0.2 and a previous version work same;
how to temporarily disable the observers?I was meaning the version of 'layer panels' it's throwing those errors, if you disable it then it's observers shouldn't run...
@unknownuser said:
yes 'new windows' are set to 'cascade', deselecting this solved the window moving problem
I can turn that on and off in code so I'll add it in...
I'd forgotten that dave had that problem on another version...
-
sorry I didn't read your words carefully.
I removed jbb_layers_panel, no more error message in ruby console.
however the close/open window issue remains:
I paste the code and return
JcB::SetWindowSize::Change.set_2_square and return
SketchUp ask if I want to save my file
no matter yes or no the window is closed
I manually re-open the window, continue with up arrow return, window transform forward and backward works fine afterwards. -
@greatoe said:
SketchUp ask if I want to save my file
no matter yes or no the window is closed
I manually re-open the window, continue with up arrow return, window transform forward and backward works fine afterwards.I've been adding a catch for that as well, so it waits for you to save...
got it working for 'Unsaved' just need to add some code for modified ones as well...
john
-
here's a test version that hopefully deals with the retina and other v15 issues...
set_square and set_printer should both deal with unsaved models or changes, but you then need to re-select the option...
EDIT: removed test file
PM me if you can do any testing and I'll send you a rbz...
john -
luxurious way to add icons…nice one!however, the batch command doesnt work for me…i get the loading image, but this process continues forever. Where looks your plugin for, example, "*.skp" files?
Else, thanks!oh, i forget : im on Mac 10.7.5, and use Su13 make
-
@jojo9 said:
luxurious way to add icons…nice one!cheers, I got sick of waiting for native icons...
@unknownuser said:however, the batch command doesnt work for me…i get the loading image, but this process continues forever.
this is down to me not using v2013 anymore, and not having the time to go back in time to fix it...
@unknownuser said:Where looks your plugin for, example, "*.skp" files?
In batch mode, it should open a 'Finder' window that lets you look anywhere you want, it is best to target small collections, i.e. if I target 'Downloads' it will try process the 206 files without icons and if any are corrupt files it can crash SU, but I have also done folders with 500+ skps that I've created without any issues...
@unknownuser said:oh, i forget : im on Mac 10.7.5, and use Su13 make
that is probably the issue, the single mode should work for any SU version, and some people can run batch mode in earlier versions, so it hard to figure out the problem...
I'll try to find some time to revisit...
john
-
like to donate thru paypal. your add icons plugin works. what is your paypal address. u can pm me. Thanks.
-
i have to resize the sketchup window size to a square , if i want the thumb nail to be square. otherwise, my thumnails are always with red bands. the square button doesn't work.
also, can you change the red color to white or grey? thanks
-
Hi sketchuh,
are you still on SU v15 , which version of osx do you run and do you have a retina display?I've been doing some more work on this, but it's not quite ready...
can I PM you some test files?
john
-
yes john!
I am using sketchup 2015 on macbook pro retina 2013. and using the latest os system.
-
actually, when chose the batch mode, almost all other sktechup files would have square thumb nails, only one that is opened has red bands if the viewport is not square.
Advertisement