• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[Plugin] Set Arc and Circle Defaults

Scheduled Pinned Locked Moved Plugins
24 Posts 12 Posters 27.5k Views
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.
  • O Offline
    openhatch
    last edited by openhatch 1 Sept 2011, 22:45

    Name : SetArcCircleDefaults

    Description : When SketchUp loads, this script selects the circle tool and changes the number of sides to the circle (to predifined user preference), then selects the arc tool and changes the segments in the arc (also to user preference).  This way it effectively sets their "defaults" (to lower or higher numbers) according to user preference.  As this script comes "shipped", it sets the sides of a circle to 12, and the segments in an arc to 6.
    
    (The defaults for sides of a circle and segments in an arc could be directly set via SketchUp's Ruby API.. if it let you do that.  It doesn't as of SU V8.)
    
    This script requires the eventrelay plugin (windows	only at this writing), or EventRelay.dll, and includes a version of that .dll known at this writing to work.  eventrelay is available at [http://code.google.com/p/eventrelay/](http://code.google.com/p/eventrelay/)
    
    Author : Alex Hall (c) 2011
    	[http://blog.openhatch.net/contact/](http://blog.openhatch.net/contact/)
    	Released under the GNU GPL v2
    
    Installation: At this writing, and unless eventrelay is ported to the Macintosh, this plugin is for Windows only.  Copy these files into the [Sketchup Plugins directory](http://forums.sketchucation.com/search.php?keywords):
    

    EventRelay.dll
    SetArcCircleDefaults.rb
    setArcCircleDefaults-config.txt

    (For example, Google Sketchup 8's plugin directory on Windows 7 defaults to: "C:\Program Files (x86)\Google\Google SketchUp 8\Plugins" - copy these files there in that case.  Then, start Sketchup. For help finding the plugin directory look in the forums: [http://forums.sketchucation.com/search.php?keywords=plugin+folder+OR+directory](http://forums.sketchucation.com/search.php?keywords=plugin+folder+OR+directory) )
    
    Usage : To alter the "defaults" which the script sets for sides of a circle and segments of an arc, go to the "Plugins->Set Circle and Arc Segments Defaults", enter the desired values in the popup box, and click "OK".
    
    POSSIBLE CAVEAT: If you select any window besides SketchUp while SketchUp is loading, it may type key-presses to change these settings into some document or web browser text box etc. It *seems* the script avoids that by typing an inert {TAB} key, but if your set "defaults" for the Circle and Arc tool don't load with SketchUp, make sure you don't select any other windows after starting SketchUp to load.
    
    You could also modify the script to exploit any of the functionality of the eventrelay plugin.
    
    For defaults, numbers divisible by four may be advisable, as they will provide vertices at right angles along the perimiter of the circle, which makes for easy rotation and geometric snapping/angular construction.
    
    Future plans: possible exception handling for any errors related to config file.
    
    Version history:
    
    **[UPDATE]** 1.1 Revamped from scratch, incorporating suggestions by AlexMozg.  Added config storage to setArcCircleDefaults-config.txt file in plugin directory (with setting via "Plugins->Set Circle and Arc Segments Defaults" menu.)
    
    1.0 08/11 Planned updates : none.  Could have menu option to alter and store "defaults"; not programming that.  Anyone else is free to.
    

    Zip archive of files for Set Arc and Circle Defaults plugin.

    1 Reply Last reply Reply Quote 0
    • B Offline
      Bob James
      last edited by 2 Sept 2011, 05:46

      Thanks, openhatch, I'll use this often.

      i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60

      1 Reply Last reply Reply Quote 0
      • A Offline
        AlexMozg
        last edited by 2 Sept 2011, 06:24

        Without "EventRelay.dll"
        Safer to use the method "send_action" to activate the tool, because that hot keys of these tools can be modified.

        
        require 'sketchup.rb'
        unless file_loaded?(file_name = File.basename(__FILE__))
        Kernel.require 'win32ole.so'
        wscript = WIN32OLE.new("WScript.Shell")
        Sketchup.send_action	"selectCircleTool;"
        UI.start_timer(0, false){
        	for key in %w|12 {ENTER}| ; wscript.SendKeys key; end
        	UI.start_timer(0, false){
        		Sketchup.send_action	"selectArcTool;"
        		UI.start_timer(0, false){
        			for key in %w|6  {ENTER}| ; wscript.SendKeys key; end
        			UI.start_timer(0, false){Sketchup.send_action	"selectSelectionTool;"}
        		}
        	}
        }
        file_loaded(file_name)
        end
        
        
        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 2 Sept 2011, 07:30

          @alexmozg said:

          Without "EventRelay.dll"
          Safer to use the method "send_action" to activate the tool, because that hot keys of these tools can be modified.

          +1

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • V Offline
            Vicspa
            last edited by 2 Sept 2011, 15:13

            Hope someone takes you up and does a menu option.

            1 Reply Last reply Reply Quote 0
            • B Offline
              Bob James
              last edited by 2 Sept 2011, 17:14

              @unknownuser said:

              Hope someone takes you up and does a menu option.

              +1

              i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60

              1 Reply Last reply Reply Quote 0
              • O Offline
                openhatch
                last edited by 2 Sept 2011, 21:12

                Ha!

                Thanks to AlexMozg for rewriting it a better way! 😄

                (I have little idea what that code actually does, BTW)

                That rewrite only ran after I found a copy of win32ole.so and dropped it into the plugins folder. The copy of the file I found was linked from this thread.

                Is that file what I should use then (or is it safe)?

                1 Reply Last reply Reply Quote 0
                • O Offline
                  openhatch
                  last edited by 3 Sept 2011, 07:34

                  So.. okay.. I added a plugin menu option to alter and store "defaults". 😄

                  And per suggestion, the code uses Sketchup.send_action to avoid problems of hotkeys changing.

                  I encounted an undesirable side effect with SendKeys via win32ole.so (and found the same limitation with eventrelay's SendKeyMacro): if Sketchup was loading for a while and I (for example) had a web browser open with a text box, while Sketchup was out of focus, SendKeys would type the macro (for example "12s") into the browser's text box! - appearing to make ghost typing (could be creepy for a user) but also not typing it into SketchUp's Value Control Box.. and so not changing any setting!

                  After quite a bit of frustration, and observing that strangely the second parts of the macro (for the Arc tool settings) didn't type into the web browser window, but in fact got in to SketchUp.. however those magic brackets and start_timer(s) work, they seem to alleviate it.. I finally got the error to apparently go away by placing an inert {TAB} before the macro for Circle Tool (as Circle Tool was to Arc Tool (whose settings worked), so Tab is now to Circle Tool).. blah blah 😒 but it apparently worked:

                  	UI.start_timer(0, false){
                    Sketchup.send_action   "selectSelectionTool;"
                      myEventRelay.SendKeyMacro("{TAB}")
                        UI.start_timer(0, false){
                        Sketchup.send_action   "selectCircleTool;"
                        myEventRelay.SendKeyMacro(circleSides.to_s + "s{ENTER}")
                        UI.start_timer(0, false){
                          Sketchup.send_action   "selectArcTool;"
                          UI.start_timer(0, false){
                          myEventRelay.SendKeyMacro(arcSegments.to_s + "s{ENTER}")
                            UI.start_timer(0, false){Sketchup.send_action   "selectSelectionTool;"}
                  				}
                  			}
                  		}
                  	}
                  
                  

                  Sticking with eventrelay over win32ole; it seems to load and execute faster.

                  1 Reply Last reply Reply Quote 0
                  • I Offline
                    Involute
                    last edited by 22 Nov 2011, 00:59

                    I'd love to get this to work, openhatch, but I'm unfamiliar with plugins. Can you give me some pointers (cut and paste the code to a file, save it in plugins directory, etc.)? Thanks.

                    1 Reply Last reply Reply Quote 0
                    • O Offline
                      openhatch
                      last edited by 29 Feb 2012, 00:10

                      @involute said:

                      I'd love to get this to work, openhatch, but I'm unfamiliar with plugins. Can you give me some pointers (cut and paste the code to a file, save it in plugins directory, etc.)? Thanks.

                      Sorry I missed this reply. Added to usage notes in the post is this answer:

                      Extract the files in the .zip archive to your plugins folder (for example, in Windows 7, this is usually "C:\Program Files (x86)\Google\Google SketchUp 8\Plugins"), and start Sketchup.

                      [Edit:] no, that answer is already in there under installation instructions... 😉

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        Christmended
                        last edited by 27 Feb 2015, 20:14

                        Any plans to make this work in SU2015? Mine doesn't work.

                        1 Reply Last reply Reply Quote 0
                        • R Offline
                          rustystumps
                          last edited by 2 Mar 2015, 17:51

                          Dito on the Not working in V15 of SU. Really would like this.

                          1 Reply Last reply Reply Quote 0
                          • R Offline
                            rustystumps
                            last edited by 13 Apr 2016, 18:29

                            2016 and still waiting for a Ruby Script for this. The one mentioned previous is old and the required second file is not readily downloadable.
                            I manufacture models and use the SU files to print on my Form1+ 3D printer to make masters for RTV Silicone molds so finished parts are then cast in resin plastic.
                            I need smooth arcs and curves and most, if not all, of my models have plenty of these.

                            1 Reply Last reply Reply Quote 0
                            • Dave RD Offline
                              Dave R
                              last edited by 14 Apr 2016, 00:53

                              You might want to set about writing your own script for this. The author of this plugin hasn't been active here for four years. He might have moved on to other things.

                              Etaoin Shrdlu

                              %

                              (THERE'S NO PLACE LIKE)

                              G28 X0.0 Y0.0 Z0.0

                              M30

                              %

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                thomthom
                                last edited by 14 Apr 2016, 13:37

                                Might be good to try to reach out to the developer and see if he'd be willing to open source it and put it out on GitHub. IMO that would be better than rewriting from scratch.

                                Thomas Thomassen — SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  driven
                                  last edited by 14 Apr 2016, 16:39

                                  does this work in v14 and above?

                                  I don't use PC's but I'm looking for code that does something similar to this...

                                  require 'win32ole'
                                  val =  48
                                  
                                  circle_first = UI.start_timer(1.0, true) do
                                  	if Sketchup.active_model.tools.active_tool_name != 'CircleTool'
                                  		Sketchup.send_action('selectCircleTool;')
                                  	else # run the script
                                  		WIN32OLE;;new('WScript.Shell').SendKeys("#{val}{ENTER}")
                                  		p "#{val}{ENTER}" 
                                  		UI.stop_timer(circle_first)  
                                  		arc_next = UI.start_timer(1.0, true) do
                                  			if Sketchup.active_model.tools.active_tool_name != 'ArcTool'
                                  				Sketchup.send_action('selectArcTool;')
                                  			else # run the script
                                  				WIN32OLE;;new('WScript.Shell').SendKeys("#{val/2}{ENTER}") 
                                  				p "#{val/2}{ENTER}"
                                  				UI.stop_timer(arc_next)
                                  			end 
                                  		end 
                                  	end 
                                  end
                                  

                                  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
                                  • TIGT Offline
                                    TIG Moderator
                                    last edited by 14 Apr 2016, 17:36

                                    Here is a v8...v2016 beta RBZ... of "TIG-CircleArcDefaulter"
                                    It uses different methods across the various SketchUp versions...
                                    Note that it's for Windows only...

                                    I think it works OK... 😕

                                    The defaults.txt file contains the default [new] segment counts for circles and arcs [its shipped values are 48 and 24 respectively].

                                    These are used to reset those defaults as SketchUp starts...

                                    The Plugins/Extensions menu contains a new TIG-CircleArcDefaulter submenu...

                                    Its items let you:

                                    1. Edit the defaults.txt file to set new defaults [which are then reused thereafter].
                                    2. Reset the defaults to the two values currently saved in the defaults.txt file [run this after saving your edit]...

                                    If there is positive feedback I'll publish it as a new Extension in the PluginStore...


                                    TIG-CircleArcDefaulter_v1.0.rbz

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • TIGT Offline
                                      TIG Moderator
                                      last edited by 15 Apr 2016, 14:08

                                      Here's an update on my recent beta RBZ...
                                      v2.0 of "TIG-CircleArcDefaulter"
                                      It works on v8...v2016 and it now works on both PC and MAC 🤓
                                      It uses different methods across the various SketchUp versions and OS...

                                      As with the original PC only version...

                                      The defaults.txt file contains the default [new] segment counts for circles and arcs [its shipped values are 48 and 24 respectively].

                                      These are used to reset those defaults as SketchUp starts...

                                      The Plugins/Extensions menu contains a new "TIG-CircleArcDefaulter" submenu...

                                      Its items let you:

                                      1. Edit the defaults.txt file to set new defaults [which are then reused thereafter].
                                      2. Reset the defaults to the two values currently saved in the defaults.txt file [run this after saving your edit]...

                                      If there is enough positive feedback I'll publish it as a new Extension in the PluginStore...

                                      PS: I did a post a while back about 'versines' and how to consider faceting in 3d-printing etc...
                                      http://sketchucation.com/forums/viewtopic.php?p=577465#p577465
                                      These simple snippets [" & mm] were written to let you input the radius, versine-tolerance [typically 1/1000"] and a swept-arc - and get back a corresponding segmentation suggested for the arc - since smaller radii are different from bigger objects etc...

                                      PPS: As you know, @driven is a MAC guru, and he has pointed out in a PM that users with the latest OSX [my test MAC is one OSX behind!] might have Apple trying to protect them from the sort of operations need to circumvent SketchUp's segment-defaulting as it starts up... If you do get error messages and have some system knowledge you can probably set it to be allowed, alternatively let us know because @driven probably has a work around, but that does involve using a 3rd party app that'd need shipping for MAC uses...


                                      TIG-CircleArcDefaulter_v2.0.rbz

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • TIGT Offline
                                        TIG Moderator
                                        last edited by 16 Apr 2016, 15:32

                                        Here's an update on my recent beta RBZ...
                                        v3.0 of "TIG-CircleArcDefaulter"
                                        It works on v8...v2016 and it now works on both PC and MAC 🤓
                                        It uses different methods across the various SketchUp versions and OS...

                                        It now has a trap [thanks to @driven] to ensure that the SketchUp viewport is foremost as the 'reset' is done...


                                        As with the previous version...

                                        The defaults.txt file contains the default [new] segment counts for circles and arcs [its shipped values are 48 and 24 respectively].

                                        These are used to reset those defaults as SketchUp starts...

                                        The Plugins/Extensions menu contains a new "TIG-CircleArcDefaulter" submenu...

                                        Its items let you:

                                        1. Edit: the "defaults.txt" file to set new defaults [which are then reused thereafter].
                                        2. Reset: the defaults to the two values currently saved in the "defaults.txt" file [run this after saving your edit]...

                                        If there is enough positive feedback I'll publish it as a new Extension in the PluginStore...


                                        I'll repeat the PSs [modifed]...


                                        PS: I did a post a while back about 'versines' and how to consider faceting in 3d-printing etc...
                                        viewtopic.php?p=577465#p577465
                                        These simple snippets [" & mm] were written to let you input the radius, versine-tolerance [typically 1/1000"] and a swept-arc - and get back a corresponding segmentation suggested for the arc - since smaller radii are different from bigger objects etc...


                                        PPS: @driven, the MAC guru, has pointed out that users of the latest OSX might have their Apple trying to protect them from the sort of operations need to circumvent SketchUp's segment-defaulting as it starts up...
                                        If it does this, then please follow this guidance to allow SketchUp.app access to your computer...
                                        https://support.apple.com/kb/PH21504?locale=en_US



                                        TIG-CircleArcDefaulter_v3.0.rbz

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • TIGT Offline
                                          TIG Moderator
                                          last edited by 16 Apr 2016, 18:57

                                          Here's an update on my recent beta RBZ...
                                          v4.0 of "TIG-CircleArcDefaulter"
                                          It works on v8...v2016 and it now works on both PC and MAC 🤓
                                          It uses different methods across the various SketchUp versions and OSs...

                                          It now has a MAC trap [using 'cliclick' - thanks to @driven] to ensure that your OSX doesn't try and stop its system-level resetting.


                                          As with the previous version...

                                          The defaults.txt file contains the default [new] segment counts for circles and arcs [its shipped values are 48 and 24 respectively].

                                          These are used to reset those defaults as SketchUp starts...

                                          The Plugins/Extensions menu contains a new "TIG-CircleArcDefaulter" submenu...

                                          Its items let you:

                                          1. Edit: the "defaults.txt" file to set new defaults [which are then reused thereafter].
                                          2. Reset: the defaults to the two values currently saved in the "defaults.txt" file [run this after saving your edit]...

                                          If there is enough positive feedback I'll publish it as a new Extension in the PluginStore...


                                          I'll repeat the various earlier PSs [modifed]...


                                          PS: I did a post a while back about 'versines' and how to consider faceting in 3d-printing etc...
                                          viewtopic.php?p=577465#p577465
                                          These simple snippets [" & mm] were written to let you input the radius, versine-tolerance [typically 1/1000"] and a swept-arc - and get back a corresponding segmentation suggested for the arc - since smaller radii are different from bigger objects etc...


                                          PPS: @driven, our bestest MAC guru, has pointed out that users of the latest OSX might have their Apple trying to protect them from the sort of operations need to circumvent SketchUp's segment-defaulting as it starts up...
                                          This version should circumvent this, if it does not please let us know, in the meanwhile see this...
                                          https://support.apple.com/kb/PH21504?locale=en_US



                                          TIG-CircleArcDefaulter_v4.0.rbz

                                          TIG

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

                                          Advertisement