• Login
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.
  • J Offline
    jeff hammond
    last edited by 25 Dec 2011, 05:58

    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
    • C Offline
      Chris Fullmer
      last edited by 25 Dec 2011, 07:07

      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
      • J Offline
        jeff hammond
        last edited by 25 Dec 2011, 07:18

        @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
        • D Offline
          Dan Rathbun
          last edited by 25 Dec 2011, 07:30

          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
          • J Offline
            jeff hammond
            last edited by 25 Dec 2011, 18:32

            @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
            • D Offline
              Dan Rathbun
              last edited by 26 Dec 2011, 15:49

              @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
              1 / 1
              • First post
                4/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement