sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Importing and placing components

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 299 Views 4 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.
    • RichMorinR Offline
      RichMorin
      last edited by

      I'm writing a Ruby script that (using AppleScript) causes SU to start up, open a file containing a "wall" (10' x 10' x 1' box), and import a component file. This all works, except that I don't know how to place the component against the wall.

      Clues?

      -r

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

        Perhaps get it to set a flag [$xxx] so you know that it's done something.
        Then when your model opens it finds the component by its name [defn] and then uses - for example:

        model=Sketchup.active_model
        defn=model.definitions[your_components_name]
        tr=Geom;;Transformation.new(your_required_point_on _the _wall)
        model.active_entities.add_instance(defn,tr)
        

        TIG

        1 Reply Last reply Reply Quote 0
        • RichMorinR Offline
          RichMorin
          last edited by

          Thanks, TIG! That almost works.

          If I just run the script, the component never shows up. However, if I click on the border of the main SU window (using the mouse), the component appears in the specified location. So, what do I have to do to mechanize the mouse click?

          -r

          1 Reply Last reply Reply Quote 0
          • RichMorinR Offline
            RichMorin
            last edited by

            Hmmm. I just tried a sleazy hack which seems to work:

            
                model.active_entities.add_instance(defn, tran)
                Sketchup.send_action('selectSelectionTool;')
            
            

            Selecting the Selection Tool seems to "wake up" SU, causing it to place and display the component without any user action.

            -r

            1 Reply Last reply Reply Quote 0
            • scottliningerS Offline
              scottlininger
              last edited by

              Not sure if this would do the same, but you might try view.refresh.

              http://code.google.com/apis/sketchup/docs/ourdoc/view.html#refresh

              Cheers,

              • Scott Lininger
                SketchUp Software Engineer
                Have you visited the Ruby API Docs?
              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @unknownuser said:

                Not sure if this would do the same, but you might try view.refresh.

                http://code.google.com/apis/sketchup/docs/ourdoc/view.html#refresh

                Cheers,

                That isn't meant to be used within Tools? Thought most view methods where.
                (might also be worth noting that it's 7.1 - so you'd still need another workaround for older versions - if this method if working.)

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

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

                  You have exited your Tool so the View refreshes...
                  selectSelectionTool changes to that tool...
                  No hack... No magic involved... β˜€

                  TIG

                  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