sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [AppleScript] - Sketchup PrintRight

    Scheduled Pinned Locked Moved Plugins
    75 Posts 7 Posters 3.7k Views 7 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dave RD Offline
      Dave R
      last edited by

      Jeff, I couldn't find it because it installed under ~/Users/Jeff/Library/Services/ as John reported. Not because I couldn't understand how to use it. I followed your instructions and enabled under Assistive Devices as you described.

      Etaoin Shrdlu

      %

      (THERE'S NO PLACE LIKE)

      G28 X0.0 Y0.0 Z0.0

      M30

      %

      1 Reply Last reply Reply Quote 0
      • jeff hammondJ Offline
        jeff hammond
        last edited by

        @dave r said:

        Jeff, I couldn't find it because it installed under ~/Users/Jeff/Library/Services/ as John reported. Not because I couldn't understand how to use it. I followed your instructions and enabled under Assistive Devices as you described.

        lol.. sorry about that.. let me take that pkg down for now.. i obviously used the wrong setting in package maker and had it set up to install in the same exact place as it does on my computers..

        just download the lion version and place it manually at:
        user/library/services

        delete the user/jeff folder 😳

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          @Jeff,

          I've got it basiclly running on 10.5.8, it doesn't appear recognize 'edge' as a dock preference,
          so if I comment out

          **%(#0000FF)[get autohide of]%(#408000)[DockProp]
          		%(#808080)[--get screen edge of DockProp]
          		
          		%(#0000FF)[if autohide is true then] %(#808080)[--or screen edge is not bottom then]**
          

          it all still seems to work...
          if dock is hidden it uses the full screen height and if it's showing I get a 90px margin from bottom of model area to top of 'Dock'

          I'll try and turn it back into a 'Leopard' service next, I pulled out the workflow and have it running from Automater...

          for Leopard users
          first clean up service menu http://manytricks.com/servicescrubber/
          then it'll be easier when this is working...

          john
          john

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

          1 Reply Last reply Reply Quote 0
          • jeff hammondJ Offline
            jeff hammond
            last edited by

            @driven said:

            @Jeff,

            I've got it basiclly running on 10.5.8, it doesn't appear recognize 'edge' as a dock preference,
            so if I comment out

            **get autohide ofDockProp
            --get screen edge of DockProp

              	%(#0000FF)[if autohide is true then] %(#808080)[--or screen edge is not bottom then]**
            

            it all still seems to work...
            if dock is hidden it uses the full screen height and if it's showing I get a 90px margin from bottom of model area to top of 'Dock'

            hmm.. i think in that case, if the dock is visible but on a screen edge (mine is on the right side for instance), then there will still be space left at the bottom as it thinks there's a dock down there…

            put this in AppleScript Editor:

            tell application "System Events"
            	tell dock preferences
            		get properties
            	end tell
            end tell
            

            and it will report which which preferences are recognizable :
            (on lion, i get this)

            screen 2011-12-09 at 1.56.19 PM.jpg

            dotdotdot

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              this is 10.5.8 list,

              where I started from as well... {minimize effect:scale, dock size:1.0, location:bottom, magnification:false, class:dock preferences object, magnification size:0.5, animate:true, autohide:true}
              or {minimize effect:scale, dock size:1.0, location:left, magnification:true, class:dock preferences object, magnification size:0.517857134342, animate:false, autohide:false}
              right being the other location...

              when NOT hidden, with the commented out version it just pushes it sideways 90px, either left, right or up...

              what happens when you leave it out on Lion?

              john

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

              1 Reply Last reply Reply Quote 0
              • jeff hammondJ Offline
                jeff hammond
                last edited by

                not sure.. I'm on a phone now.
                I'll chage it to where it checks for location or screen edge instead of just screen edge.
                i guess at this point, I'm mostly concerned with the aspect ratio showing up properly.

                an easy way to check is by setting the paper height and width to the same size (square) the using the shift-cmmd-4 screenshot cursor to manually measure the drawing area.

                dotdotdot

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  been doing exactly that, and it's square... john

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

                  1 Reply Last reply Reply Quote 0
                  • jeff hammondJ Offline
                    jeff hammond
                    last edited by

                    @driven said:

                    been doing exactly that, and it's square... john

                    sweet!

                    I figured out how to get into the print dialogs so I should be able to get the rest of my ideas implemented.
                    going to SF tmmr for a week so I might not get an update out super soon.

                    dotdotdot

                    1 Reply Last reply Reply Quote 0
                    • jeff hammondJ Offline
                      jeff hammond
                      last edited by

                      @edson said:

                      besides, can the units be changed to metric?

                      hey Edson, i have a question about the metric deal..
                      if you go File -> Page Setup… , are those units still being displayed in inches on your machine?

                      screen 2011-12-09 at 6.29.31 PM.jpg

                      and if you hover your mouse over the dimensions, is the popup showing your border settings also in inches?

                      for me, it always reports in inches regardless of my unit settings while the File->Document Setup… will show metric if i change units to metric..

                      if your page setup is showing metric then it must be at setting at the system level that i can't figure out yet.. but i do know that if i print with another app that uses the same "Page Setup… " (iWork's Pages for instance), the units are also in inches and i assume an apple app wouldn't force everyone to work in inches..
                      thanks

                      [EDIT] -- nevermind, found it 😄

                      System Prefs-> Language & Text-> Formats-> Measurement Units

                      screen 2011-12-09 at 6.43.55 PM.jpg

                      dotdotdot

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by

                        Jeff,

                        I did some unit test, and if I draw a parallel projection, top view rectangle, the same size as an A4 297mm, 210mm sheet of paper.

                        then input width 297, height 210 in the dialogs, I get SU resized around my drawing with height margins 27px and width margins of 40px [one per side...]

                        I get the same if I change model units to inches, and/or the input to inches, I not sure the units make any odds? as long as there proportional.

                        I can't loose that margin... john

                        EDIT: unless I use export to PDF use view size, I get a full page PDF from Preview for printing, borderless...
                        EDIT: that doesn't work.....

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

                        1 Reply Last reply Reply Quote 0
                        • jeff hammondJ Offline
                          jeff hammond
                          last edited by

                          right, the actual units being used won't matter for setting the aspect ratio.. there will probably be some dialogs eventually (or maybe a summary) so i'll check if the user is US or metric for that display..

                          i almost have it working now without the dialogs, the script is pulling the paper dimensions from the 'page setup...' dialog.
                          maybe one more session with it tonight and i'll get that part hooked up

                          dotdotdot

                          1 Reply Last reply Reply Quote 0
                          • jeff hammondJ Offline
                            jeff hammond
                            last edited by

                            @driven said:

                            EDIT: unless I use export to PDF use view size, I get a full page PDF from Preview for printing, borderless...
                            EDIT: that doesn't work.....

                            right.. that's an example of why i want to do this thing..
                            if you want to print borderless, you have to make sure the paper/pdf has no borders set (which you can do via 'page setup->paper size->manage custom sizes.. -or- if you have the right printer type in your list, you'll have a few borderless options..

                            it's super confusing when first trying to figure all this out in sketchup and unnecessarily complicated (three different windows/dropdowns which all have an effect on your final output plus the fact that sketchup prints the entire drawing window but it doesn't have any way to make your drawing window and paper the same size).. so my goal is to make this a lot easier..

                            ie- you want a borderless 8 1/2 x 11? use this script and do it right the first try etc..
                            we'll eventually see if it's successful 😄 (fingers crossed)
                            [and if it is successful, i hope to show it to the google devs as an example of how sketchup should/could work 💚 ]

                            dotdotdot

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              driven
                              last edited by

                              I've been trying to get scale printing sorted forever, including lots of tests for GSuT, it's a pain, however I do like applescript so I'll help out where I can...

                              Figuring out those margins is the issue... john

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

                              1 Reply Last reply Reply Quote 0
                              • jeff hammondJ Offline
                                jeff hammond
                                last edited by

                                hmm.. so i'm running into some problems trying to do some things with applescript.. basically, it can't wait for the user to do something..
                                so for me to actually get this thing working as i would like it to, i'd have to have multiple scripts..

                                one possibility (i think) would be doing it via ruby (with the help of the local's of course 😄 )

                                do you think something like this is possible?

                                • start the ruby
                                • (maybe use it for some user input/ parameters)
                                • ruby activates and gives the parameters to applescript(1)
                                • the script does it's thing to the end but ruby is watching over everything..
                                • the user does something (say a keystroke or clicks an 'ok' button or something) which the ruby sees then activates
                                  applescript(2)..
                                • etcetc..

                                might be a little more intense than what i'm willing to do but wandering just in case..

                                dotdotdot

                                1 Reply Last reply Reply Quote 0
                                • jeff hammondJ Offline
                                  jeff hammond
                                  last edited by

                                  actually, i may have just found a workaround.. everything i've read so far has said it's impossible to make something like this happen in applescript but this is more/less working.. it fails maybe 1 out of 15 times but i think i can mess with it some more to get it consistent..

                                  try this in the AppleScript editor.. (with sketchup running and a su window present)

                                  tell application "SketchUp"
                                  	activate
                                  	tell application "System Events" to tell process "SketchUp"
                                  		
                                  		set drawwin to count of windows
                                  		set AppleScript's text item delimiters to {" "}
                                  		
                                  		click menu item "page setup..." of menu "file" of menu bar 1
                                  		
                                  		
                                  		
                                  		repeat until focused of window drawwin = true
                                  			try
                                  				set psz to value of static text 2 of sheet 1 of window drawwin
                                  			end try
                                  			
                                  		end repeat
                                  		
                                  		
                                  		
                                  		
                                  		set papw to first text item of psz
                                  		set paph to third text item of psz
                                  		
                                  		display dialog "width = " & papw & "
                                  height = " & paph
                                  		
                                  	end tell
                                  end tell
                                  

                                  it lets the user update their paper size while the script is still running and updating the variables according to the user's latest selection... then , when ok is pushed, the script continues along (well, in this case, it just show which numbers were pulled from the page setup..

                                  i left some of the other stuff out of this post (determining paper orientation etc..) ... this is just illustrating that i may in fact be able to get all of this stuff into a single service.

                                  dotdotdot

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    driven
                                    last edited by

                                    fails here

                                    get focused of window 16 of process "SketchUp" true "Can’t get text item 3 of \"\"."

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

                                    1 Reply Last reply Reply Quote 0
                                    • jeff hammondJ Offline
                                      jeff hammond
                                      last edited by

                                      @driven said:

                                      fails here

                                      get focused of window 16 of process "SketchUp" true "Can’t get text item 3 of \"\"."

                                      hmm.. that's weird.. if it's getting to the text item3 part then it's making it through the 'wait' sequence which is what i was having problems with.. getting the text items was the easy part.

                                      i'm not sure why it's failing to get the text item.. maybe thetext item delimiters aren't in leopard?
                                      [seriously just a guess... or maybe your 'page setup' looks different than lions? (as shown in my earlier post questioning the metric/us settings)... i'll look into it..

                                      dotdotdot

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        driven
                                        last edited by

                                        second time I got this
                                        %(#4000FF)[get value of static text 2 of sheet 1 of window 16 of process "SketchUp"
                                        "HP Photosmart C5100 series"
                                        get focused of window 16 of process "SketchUp"
                                        true
                                        display dialog "width = HP
                                        height = C5100"
                                        «event ascrgdut»
                                        {}
                                        display dialog "width = HP
                                        height = C5100"]

                                        do you use 'Accessibility Inspector' to help pick your targets, can be useful

                                        %(#404080)[<AXApplication: “SketchUp”>
                                        <AXWindow: “Untitled - SketchUp Pro”>
                                        <AXSheet: “Page Setup”>]
                                        <AXPopUpButton: “A4”>
                                        %(#404080)[Attributes:
                                        AXRole: “AXPopUpButton”
                                        AXRoleDescription: “pop up button”
                                        AXHelp: “(null)”
                                        AXEnabled: “true”
                                        AXFocused (W): “false”
                                        AXParent: “<AXSheet: “Page Setup”>”
                                        AXWindow: “<AXWindow: “Untitled - SketchUp Pro”>”
                                        AXTopLevelUIElement: “<AXSheet: “Page Setup”>”
                                        AXPosition: “x=982 y=192”
                                        AXSize: “w=216 h=26”
                                        AXValue: “A4”
                                        AXChildren: “<array of size 0>”

                                        Actions:
                                        AXShowMenu - show menu
                                        AXPress - press]

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

                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          driven
                                          last edited by

                                          grabbing the wrong text, here. dialogs the same on Leopard.
                                          I get this

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

                                          1 Reply Last reply Reply Quote 0
                                          • D Offline
                                            driven
                                            last edited by

                                            what about a simple 'on click OK', list all text items, then pick the ones you want.

                                            you don't need the repeater then, the final click is your next step.

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

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 4 / 4
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement