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

    How do you make plug-ins for sketchup

    Scheduled Pinned Locked Moved Developers' Forum
    103 Posts 25 Posters 9.0k Views 25 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      then change it around and make it erase all faces instead of pushpulling them πŸ˜„

      Chris

      Edit: you literally just copied and pasted, awesome!

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • B Offline
        BTM
        last edited by

        That's good, but my main issue (which I've been trying to figure out) is how to use the cursor to set the transformation, like the move tool does; click and drag. I thought I saw something on it once, but am still confused.

        *I started writing this before remus's post. I see you used the 'selection' method, I guess that would fix the whole pushpull-resulting-faces issue I had.(that's what they're called, methods, right? I can never remember...)

        *I started that last part before Chris posted πŸ˜’ and Chris, why won't it work to just replace e.pushpull 10 with e.clear! ?

        1 Reply Last reply Reply Quote 0
        • B Offline
          BTM
          last edited by

          ...but I DID manage to get it to reverse faces πŸ˜‰

          model = Sketchup.active_model
          selection = model.active_entities
          #  -  -  -  -  -  -  -  -  -  -  -  -
             selection.each { |entity|
                if entity.typename == "Face"
                entity.reverse!
             end
          }
          

          Why does reverse! work, but not clear! ?

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

            give em some credit chris, i had to type 'selection' as well πŸ˜„

            http://remusrendering.wordpress.com/

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              πŸ˜„

              .clear! will empty an array, it does not erase anyhing from the model. Glad you found the erase! method.

              You can also go through and put everything to erase into an array of entities, then use

              entities.erase_entities my_array_of_entities

              to delete them all in one shot. Apparently some people have ran into bugsplats when erasing entities one at a time like you've done in your example.

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • B Offline
                BTM
                last edited by

                ...Nevermind. I found in the parent directory; erase! 🀣( How didn't I notice that?)

                model = Sketchup.active_model
                selection = model.active_entities
                #  -  -  -  -  -  -  -  -  -  -  -  -
                selection.each { |entity|
                if entity.typename == "Face"
                entity.erase!
                end
                }
                
                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  @remus said:

                  give em some credit chris, i had to type 'selection' as well πŸ˜„

                  Heh, I didn't notice that you switched it around to use the selection set instead of all entities. Well done πŸ˜„ Now make it smart enough to use the selection set if it exists, and if not, use all entities.

                  Chris

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    BTM
                    last edited by

                    It probably got overrun by new posts, so here's my original question about translation

                    my main issue (which I've been trying to figure out) is how to use the cursor to set the transformation, like the move tool does; click and drag. I thought I saw something on it once, but am still confused.

                    Your last post, Chris: Ah, and that's easy.

                    model = Sketchup.active_model
                    if model.selection == true
                    selection = model.selection
                    else
                    selection = model.active_entities
                    end
                    #  -  -  -  -  -  -  -  -  -  -  -  -
                    selection.each { |entity|
                    if entity.typename == "Face"
                    entity.erase!
                    end
                    }
                    

                    ...well, sort of easy. It seems to be buggy, and deletes random faces, if anything is selected. πŸ˜•
                    How do you put all the entities into an array again?

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

                      just learnt an important lesson about using recursion in combination with a messagebox.

                      model = Sketchup.active_model
                      entities = model.selection
                      
                      entities.each { |e|
                       if e.typename == "Curve"
                       edgnum = e.count_edges
                       UI.messagebox "edgnum.to_s"
                       else
                       UI.messagebox "Please select a curve"
                       end
                       }
                      

                      10 points if you can spot what'll happen (without running it!)

                      http://remusrendering.wordpress.com/

                      1 Reply Last reply Reply Quote 0
                      • B Offline
                        BTM
                        last edited by

                        it counts the edges of any selected curve, and displays them as a string, in a message box. If 20 curves were selected, then 20 different message boxes, with the amount of edges in each curve, is shown, one after another each time you click enter. πŸ˜‰

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

                          Could well do, but it's worse than that...points still up for grabs.

                          http://remusrendering.wordpress.com/

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

                            Close enough, it will keep saying 'please select a curve' until you force quite SU, as it keeps going through the model.

                            http://remusrendering.wordpress.com/

                            1 Reply Last reply Reply Quote 0
                            • B Offline
                              BTM
                              last edited by

                              oh, I forgot to mention that if no curve is selected, it says the message "Please select a curve".

                              Oh, and I'm pretty sure you wrote part of your code wrong, which could cause... hmmm.... I don't know... O.K., I'm testing it πŸ˜‰

                              1 Reply Last reply Reply Quote 0
                              • B Offline
                                BTM
                                last edited by

                                No, just tested it, I think it says it once for every edge in the selected curve/curves.

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

                                  thats interesting, more experimenting is needed!

                                  edit: perhaps in the morning. Its getting a bit late now πŸ˜‰

                                  http://remusrendering.wordpress.com/

                                  1 Reply Last reply Reply Quote 0
                                  • B Offline
                                    BTM
                                    last edited by

                                    model = Sketchup.active_model
                                    selection = model.selection
                                    #  -  -  -  -  -  -  -  -  -  -  -  -
                                       selection.each { |entity|
                                          if entity.typename == "Face"
                                          UI.openURL "http://www.sketchucation.com/forums/scf/"
                                       end
                                    }
                                    

                                    πŸ˜‰

                                    1 Reply Last reply Reply Quote 0
                                    • Chris FullmerC Offline
                                      Chris Fullmer
                                      last edited by

                                      Well, this is not the problem in question, but a selection will not contain an entity "Curve" for one thing. It contains edges though, and they might belong to a curve. So you can test if e.typename == "Edge" and then if true test if e.curve != false.

                                      (And this gets back to what Adam was bringing up and Jim also talked about in another post. I think instead of testing if each entity is an edge (which is how I still do it), perhaps test each entity if its part of a curve. (I don't know the best code to do that, but its something to think about).)

                                      I think that a selection can only hold DrawingElements (which does not include curves). I'm not sure why though.

                                      Chris

                                      Lately you've been tan, suspicious for the winter.
                                      All my Plugins I've written

                                      1 Reply Last reply Reply Quote 0
                                      • B Offline
                                        BTM
                                        last edited by

                                        It probably got overrun by new posts, so here's my original question about translation

                                        my main issue (which I've been trying to figure out) is how to use the cursor to set the transformation, like the move tool does; click and drag. I thought I saw something on it once, but am still confused.

                                        1 Reply Last reply Reply Quote 0
                                        • Chris FullmerC Offline
                                          Chris Fullmer
                                          last edited by

                                          Oh, and BTM, in my opinion, as a fairly new Ruby scripter, making any script that interacts with the mouse is a bit challenging, especially at first. It requires making a class tool, and instantiating the tool, and making good use of methods, including pre-defined methods from the API. I'll try to write up a template for creating a new tool. But that is really a tutorial all of its own. (BTW, I said before I was working on a tutorial for beginning ruby, and its been put on hold because the methods for wiritng a tutorial for SketchUcation are currently not working....so I have to wait for the management to fix it.)

                                          If possible, I would avoid the mouse controlling the transform idea.

                                          Chris

                                          Lately you've been tan, suspicious for the winter.
                                          All my Plugins I've written

                                          1 Reply Last reply Reply Quote 0
                                          • Chris FullmerC Offline
                                            Chris Fullmer
                                            last edited by

                                            To be more specific, I don't understand how to implement the inferencing system of SU. I have a sfew scripts that use inferencing, but I literally copied and pasted portions of those scripts from the query tool example that comes with SU. If you want to being working with inferencing, check out that tool.

                                            Lately you've been tan, suspicious for the winter.
                                            All my Plugins I've written

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

                                            Advertisement