• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Is the ruby source for rectangle tool or similar available?

Scheduled Pinned Locked Moved Developers' Forum
2 Posts 2 Posters 209 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.
  • B Offline
    bobdiya
    last edited by 30 Dec 2013, 12:25

    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.

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 30 Dec 2013, 13:58

      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 = p1 the start of an edge
      Point 2 click = p2 the 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]
      Project p1 & p2 to line
      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...

      TIG

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement