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

    Request: Automatically add ConstructionPoint at Center of Ci

    Scheduled Pinned Locked Moved Plugins
    13 Posts 7 Posters 3.3k 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.
    • JClementsJ Offline
      JClements
      last edited by

      With the type of work I do, I almost always want a construction point when drawing a circle (for aligning pipe centerlines, etc., during later stages of developing an illustration).

      Is there a way to do this automatically. when using SU's Circle tool so that a separate custom tool wouldn't have to be developed?

      If not, then a custom tool would be the next best choice (with perhaps an option in the dialog to choose a layer to assign all the "circle-center points" to during that drawing session)?

      John | Illustrator | Beaverton, Oregon

      1 Reply Last reply Reply Quote 0
      • jujuJ Offline
        juju
        last edited by

        JClements, you can have a look here ( http://www.smustard.com/script/CenterPoint ) over at Smustard or you can have a look here ( http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY_Library_Depot.htm ) and have a look around seeing that there are quite a few ruby scripts doing all sorts of things.

        Save the Earth, it's the only planet with chocolate.

        1 Reply Last reply Reply Quote 0
        • R Offline
          RickW
          last edited by

          John,

          Yes, this can be done. I'll see if I can come up with something.

          RickW
          [www.smustard.com](http://www.smustard.com)

          1 Reply Last reply Reply Quote 0
          • R Offline
            RickW
            last edited by

            I should have said, "Yes, theoretically, it can be done."
            Reality is BugSplatting 😢
            Conversing with the SU crew about the issue...

            RickW
            [www.smustard.com](http://www.smustard.com)

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              In principle you'd have some 'observer' auto-made in each model that's watching for new geometry to be added. If it forms an arc or circle a simple script adds a centre point ?

              TIG

              1 Reply Last reply Reply Quote 0
              • A Offline
                azuby
                last edited by

                Isn't is possible to observer the Circle Tool itself? Or subclassing the Circle Tool?

                azuby

                *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

                Bad English? PM me, correct me. :smile:**

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  @azuby said:

                  Isn't is possible to observer the Circle Tool itself? Or subclassing the Circle Tool?

                  azuby

                  I don't think you can observe a Tool. You can observer the Tools class.

                  But, I think by using both a ToolsObserver and a ModelObserver, you can get to where you want to be.

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    azuby
                    last edited by

                    Oh, you have to differentiate between "collection of tools" and "class of Tools"

                    The class of Tools is Class, Tools itself is a class. What you mean is the collection of one tool and one more tool -> tools (not Tools). I do mention that, because we are in the Ruby forum and Ruby programmers would come in semantic conflict by the words.

                    This is, what the spec says: "The Tools class contains methods to manipulate a collection of SketchUp tools." - that means a collection of - hm - circle tool, square tool etc. This classs do provide an add_observer method, so that you can register an object to a collection of tools, which gets notified of changes in the collection.

                    Your are right, there does not seem to be a way of registering an observer to a Tool object. Also subclassing the circle tool does not seem possible, because I can't reach the circle Tool object.

                    Maybe there is a way adding a Tools observer to the tools collection where the circle tool is in.

                    azuby

                    *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

                    Bad English? PM me, correct me. :smile:**

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      In my example, you would need a 3rd observer - EntitiesObserver - to get the entities to add the center point to.

                      The following attachment adds these 3 observers and outputs debugging info to the Ruby Console.


                      observer_ex.rb

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        not registered yet
                        last edited by

                        At jim & TIG

                        Not strictly on topic, but I'm trying to figure out how to write observers for a script of my own. I can't seem to find any kind of observer documentation anywhere; is there such thing as a formal observer? Jim's example above seems to indicate there is, and is the closest example I've got so far. So; how would I write a camera observer that calls a specific function every time the camera is moved (manually or by another tool/script)? Would that be something like "class CameraObserver < Sketchup::ModelObserver" with some camera specifc code thrown in?

                        I also need a Tools observer; how do I activate a constraint for each drawing tool based on (3Dpoint) information from the first click? Would that work better as a tool observer or a onLButtonDown action? I want something fairly efficient for this one; I don't expect the camera to be moving much for this plugin so I'd rather tie this to tools or clicks than to the camera.

                        Any suggestions, code, or links to observer documentation

                        Censored to protect your privacy Rick - I'm trying to use this for the 2D idea; any ideas or suggestions on how to best implement this?

                        [birchins]

                        1 Reply Last reply Reply Quote 0
                        • N Offline
                          not registered yet
                          last edited by

                          I usually draw the circle using the Circle Tool first and then use "Get Midpoint" because I have "midpoint.rb". 😆

                          [Invader ZIM]

                          1 Reply Last reply Reply Quote 0
                          • R Offline
                            RickW
                            last edited by

                            You want to create a view observer (not a camera observer, since those don't exist). The general form is:

                            1. create the observer, deriving from the appropriate template
                            2. attach the observer to the appropriate object

                            In your case, this would take the form of

                            class MyViewObserver < Sketchup;;ViewObserver
                              def onViewChanged(view)
                                # do stuff here
                              end
                            end
                            
                            $myViewObserver = Sketchup.active_model.active_entities.add_observer(MyViewObserver.new)
                            #assigning to a global variable is optional, but allows you to remove the observer later
                            #you could also create a class variable to store the various instances, or there are other possibilities as well
                            

                            Hope that helps...

                            RickW
                            [www.smustard.com](http://www.smustard.com)

                            1 Reply Last reply Reply Quote 0
                            • R Offline
                              RickW
                              last edited by

                              The Tools observer has some problems - "toolname" is truncated on the Mac, making it hard (or impossible) to get the active tool based on name. However, the toolid works fine.

                              class MyToolsObserver < Sketchup;;ToolsObserver
                                def onActiveToolChanged(tools,toolname,toolid)
                                  #do stuff here
                                  puts "Selected tool; #{toolid} ;; #{toolname}"
                                end
                              end
                              
                              Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
                              
                              

                              That said, to constrain drawing to a 2D plane will probably require recreating all the tools with the constraints built in. 😞

                              RickW
                              [www.smustard.com](http://www.smustard.com)

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

                              Advertisement