[Plugin] Add Icons [for all SU files on mac]

[Plugin] Add Icons [for all SU files on mac]

Postby driven » Wed Feb 18, 2015 12:15 am

this has been evolving for a long while, but here it is...
I have now added it to the plugin store...

Download

or visit the Plugin Store for a little more info...
If you have any other versions you should upgrade after a manual 'move to trash' of the older files...
The manual deletion is required as I changed a lot of the filenames...
batch_icons2.gif

2015-02-19 07.15.35 pm.png

please give feedback, so i can put this to bed, before my wife kills me...

v1.0.2: updated to fix v8 ruby bugs...
changed the Toggling of windows size to enhance the process...

john
0
Last edited by driven on Thu Feb 19, 2015 8:12 pm, edited 4 times in total.
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby Dave R » Wed Feb 18, 2015 3:23 am

Excellent work, sir!
0
Etaoin Shrdlu


%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Wed Feb 18, 2015 3:51 am

cheers dave,

don't know why I cant find it in the plugin store yet...

I probably did something amiss loading the details...

I'll chase it up tomorrow...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby Dave R » Wed Feb 18, 2015 3:53 am

Go to bed and worry about it when the sun is shining. Or at least supposed to be shining. ;)
0
Etaoin Shrdlu


%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby gilles » Wed Feb 18, 2015 10:14 am

I get this loading SU:

Error Loading File jcb_Add_Icon.rb
undefined method `[]' for #<LanguageHandler:0x10ccfca8 @strings={}>


SU V 8.0.14345
0
" c'est curieux chez les marins ce besoin de faire des phrases "
User avatar
gilles 
Top SketchUcator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby Rich O Brien » Wed Feb 18, 2015 10:41 am

@john

you don't go live until this is green.

PicPick-014.png


it allows you to pull down or publish extensions whenever you wish.
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Wed Feb 18, 2015 2:58 pm

gilles wrote:I get this loading SU:

Error Loading File jcb_Add_Icon.rb
undefined method `[]' for #<LanguageHandler:0x10ccfca8 @strings={}>


SU V 8.0.14345

cheers gilles,

I recently changed it to use 'langhandler' for translations, but forgot 'langhandler' changed at v14...

As a test, could you try this from 'Ruby Console'
EDIT: code is now added to v1.0.2...

Add Icon should then work...
john
0
Last edited by driven on Thu Feb 19, 2015 8:00 pm, edited 1 time in total.
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Wed Feb 18, 2015 7:43 pm

@gilles

I found a few other v8 issues which I've 'almost' sorted out...


can I PM you another version, when done?

the making of icons is working, but the window resizing [used for improving them] needs a tweak...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Wed Feb 18, 2015 11:33 pm

driven wrote:this has been evolving for a long while, but here it is...
I have now added it to the plugin store...
 DOWNLOAD 
If you have any other versions you should upgrade after a manual 'move to trash' of the older files...
The manual deletion is required as I changed a lot of the filenames...
batch_icons2.gif


please give feedback, so i can put this to bed, before my wife kills me...

v1.0.2: updated to fix v8 ruby bugs...
changed the Toggling of windows size to enhance the process...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby Rich O Brien » Thu Feb 19, 2015 5:16 pm

driven wrote:this has been evolving for a long while, but here it is...
I have now added it to the plugin store...

Download



If you have any other versions you should upgrade after a manual 'move to trash' of the older files...
The manual deletion is required as I changed a lot of the filenames...
batch_icons2.gif


please give feedback, so i can put this to bed, before my wife kills me...

v1.0.2: updated to fix v8 ruby bugs...
changed the Toggling of windows size to enhance the process...

john
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby gilles » Thu Feb 19, 2015 6:57 pm

The symlink is there but no change, error when loading.

Pm me any version you want to test with SU8. :thumb:
0
" c'est curieux chez les marins ce besoin de faire des phrases "
User avatar
gilles 
Top SketchUcator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Thu Feb 19, 2015 7:04 pm

@gilles,

I got v8 back up and running so the new v1.0.2 in the Plugins Store should now work...

can you test it to make sure?

I also have a translation plugin if you want to try it?

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby gilles » Fri Feb 20, 2015 9:16 am

driven wrote:@gilles,

I got v8 back up and running so the new v1.0.2 in the Plugins Store should now work...

can you test it to make sure?

I also have a translation plugin if you want to try it?

john


It does not work.

inside jcb_Add_Icon.rb I read: add_icons_on_mac.version = '1.0.1'
0
" c'est curieux chez les marins ce besoin de faire des phrases "
User avatar
gilles 
Top SketchUcator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Fri Feb 20, 2015 1:01 pm

gilles wrote:...inside jcb_Add_Icon.rb I read: add_icons_on_mac.version = '1.0.1'


oops... I just re-uploaded, and then downloaded the .rbz to check that it is now the 1.0.2 version...

sorry about that...
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby gilles » Fri Feb 20, 2015 7:35 pm

Sorry,

Erreur de chargement du fichier jcb_Add_Icon.rb
undefined method `[]' for #<LanguageHandler:0x10bccff4 @strings={}>

Don't pull out your hairs. :mrgreen:
0
" c'est curieux chez les marins ce besoin de faire des phrases "
User avatar
gilles 
Top SketchUcator
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Fri Feb 20, 2015 7:39 pm

gilles wrote:Don't pull out your hairs. :mrgreen:

I've got quite a lot, and it's working on v8 for me so it's some silly uploading issue...
I'll PM my copy
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Fri Mar 20, 2015 5:08 pm

For the latest version 1.0.2, I noticed that a solid white colour is added to the backgound of the icon, and if my SketchUp window is not square, red bars will be added to the top and bottom, or left and right of the icon.

The "set window to square" button/function seems not working, I'm on SketchUp 2015 and OS X 10.10.3.

I was using an early version of your script, and was pleased with it while it generates icons with transparent background.

When I wanted to generate an icon, I use a window management tool (named Window Tidy) to set my SketchUp window to nearly (but not exactly) square to have the best icon result.

May I ask for the transparent background back, and get rid of the red bars?

The old version I use was running good, but I do like the batch function of adding icons to Layout files and skm file.
0

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Fri Mar 20, 2015 5:31 pm

hi

I added the 'Red' banding so you can quickly see that a 'better' icon is available by using 'Make Square',

I am looking at adding some user preferences that will let you set the band color to any or transparent...

but first, get 'Set Square' working is quite critical...

It may be a locale issue, do you use 'en-US' for SU or other...

if you could run a couple of test's in 'Ruby Console' we can try and work out the issue...
use 'Select All' >> Copy >> Paste in 'Rudy Console' >> hit 'Enter/Return'
Code: Select all
    class  Change

    @plist = (ENV["XPC_SERVICE_NAME"]).split('.')[0..-2].join('.')

#----------------------------------------------------------------------------------------#

    def self.vpw
      Sketchup.active_model.active_view.vpwidth
    end

#----------------------------------------------------------------------------------------#

    def self.vph
      Sketchup.active_model.active_view.vpheight
    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

#----------------------------------------------------------------------------------------#
type = %x(defaults read com.apple.print.PrintingPrefs DefaultPaperID).chomp!
p Sketchup.get_locale
p @plist
p SUD
p SMF
p [vpw, vph]
p type
nil
end
this should return your machines version of this...
"en-US"
"com.sketchup.SketchUp.2015"
"189 651 977 526 0 0 1920 1177 "
"{{37, 608}, {977, 569}}"
[977, 473]
"iso-a4"

and hopefully show me what's going wrong...
if you can paste that info back here, that a start...

I'm working on batch mode at the moment as there are issues with versions other than v2015...
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Sat Mar 21, 2015 1:27 am

hi john,

here's the result:

"en-US"
"com.sketchup.SketchUp.2015"
"73 40 1810 1137 0 0 1920 1177 "
"{{73, 4}, {1810, 1173}}"
[3620, 2124]
nil

ps. I'm on a 15" retina display macbook pro.
0

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Sat Mar 21, 2015 1:39 am

cheers,

I think I see the issue, SU shows the 'retina' values but system shows 'traditional' sizes...
in yours this two double...
"{{73, 4}, {1810, 1173}}"
[3620, 2124]
on mine it stays the same...
"189 651 977 526 0 0 1920 1177 "
"{{37, 608}, {977, 569}}"
[977, 473]

I need to add a check for retina, and will post a test file...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Sat Mar 21, 2015 1:47 am

what does this return on retina...
Code: Select all
UI::WebDialog::new.screen_scale_factor

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Sat Mar 21, 2015 1:57 am

> UI::WebDialog::new.screen_scale_factor
2.0
0

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Sat Mar 21, 2015 2:00 am

greatoe wrote:2.0


excellent...

I'll add that inn

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Sat Mar 21, 2015 2:08 am

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?
Code: Select all
=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

0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Sat Mar 21, 2015 4:24 am

1) I pasted the code, hit return
ruby console return "True";

2) JcB::SetWindowSize::Change.set_2_square, return
ruby console return "True";
and SketchUp ask me if I want to save my current work;

3) I click "yes"
ruby console return the following:
Error: #<NoMethodError: undefined method `attribute_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:in `each'
/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.

4) 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.
0
Last edited by greatoe on Sat Mar 21, 2015 4:39 am, edited 1 time in total.

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Sat Mar 21, 2015 4:32 am

5) 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.
0

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Sat Mar 21, 2015 4:38 am

6) I draw something in the new blank SketchUp window, save the file.
the "square - revert with different position" circle goes on.

7) I close SketchUp, open it again (with and without an existing file), I do 1) and 2), the result is same as 3).
0

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Sat Mar 21, 2015 11:35 am

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
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby greatoe » Sat Mar 21, 2015 4:32 pm

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
0

greatoe 
 

Re: [Plugin] Add Icons [for all SU files on mac]

Postby driven » Sat Mar 21, 2015 4:46 pm

greatoe wrote: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...
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...
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: mvm1990 and 18 guests

Visit our sponsors: