# extrude length, leave 0 for a 2d polygon # Set to a value in radians to rotate from the default # By default, the first point is drawn on the X axis. # Position of the center point of starting face # ignored if type = "inner" or "outer" if using # Draw the polygon with a predefined edge length # Draw the polygon based on the radius of a circle outside the polygon, # Draw the polygon based on the radius of a circle insdie the polygon, All other arguments are optional.Ĭode: Select all def regPolygon(sides, radius=2, type="inner", edgeLength=0, \ The only required argument is sides, and you would normally need to specify either radius or edgeLength, though default values are specified for both since they are mutually exclusive (which one is needed is specified by type). I also want to add a gui for people who are not scripters. By default, the polygon is generated at 0,0,0, but you can offset it as needed, and you can rotate the initial point.Ĭurrently it only works on the XY plane and extrudes into the Z, but it will support rotating into other vectors as soon as I figure out how to get that to work. It can generate the polygon as simply a wire, as a face, or as an extruded polygon. Since I was going through the trouble of coding that, I figured it made sense to extend my script into a general purpose Regular Polygon generator, allowing any n-sided polygon to be specified by the inner or outer radius, or the length of the sides. Since I needed to learn Python and FreeCAD, this seemed like a good way to do it. The only regular polygon tool I could find was in the 2d drafting mode, and it is limited to generating polygons with the outer radius, so it appeared that I was going to have to code it myself. This is how Nuts and bolts (and in my case, Allen wrenches) are defined. I needed a way to generate regular hexagons based on the inradius (put simply when measured from flat to flat).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |