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

    Sketchup and ruby

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 432 Views 3 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.
    • S Offline
      sachi
      last edited by

      I want to perform a onclick action on a sketchup object to connect to a Mysql database.

      I developed a Ruby class to create sketchup objects.

      And now I want to perform an onclick action on this sketchup objects. When I Mouseclick on a sketchup object ,an onclick action will be initialized and will automatically connect to the database.
      Is this possible with Sketchup and ruby?If so, what are the necessary ruby classes and methods for this event?

      Thank you.

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

        I've moved this into the developer's forum as it'll get more appropriate attention here.
        You need to make a 'Tool' class - see the API - there are various 'onClick' methods and you use a 'pickhelper' to make a test for the user clicking on the object.
        https://developers.google.com/sketchup/docs/ourdoc/tool#onLButtonDown
        https://developers.google.com/sketchup/docs/ourdoc/pickhelper#picked_element
        The way you define the command associated with the class tells Sketchup it's a 'Tool', and you get lots of premade methods to use that are no available in 'plain' class or module...

        TIG

        1 Reply Last reply Reply Quote 0
        • K Offline
          kwalkerman
          last edited by

          Depending on what you're trying to do, you might want to look at the SelectionObserver class. You can use a SelectionObserver to perform actions based on what is selected, regardless of what tool is currently being used.

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

            If the object's 'collection' is a group or a component-instance you can set attributes for that - like an 'id' code.
            You can also attach the same 'id' attribute to any entity, so you could also 'label' each individual part too by iterating through the objects.entities ...
            See
            https://developers.google.com/sketchup/docs/ourdoc/entity
            Set the 'id' with
            entity.set_attribute("Sachi", "id", 1234567890)
            later to get an object's 'id' your pickhelper method can return the group/instance and retrieve its 'id' using
            entity.get_attribute("Sachi", "id", 0)

            TIG

            1 Reply Last reply Reply Quote 0
            • S Offline
              sachi
              last edited by

              Thank you very much TIG and kwalkerman. I have tried some simple codes.And the tool interface and pickhelper will be just fine for the task.
              But now it raised a problem. I want to select a whole sketchup entities object, as one object. So that when I click anywhere on that object (like a house or a building), the same data record will be retrieved from the database.
              The database contains a record for each house.

              Do you have any idea about this? Thank you

              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