sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Lisp getpoint (not finished!)

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 2 Posters 612 Views 2 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 all!

      I try to do a function like "GETPOINT" Lisp function.
      I have one problem... I use a class method to do this function. It works great (I have not yet transformed into sub-function (or semi-invoked function), which may suspend the main function) but I want to assignate a variable to retrieve point clicked.
      for example : pt=getpoint("Specify first point:")... But pt always returns active model... In fact it returns GetPoint.new result!

      Do you know how to replace model result by point-clicked result, please?

      Code is attached below...


      This is a code, not a plugin!

      Frenglish at its best !
      My scripts

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

        What happens if you draw a face and zoom in so that the face is taking up 100% of the screen and then try clicking on the face. Does that return that face?

        Also, what is the msg variable supposed to contain? It is being sent into the class, but I haven't figured out what its supposed to do.

        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

          Oh, I get the message bit now. It is the status text.

          So what is the main thing you are trying to do? I'm not familiar with the LiSP that named. What does it do? Just click on a point and this will display the point 3d position?

          Chris

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

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

            Hi Chris! Thank you for your answers!

            This function will be used by coders. I hope this kind of function will be able to simplify coding work... Now, to know position of a point defined by the user, we have to use class methods. Here I hope you may create a function like this:

            # Code example; To make a line by two points...
            def speed_coding_line
              model=Sketchup.active_model
              model.entities.add_edges(getpoint("Specify start point; "),getpoint("Specify end point; "))
            end
            

            So I want code available in the first post (function getpoint(msg)) returns position of point clicked by the user.

            Sorry for my bad english... 😳

            Frenglish at its best !
            My scripts

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

              Ahh, I'm getting it now. And you're trying to do it without using a global variable?

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

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

                Yes... 😲

                Frenglish at its best !
                My scripts

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

                  With a global you could have your speed code setup like this:

                  def speed_coding_line
                    model=Sketchup.active_model
                    (getpoint("Specify start point; ")
                    pt1 = $global_variable.clone
                    (getpoint("Specify start point; ")
                    pt2 = $global_variable.clone
                    model.entities.add_edges( pt1, pt2 )
                  end
                  

                  Not as simple, but it does the trick. I think since the $global_variable will be holding a Point3d object, you will need to .clone it or else you will get pt1 == pt2.

                  Is that a possible workaround? I don't like globals. Maybe someone else can figure out how to pass the variable back to the getpoint method.

                  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

                    And maybe I should mention that the code above assumes that you add this to the onLbuttonDown method of the script:

                    $global_variable = pt.position

                    So that your class actually sets the global variable. Then the little code snippet I added above should work.

                    Chris

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

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

                      I thought about that work-around method... I will use it until something better...
                      Thank you Chris!

                      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