Is the ruby source for rectangle tool or similar available?
-
I've been reading up the ruby source of tools - Construction line, Sphere tool by Jim Foltz and rotate scale tool by thomthom. They have been very helpful in writing my tool.
Also, I have been wondering if there exists a version of ruby source for rectangle tool. The source to this tool will help me figure a lot of things I want to achieve. I searched for it but in vain. Even an older version or something similar would be helpful.
-
There are several 'rectangle' plugins available, like '3 point rectangle' ...
My own 2Dtools includes a 'rectangle tool' making 4 edges - no face...The principal is very similar to the line-tool example, instead of picking 2 points, you pick 3.
The 'box' tool also has a potential crib...Point 1 click =
p1the start of an edge
Point 2 click =p2the end of that edge
A Vector -vec = p1.vector_to(p2)
Point 3 click -poff- this defines the offset to the opposite side NOT a vertex.
A Line -line = [poff, vec]
Projectp1&p2toline
p3 = p2.project_to_line(line) p4 = p1.project_to_line(line)
Now if you want a face:
face = Sketchup.active_model.active_entities.add_face(p1, p2, p3, p4)
The edges get automatically added.If you want just edges:
edges = Sketchup.active_model.active_entities.add_edges(p1, p2, p3, p4, p1)
Remember to close the loop by reusing the first point again at the end...***To get the temporary graphics rubber-banding that is needed in 'draw'... use the initial 2 points as if it's the line-tool, and then after the stare increments... while waiting for the 'poff' click the mouse's cursor-position can be used for calculating the the dynamically changing projected points from those 2, to draw the four sides of the potential rectangle as the cursor moves...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement