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

    Copy tool --> no preview

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 4 Posters 218 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.
    • N Offline
      njeremy2
      last edited by

      @dan rathbun said:

      Here is another way which can copy multiple objects (be they components, groups, primitives, or any combination of them.)

      1) Select the component, or the selection contains anything(s) you wish to copy.

      2) Sketchup.send_action("copy:")

      3) Sketchup.send_action("paste:")

      User presses ESC to unselect the copied things. (But the MoveTool is still active afterward.)
      You can clear the selection via Sketchup.active_model.selection.clear() and then reset the original selection if you have first saved it to an array.

      All this can be done with the Edit menu options, or the Copy and Paste buttons from the Standard toolbar, or CTRL+C/CTRL+V shortcuts.

      Yeah, I think it could be a great solution but the tool i've made is really useful for people who works for making forest on sketchup for example.

      You select your first tree, activate the plugin, and put your tree everywhere you click (like the video game SIMS on computer 😜 )

      BUT I WOULD THANKS TO ALL OF YOU ! πŸ‘

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        I think there is a component spray plugin that you could use to spray trees into a model.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • N Offline
          njeremy2
          last edited by

          @dan rathbun said:

          I think there is a component spray plugin that you could use to spray trees into a model.

          yeah ! but it's not only trees πŸ˜‰

          1 Reply Last reply Reply Quote 0
          • N Offline
            njeremy2
            last edited by

            I want to put a name on each copy
            the name is store on that variable : @nameCompo

            I put that code

            newCompo = @model.place_component(@composantDef, true)
            

            I try

            newCompo.name = "#{@nameCompo}"
            

            but it didn't work

            I try also

            @model.place_component(@composantDef, true, "#{nameCompo})
            

            didn't work too...
            Can I have all parameters of "place_component" ?

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @njeremy2 said:

              Can I have all parameters of "place_component" ?

              There are only 2.

              And the API is wrong.. the method always returns the model object. (It cannot return the new component instance because there may be many off them.)

              So instead do this:

              
              before = @composantDef.instances.to_a
              toolset = Sketchup.active_model.tools
              @model.place_component(@composantDef, true)
              tid = UI.start_timer(1.0,true){
                if toolset.active_tool_id != 21013
                  UI.stop_timer(tid)
                  after = @composantDef.instances.to_a - before
                  after.each {|inst| inst.name = @nameCompo }
                end
              }
              
              

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • N Offline
                njeremy2
                last edited by

                @dan rathbun said:

                @njeremy2 said:

                Can I have all parameters of "place_component" ?

                There are only 2.

                And the API is wrong.. the method always returns the model object. (It cannot return the new component instance because there may be many off them.)

                So instead do this:

                
                > before = @composantDef.instances.to_a
                > toolset = Sketchup.active_model.tools
                > @model.place_component(@composantDef, true)
                > tid = UI.start_timer(1.0,true){
                >   if toolset.active_tool_id != 21013
                >     UI.stop_timer(tid)
                >     after = @composantDef.instances.to_a - before
                >     after.each {|inst| inst.name = @nameCompo }
                >   end
                > }
                > 
                

                I'm gonna try this now, I will tell you again when it's working πŸ˜›

                1 Reply Last reply Reply Quote 0
                • N Offline
                  njeremy2
                  last edited by

                  Dan, if you were a girl, I could fall in love with you !!!

                  It's working !

                  Thanks to Dan and TIG !!

                  If you need a help from me for Sketchup, ask me πŸ˜‰ I'm a professional almost ! lol

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Instead of a timer, wouldn't DefinitionObserver.onComponentInstanceAdded be better..?
                    https://developers.google.com/sketchup/docs/ourdoc/definitionobserver#onComponentInstanceAdded

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

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @thomthom said:

                      Instead of a timer, wouldn't DefinitionObserver.onComponentInstanceAdded be better..?
                      https://developers.google.com/sketchup/docs/ourdoc/definitionobserver#onComponentInstanceAdded

                      He is a month-old newbie.. I didn't want to go into observers with him yet.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        njeremy2
                        last edited by

                        @dan rathbun said:

                        @thomthom said:

                        Instead of a timer, wouldn't DefinitionObserver.onComponentInstanceAdded be better..?
                        https://developers.google.com/sketchup/docs/ourdoc/definitionobserver#onComponentInstanceAdded

                        He is a month-old newbie.. I didn't want to go into observers with him yet.

                        πŸ‘ right ! thanks πŸ˜„

                        not "month-old", I'm "week-old" newbie ! πŸ˜‰

                        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