[Request]Define Segment Length Plugin
-
I am asking for a plugin that can create a polygon with any number of segments, in which you can specify a length for the segments and create the polygon. For example, you could define an endpoint position. Then your tool would move onto the next endpoint, so you could define a position and then create the polygon. I'll post a pic of what I am trying to ask for.
-
@unknownuser said:
I am asking for a plugin that can create a polygon with any number of segments, in which you can specify a length for the segments and create the polygon.
Not sure I understand. You want something like the Polygon tool but its distance would be the line segment length, not radius?
-
I think you've got it.
-
Dear Physicsguy,
As a work around, make the polygon a group, edit the group, and then use the tape measure tool to set the length of the segment.
Regards,
Bob -
Hi Physicsguy
I had to do the same... here is what I do:
Create the polygon with the number of segments you want.
Explode Curve.
Take all the segments except one and weld them togheter.
Take the only segment that is not welded and use fredoscale... you can hit the TAB key to define the segment length.
Hope that helps...Daniel S
-
According to:
http://en.wikipedia.org/wiki/Regular_polygon
the radius "r" of a regular polygon of segment length "s" and number of sides "n" is
r = s / ( 2 * sin(pi/n) )
so the segment length, as a function of the radius should be
s = r * ( 2 * sin(pi/n) )
So file this little bit somewhere (not your plugins directory) as "radius.rb" and when you want it, in your Ruby Console "load /my/choice/radius.rb". (If you're going to use it often, "r = '/my/choice/radius.rb'" and then "load r".)
# radius.rb require 'sketchup.rb' ns = UI.inputbox ['Number of sides; ', 'Side length; '], ['6', '1'],'Radius Given Side Length' n = ns[0].to_f s = ns[1].to_f puts s / ( 2 * Math.sin(Math;;PI / n) )
I've not used the VCB part of the API yet. Maybe someone who has can pitch in the last step.
-
@watkins said:
Dear Physicsguy,
As a work around, make the polygon a group, edit the group, and then use the tape measure tool to set the length of the segment.
Regards,
BobWatkins's solution is the straightforward and easiest... Draw polygon, group it, use tapemeasure tool, pick two adjacent vertices, type in require length, hit enter key, accept to scale group, exit group-edit, select group and explode - you have the polygon with the required length of side...
Alternative structure for a Ruby: drawn a polygon, select and pick 'Set Polygon side length' tool, in dialog enter new 'length'. The tool takes the length of curve.edges[0].length [polygon's edge length] and then applies a scaling transformation to the polygon's curve, about it's center, based on the 'desired length' and actual 'length' ratio...
Advertisement