sketchucation logo sketchucation
    • Login
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here

    Integration tool by using paste in place

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

      @thomthom said:

      You can use the PickHelper to determine you are drawing on a face inside a group and then draw directly inside that group.

      Yes you can do that but my boss tell me that someone forget to go inside the group before drawing, that's why he asks me to do this plugin ...

      ... we have stupid sketchup users in france πŸ˜„

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

        this line doesn't work :

        inst=group.entities.add_instance(tempgroup.entities.parent, tempgroup.transformation*(group.transformation.inverse))
        

        What "transformation" module is use for ?
        Because in "Automatic Sketchup.pdf" transformation* doesn't exist.
        It's write : The transformation method is used to retrieve the transformation for the group.
        But what transformation ?

        I'm stuck here, I'm coming back tomorrow

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

          What error messages do you get ?
          Any group/instance has a transformation.
          We use it here to get the temp group into the group in the same relationships ...

          TIG

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

            @tig said:

            What error messages do you get ?
            Any group/instance has a transformation.
            We use it here to get the temp group into the group in the same relationships ...

            There is no error messages but this line isn't executed.

            %(#BF0000)[model = Sketchup.active_model
            things = model.selection.to_a
            UI.messagebox "initialization ok"

            	tempgroup=model.active_entities.add_group(things)
            	UI.messagebox "add group ok"
            	inst=group.entities.add_instance(tempgroup.entities.parent, tempgroup.transformation*(group.transformation.inverse))
            	UI.messagebox "add_instance ok"]
            

            I put messageBox each line to see if the code is executed or not.
            "add instance ok" didn't appear so I guess is not working

            Into outliner, I see the plugin create a new group for my thing which is selected but it isn't integrated inside the initial group.

            http://img204.imageshack.us/img204/7599/75074987.png

            http://img268.imageshack.us/img268/7420/addgroup.png

            http://img20.imageshack.us/img20/7563/copied.png

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

              Where in your code are you getting 'group' as a reference to the group into which you want to move the selected 'things' ?
              It will be set by picking a group with the Tool, but as a test now you can 'preselect' it earlier by highlighting the 'group' and having an extra line early on like this...
              model=Sketchup.active_model **group=model.selection[0]**
              then deselect the 'group' and select the 'things' to be added, then continuing with the code...
              things = model.selection.to_a ...
              If you do it line by line in the Ruby Console what is the result?

              I have just tested it this way and it works perfectly...

              TIG

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

                Here is my file,

                When I test it, I select my drawing which I want to add in group.
                Then this plugin create group with that drawing put it cannot execute the next line (with transform)

                I didn't test it in RUBY console into sketchup

                file reupload at 11h49 - France


                testintegration.rb

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

                  This is messed up...
                  Run it with the Ruby Console open to see all of the error messages...
                  You click the mouse-button, have a pick_helper but then set @group to be the the first item in the model.selection which is of course one of the things to be added into the 'group' ???
                  Also you haven't defined 'model' in the code so it'll fail at that step anyway...
                  Try something like this:

                  def onLButtonDown(flags, x, y, view)
                    pickHelper = view.pick_helper
                    pickHelper.do_pick(x, y)
                    allPicked=pickHelper.all_picked
                    @group = nil
                    allPicked.each{|e|@group=e if e.is_a?(Sketchup;;Group)}
                    unless @group
                      UI.messagebox("That's NOT a Group !")
                      return nil
                    end
                    self.integration()
                    Sketchup.send_action("selectSelectionTool;")
                  end
                  

                  The pick_helper stuff needs recasting...
                  I added an 'exit' to the select tool.
                  Also you should trap in 'activate' for an empty selection as they'd be nothing to tempgroup/add_ later...
                  Here's an adjusted version that works...
                  Also I'd also call the tool class something like 'Jeremy_integration_tool' ???


                  ###testintegration.rb

                  TIG

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

                    Oh wooow! thank you TIG ! πŸ˜„

                    It works great ! you are fabulous ! πŸ‘

                    When I look the code, it's different than what I tought !
                    Just a little question, if you initialise "@group=nil" is it the same if you do that : "@group=[]" ?
                    Because after picking, you put each group you found inside "@group".

                    Voila ! thank you so much πŸ˜‰

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

                      @njeremy2 said:

                      Just a little question, if you initialise "@group=nil" is it the same if you do that : "@group=[]" ?

                      No - @group=[] == @group=Array.new

                      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 must set any reference that you want to use later outside of a block - so when it is set inside the {} block it is still accessible to the rest of the code.
                        @group=nil sets an empty reference
                        BUT
                        @group=[] makes an empty array.

                        In the {} IF there's a selected group then @group is set to be it @group=e if....
                        Otherwise it stays as ' nil'.
                        Then the test
                        unless @group ...
                        says if group is ' nil' you didn't pick on a group, so we exit with a message...

                        The current code doesn't 'insert' the group into @group, it makes it its reference.
                        However, if you were 'collecting things' into an array initially made as groups=[] ... then you would use
                        groups << e if... rather than the singular @group=e if..., that way you get a 'list' of matching objects...

                        TIG

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

                          oh ok!
                          Thanks to all ! I understand now πŸ˜„

                          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