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

    Function "Command" From lisp

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 6 Posters 1.9k Views 6 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.
    • M Offline
      Matt666
      last edited by

      Hi every body !

      Before using sketchup, which became completely indispensable 😉 , I used autocad and its language Lisp. The lisp contains a very interesting feature: the "command" function.
      It allows you to use all tools autocad in the running. All the arguments are replies to messages orders.
      Example : (command "_line" "0,0,0" "10,0,10" "50,50,50")
      And to close the line command : (command "")

      Do you think it would be possible to create a similar function in ruby?

      PS : Sorry for that frenglish !!!

      Frenglish at its best !
      My scripts

      1 Reply Last reply Reply Quote 0
      • AdamBA Offline
        AdamB
        last edited by

        SU has a language built-in for a similar purpose. Its called Ruby.

        At the console you can execute Ruby commands to create geometry etc.

        eg

        Sketchup.active_model.entities.add_line([0,0,0], [3,1,4])

        adds a line to your model.

        Sketchup.active_model.entities.add_text "Allez Les Bleus", [5,6,7]

        adds some "camera-facing" text at coordinates 5,6,7

        etc etc

        http://download.sketchup.com/OnlineDoc/gsu6_ruby/Docs/ruby-classes.html for every function.

        Adam

        Developer of LightUp Click for website

        1 Reply Last reply Reply Quote 0
        • M Offline
          Matt666
          last edited by

          Hello AdamB !

          @adamb said:

          Sketchup.active_model.entities.add_line([0,0,0], [3,1,4])

          yes, I know these methods.

          "Command" function can use ALL the existing commands... AND also user commands... Very interesting !

          @unknownuser said:

          Sketchup.active_model.entities.add_text "Allez Les Bleus", [5,6,7]

          😄

          For example How can you add a dimension...

          Thank you for your answer !

          Frenglish at its best !
          My scripts

          1 Reply Last reply Reply Quote 0
          • Didier BurD Offline
            Didier Bur
            last edited by

            Hi Matt,
            Pas possible d'ajouter des cotes (no way to add dimensions).
            Regarde la méthode send_action pour le peu qu'on peut faire (take a look at send_action method)

            Sketchup.active_model.send_action soccer.delete[Netherlands,Italy,Romania] 🤣

            DB

            1 Reply Last reply Reply Quote 0
            • M Offline
              Matt666
              last edited by

              Hello Didier !

              @unknownuser said:

              Regarde la méthode send_action pour le peu qu'on peut faire (take a look at send_action method)

              Sketchup.send_action 21410
              

              But I can't control the action process !
              For example, to find the dimension between 2 points given by the program... Not by the user !

              Any idea ? 😉

              Frenglish at its best !
              My scripts

              1 Reply Last reply Reply Quote 0
              • Didier BurD Offline
                Didier Bur
                last edited by

                Hi,
                In fact, send_action just performs an action which doesn't need any user input, or selects a tool (afaik).
                If you want to get the distance between 2 points, you don't need dimensions for that (d=p1.distance p2). If you want your script to draw a dimension, I think this is impossible.
                I hope I'm wrong...

                DB

                1 Reply Last reply Reply Quote 0
                • M Offline
                  Matt666
                  last edited by

                  😞 😞 😞
                  Grmbl
                  Ok ! Thank you Didier !

                  Frenglish at its best !
                  My scripts

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    Matt666
                    last edited by

                    an "entmake" in lisp ! Ok, thank you ! I will try it, even if I don't know the method !

                    thank you TIG !

                    Frenglish at its best !
                    My scripts

                    1 Reply Last reply Reply Quote 0
                    • Wo3DanW Offline
                      Wo3Dan
                      last edited by

                      @didier bur said:

                      ......Sketchup.active_model.send_action soccer.delete[Netherlands,Italy,Romania] 🤣

                      Hi Didier, is this going to be your next (and shortest) SU ruby plugin to get rid of us before we even started? 😲 😕 --> 😠
                      😉
                      Wo3Dan

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

                        @didier bur said:

                        Hi,
                        In fact, send_action just performs an action which doesn't need any user input, or selects a tool (afaik).
                        If you want to get the distance between 2 points, you don't need dimensions for that (d=p1.distance p2). If you want your script to draw a dimension, I think this is impossible.
                        I hope I'm wrong...

                        Getting distances between two points is easy as stated...
                        You CAN'T make dimensions direct from Ruby, BUT you can make a dimension-component.skp (or a set of various ones) that are stored in a Plugins sub-folder - these have a 'base' length, your script then has you pick two points - it places the component at p1 and rotates it to towards p2 and also scales it by the required factor p1_to_p2 : base... Point p3 could be an offset and scale approproiately for this...

                        .

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          Matt666
                          last edited by

                          Hello !
                          It's strange Ruby can't answer to a Sketchup pending command ! 😞 😲 😕

                          I would like to create a tool for continuous dimension. Acad like !
                          1- Draw a simple dimension
                          2- Retrieving the last basis point of the first dimension
                          3- draw a dimension with the first basis point already given.

                          If I understand, we must re-program dimension tool ?? 😲

                          Frenglish at its best !
                          My scripts

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            Matt666
                            last edited by

                            Can I do smt with the observer tools ?

                            When a user action is done, the observer returns the action ??? And we just have to send the action to the tool... no ? 😕

                            Frenglish at its best !
                            My scripts

                            1 Reply Last reply Reply Quote 0
                            • M Offline
                              Matt666
                              last edited by

                              Sketchup.active_model.send_action coach.delete[Raymond Domenech]...

                              Frenglish at its best !
                              My scripts

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                toxicvoxel
                                last edited by

                                The blokes at HQ would make life a lot simpler if they could provide simple GET functions (GETPoint,GetAngle,GetDistance etc.) - quite difficult and probably beyond many to do in Ruby with a tools class. If only they would apply the Sketchup 'simplicity' ethos to the API.

                                1 Reply Last reply Reply Quote 0
                                • Didier BurD Offline
                                  Didier Bur
                                  last edited by

                                  @unknownuser said:

                                  The blokes at HQ would make life a lot simpler if they could provide simple GET functions

                                  I agree 1000%

                                  DB

                                  1 Reply Last reply Reply Quote 0
                                  • M Offline
                                    Matt666
                                    last edited by

                                    +1... 😲 😞

                                    Frenglish at its best !
                                    My scripts

                                    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