Generate the CNC-cutting curve inside the machine's workspace
Objective
You will learn how to reorient the mesh strip with the help of a bounding box for the CNC workspace, create the CNC-cutting polygon with a seam offset and check if it is within the limits of the CNC workspace.
Procedure
f. Outline with Seam
Create the strip outline as a polygon and add a seam with an offset for the CNC-cutting curve.
defseam(mesh,SEAM):"""Create the strip outline with a seam offset. """ outline = [mesh.vertex_coordinates(key)for key in mesh.vertices_on_boundary(ordered=True)] seam =offset_polygon(outline, -SEAM) seam =Polygon(seam)return seam
Define the origin and target frame for the transformation of the outline to align with the CNC workspace with the help of the bounding box. Transform the outline.
There is a problem with strip 0: it is flipped in this step! But not strip 8, so what do we do to unify their orientations? We don't want to flip the fabric because it has a coating on only one side.
g3. Correction of Orientation
We must make sure the strips are always oriented with their upper surface facing upwards.
The normal (hence cycling direction) of the bounding box is sometimes pointing in the positive and sometimes in the negative z-direction. Thus, we must reverse the order of the bounding box if its normal is pointing in the negative z-direction.
... g1# g3 ---------------------------------------------------------------------------# because the normal of the bouning box is sometimes in prositive and sometimes in negative z-direction# reverse bbox order if its pointing downwards = flip cycyleif bbox_polygon.normal[2]<0: bbox.reverse() bbox_polygon =Polygon(bbox)... g2
h. Workspace Dimensions
Lastly, we must check whether the strip fits inside the CNC-cutter workspace. Assuming the fabric can be shifted forward in its long direction, the short direction must respect the machine's maximum width. If this is not respected, an Exception should be raised.
# check cnc-workspace dimensionsshort_length =length_vector_xy(yaxis)if short_length > CNC_WIDTH:raiseException('The strip is too wide for the cnc machine.')
If the strip does not fit, we could either strip into the short direction, or find a CNC-cutting machine with a larger workspace, or split the strip's length of those that don't fit into half.
You have accomplished the materialisation of the fabric. Congratulations!