Draw lines using screen coordinates (help)
-
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)
-
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.
-
@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]
-
1)
view.draw2d
needs to be used within aTool
class, and only draws temporary lines in "screen space" not "model space" (ie, they are notSketchup::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 -
@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)
-
@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
Advertisement