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.
    • 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
              • D Offline
                driven
                last edited by

                static text 1

                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:

                    "HP Photosmart C5100 series"
                  

                  lol..weird.

                  @unknownuser said:

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

                  i'm trying out UI Browser.
                  http://pfiddlesoft.com/uibrowser/

                  seems sweet
                  but i didn't realize apple had some built-in stuff for gui scripting.

                  this gui stuff is kind of a pain though.. i wish sketchup would get a little applescript dictionary going..
                  i wonder how hard it would be for google to implement?

                  thing is, i've yet to get any of the errors you're showing on either of my machines but they both have lion on them..
                  i don't know what to do about making it compatible for everyone.. ❓

                  dotdotdot

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

                    @driven said:

                    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.

                    that's the problem.. applescript won't wait for OK of any of the dialog boxes other than it's own.. it's only concerned with making it's way through itself and doesn't pay attention to anything else going on.

                    if i were to put an on click ok in there, it would throw up it's own dialog box which the user would also have to click on..

                    ie- set your paper size then click ok in the page set up dialog.. (but clicking on anything other than the applescript dialog will bring it into focus instead.. the second 'ok' — the applescript 'ok'-- you'd have to push is now behind the sketchup window..
                    no good.

                    dotdotdot

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

                      fwiw, this is a typical response about people wanting to wait for user input etc..

                      Error - Page Not Found - Apple Community

                      The page you tried was not found. You may have used an outdated link or may have typed the address (URL) incorrectly.

                      favicon

                      (discussions.apple.com)

                      i probably read 4 hrs worth of stuff on this issue alone and no one, even the experts, have any sort of easy solution.. it's always 'use multiple scripts' or 'don't even try it' or 'set up a timer' etc..

                      but i'm new and retarded so i kept trying and found a way to do it with 3 lines..
                      i posted at some other places to see why this hasn't been done before and i'm awaiting some responses.. maybe it has been tried but there's a reason i shouldn't be doing it?

                      dotdotdot

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

                        it works once you grab the right element, I'm surprised it's 2 on yours and 1 here, that could be a hurdle...

                        BTW. this is the 'soft start' I normally use,
                        %(#4000FF)[on run
                        try
                        tell application "System Events"
                        if (count (every process whose name is "Sketchup")) = 0 then
                        activate application "SketchUp"
                        delay 1
                        end if
                        tell application "System Events"
                        ignoring application responses
                        tell process "SketchUp"
                        set frontmost to true
                        delay 1
                        try]

                        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:

                          it works once you grab the right element, I'm surprised it's 2 on yours and 1 here, that could be a hurdle...

                          oh wait, i see what's going on.. phew ☀

                          i've been doing all the tests with no printer selected.. if you select a printer then a static text item will display underneath the printer popup -displaying the printer name -which makes that static text 1 and the paper size static text 2..

                          so i can just identify it in the same way i did the sketchup window # (which changes depending on how many plugin toolbars etc you have showing)

                          dotdotdot

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

                            @driven said:

                            BTW. this is the 'soft start' I normally use,
                            %(#4000FF)[on run
                            try
                            tell application "System Events"
                            if (count (every process whose name is "Sketchup")) = 0 then
                            activate application "SketchUp"
                            delay 1
                            end if
                            tell application "System Events"
                            ignoring application responses
                            tell process "SketchUp"
                            set frontmost to true
                            delay 1
                            try]

                            is that something i should be able to paste into applescript editor and run from there?
                            i think there are some ends or tells or something missing 😄
                            those are the things that slow me down on this stuff.. getting all of that in the right place.. it'd be a lot easier if i knew what i was doing 😄

                            dotdotdot

                            1 Reply Last reply Reply Quote 0
                            • pbacotP Offline
                              pbacot
                              last edited by

                              Jeff,

                              Does this do anything for resolution or anti-aliasing? I find (just testing with print pdf) that exporting 2d graphic or using LO always gives an acceptable print, whereas a straight print out of SU does not. So I wonder if this scripting work of yours can be of use to me?
                              Another thought. A guy created a printing utility script for my Mac CAD program and it enabled printing of sheets (these are basically layer setups), providing a dialog to select the ones you want. It then ran prints of all those you selected. One was also able to save certain sets of print parameters, such as "save as pdf" and naming the files. Similarly perhaps you can batch print scenes in SU, which seem equivalent as both are a program-specific setup.

                              Peter

                              MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

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

                                @pbacot said:

                                Jeff,

                                Does this do anything for resolution or anti-aliasing? I find (just testing with print pdf) that exporting 2d graphic or using LO always gives an acceptable print, whereas a straight print out of SU does not. So I wonder if this scripting work of yours can be of use to me?

                                no, nothing to do with that type of stuff.. it's mainly about getting a to-scale print out of sketchup in a reasonable manner and with the drawing in sketchup looking like the print (like, if you try to print to a vertical 8.5x11 from sketchup and your drawing window is sort of widish like your screen, you'll have a wide view of the sketchup window scaled down to fit within the 8 1/2" width of the paper ... and huge borders at the top and bottom.

                                @unknownuser said:

                                Another thought. A guy created a printing utility script for my Mac CAD program and it enabled printing of sheets (these are basically layer setups), providing a dialog to select the ones you want. It then ran prints of all those you selected. One was also able to save certain sets of print parameters, such as "save as pdf" and naming the files. Similarly perhaps you can batch print scenes in SU, which seem equivalent as both are a program-specific setup.

                                Peter

                                automator would be really good for that type of stuff and simple to set up.. it has quite a few good print options for making print plugins which are then in turn available through your print dialogs..

                                but yeah, i'm not really attempting to make a smoother workflow for sketchup, i'm trying to make a script to do something that sketchup can't do.. (well,that part is already done which is sizing the drawing window to the same aspect ratio as the paper.. i guess the rest is just sort of an assistant which will, i hope, take a lot of confusion out of sketchup's printing procedures..)

                                dotdotdot

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

                                  static text 1 seems to stay the same regardless of what I choose in the other items... good?

                                  this is wrapped and still works, the ignoring only works for menu items, so I took it out

                                  on run
                                  	try
                                  		tell application "System Events"
                                  			if (count (every process whose name is "Sketchup")) = 0 then
                                  				activate application "SketchUp"
                                  				delay 1
                                  			end if
                                  			tell application "System Events"
                                  				
                                  				tell process "SketchUp"
                                  					set frontmost to true
                                  					delay 1
                                  					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 1 of sheet 1 of window drawwin
                                  						end try
                                  						
                                  					end repeat
                                  					
                                  					set papw to third text item of psz
                                  					set paph to first text item of psz
                                  					
                                  					display dialog "width = " & papw & "  height = " & paph
                                  				end tell
                                  				
                                  			end tell
                                  		end tell
                                  	end try
                                  end run
                                  
                                  

                                  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:

                                    static text 1 seems to stay the same regardless of what I choose in the other items... good?

                                    yeah.. i'll just have to make sure to click on everything and try different settings in this type of situation to make sure nothing else is popping up..

                                    thanks for trying this stuff out /catching the errors.

                                    dotdotdot

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

                                      @unknownuser said:

                                      yeah.. i'll just have to make sure to click on everything and try different settings in this type of situation

                                      you could write an applescript to do that....

                                      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

                                        found a better way to get the dock info.. this will return the actual height etc..

                                        tell application "Finder" set dockOrientation to do shell script "defaults read com.apple.dock orientation" end tell tell application "System Events" to tell process "Dock" set {dockW, dockH} to size in list 1 end tell return {dockOrientation, dockW, dockH}

                                        via:
                                        http://www.snaq.net/software/applescripts.php
                                        that stuff looks way more organized than how i'm doing it.. 😄 i'm going to have to make sense of what he's doing there and copy the way he's keeping things neat it if this print script is going to be successful.. it's already starting to get messy

                                        dotdotdot

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

                                          Hi Jeff,

                                          although your away maybe you can try this test file.

                                          after much searching, I can get Raster images to fit an A4 sheet exactly, [pixel perfect if you drawWin to {WinWidth - 4,]
                                          I used  297 and 210 for the input dialogs on the Automator version
                                          PrintTestMac.skp

                                          now for step 2, multiple sheets, that line up.... 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
                                          • D Offline
                                            driven
                                            last edited by

                                            Vector quality as good as I can get at the moment
                                            PrintTestMac_eps.pdf
                                            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
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 2 / 4
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement