Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import a DXF file for machining.
CNC Programming
geometry = import_geometry('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a DWG or GCODE file instead of a DXF file.
Forgetting to include the file extension.
✗ Incorrect
The import_geometry function requires the DXF file name to load the geometry correctly.
2fill in blank
mediumComplete the code to extract the contours from the imported geometry.
CNC Programming
contours = geometry.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method that does not exist on the geometry object.
Confusing contour extraction with loading or parsing.
✗ Incorrect
The method extract_contours() is used to get the contour paths from the geometry object.
3fill in blank
hardFix the error in the code to correctly convert contours to toolpaths.
CNC Programming
toolpaths = convert_to_toolpaths([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single contour instead of the list.
Passing the geometry object instead of contours.
✗ Incorrect
The variable 'contours' holds the list of contour paths and must be passed to convert_to_toolpaths.
4fill in blank
hardFill both blanks to filter contours by length and convert them to toolpaths.
CNC Programming
filtered = [c for c in contours if c.length [1] [2]] toolpaths = convert_to_toolpaths(filtered)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing wrong filtering.
Using a too small length threshold.
✗ Incorrect
We filter contours longer than 10 units using '>' and 10, then convert them to toolpaths.
5fill in blank
hardFill all three blanks to create a dictionary of toolpaths with names for machining.
CNC Programming
named_toolpaths = [1]([2]: [3] for [2] in range(len(toolpaths)) if len(toolpaths[[2]]) > 0)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable names in comprehension.
Not using dict() to create the dictionary.
✗ Incorrect
We use dict comprehension with 'i' as key and toolpaths[i] as value for non-empty toolpaths.