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

    Draw lines using screen coordinates (help)

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 853 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.
    • jeff hammondJ Offline
      jeff hammond
      last edited by

      can one of you genii help me out real quick?

      i have four points [x,y] describing a rectangle on the screen (and i can get the necessary points within the SU window or the display so that part is covered i think).. i want to draw edges which connect these points (and i'm assuming if you're set to, say, top_view/parallel_projection and you drew these lines that the z would be 0?)

      i tried messing around with various incarcerations of

      view = Sketchup.active_model.active_view
      view = view.draw2d GL_QUADS, points
      

      ..to no avail.. i think i was getting the points to happen but i couldn't see them and there were definitely no lines πŸ˜†

      i can draw a regular rectangle (in sketchup land) but i can't put two&two together to make the rectangle with the screen coordinates.. (i.e.- the rectangles that i can make are based of the origin of the model)

      i understand this may be a weird request but humor the poor boy πŸ˜„
      what's the technique?
      thanks!

      (oh, and it'd be better if the rectangle didn't have a face)

      dotdotdot

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

        I once made a tutorial or something that did pretty much this exact thing. I can't find it for the life of me at the moment. Its not on YouTube. I'll see if I can find it and post it later, unless someone else writes it up first.

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

        1 Reply Last reply Reply Quote 0
        • jeff hammondJ Offline
          jeff hammond
          last edited by

          @chris fullmer said:

          I once made a tutorial or something that did pretty much this exact thing. I can't find it for the life of me at the moment. Its not on YouTube. I'll see if I can find it and post it later, unless someone else writes it up first.

          cool.. thanks a lot.. going to sleep now so i'll check back in the morning to see i've you found it..

          [oh.. i just noticed the incarcerations typo in my first post.. lol]

          dotdotdot

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

            1) view.draw2d needs to be used within a Tool class, and only draws temporary lines in "screen space" not "model space" (ie, they are not Sketchup::Drawingelement subclass objects.)

            2) The Sketchup API has NO translation between REAL screen coordinates and model coordinates. When you see the term "screen" in the API docs, it's actually referring to the application's client area (which can be much smaller than the actual computer screen.)

            3) To add edges to the model, you must use Entities.add_edges()
            see the example in the docs.

            4) To convert a x,y client (screen) co-ordinate to a Point3D, use View.inputpoint()
            also see the InputPoint class

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • jeff hammondJ Offline
              jeff hammond
              last edited by

              @dan rathbun said:

              .

              meh.. i'm lost.. πŸ˜„

              i don't learn that way.. i wish all those api things had some examples in there (i.e.- type this and watch what happens πŸ˜„ )

              the api documentation probably makes a great reference for someone that already understands the basics (which i don't)

              dotdotdot

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

                @unknownuser said:

                i don't learn that way.. i wish all those api things had some examples in there (i.e.- type this and watch what happens

                The API entry for Entities#add_edges() has a straightforward and simple example to add edges to a Sketchup::Model object. (My point of number 1, in the previous post, is that only Sketchup::Entity subclass objects, can be added into the model's DOM (Documnet Object Model heirarchy.) Sketchup::Drawingelement is a subclass of Sketchup::Entity, and the Sketchup::Drawingelement subclass objects are what you "see" in a model, such as Edges, Faces, etc.

                @unknownuser said:

                the api documentation probably makes a great reference for someone that already understands the basics (which i don't)

                see and follow: Ruby Newbie's Guide to Getting Started

                I'm not here much anymore.

                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