0
0
3D Printingknowledge~10 mins

STL file format understanding in 3D Printing - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the file extension for STL files.

3D Printing
filename = "model[1]"
Drag options to blanks, or click blank then click option'
A.stl
B.obj
C.3mf
D.gcode
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Confusing STL with other 3D file formats like OBJ or 3MF.
Using file extensions related to printer instructions like GCODE.
2fill in blank
medium

Complete the code to check if an STL file is in ASCII format by reading its first 5 characters.

3D Printing
with open('part.stl', 'r') as file:
    header = file.read([1])
    is_ascii = header == 'solid'
Drag options to blanks, or click blank then click option'
A3
B5
C7
D10
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Reading too few or too many characters causing incorrect detection.
Not opening the file in text mode for ASCII STL.
3fill in blank
hard

Fix the error in the code to correctly parse the number of triangles from a binary STL file header.

3D Printing
with open('shape.stl', 'rb') as f:
    f.read(80)  # skip header
    num_triangles = int.from_bytes(f.read([1]), byteorder='little')
Drag options to blanks, or click blank then click option'
A2
B16
C8
D4
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Using 2 bytes which is too small for the triangle count.
Using 8 or 16 bytes which is too large and causes errors.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each triangle index to its normal vector length in an STL model.

3D Printing
normals_length = {i: (nx[1]2 + ny[2]2 + nz**2)**0.5 for i, (nx, ny, nz) in enumerate(normals)}
Drag options to blanks, or click blank then click option'
A**
B+
C-
D*
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Using multiplication instead of exponentiation for squares.
Using subtraction instead of addition inside the sum.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of triangles with area greater than zero from STL data.

3D Printing
filtered_triangles = [1]: [2] for [3], [2] in triangles.items() if [2] > 0}
Drag options to blanks, or click blank then click option'
Aindex
Barea
Ci
Dtriangle
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Mixing variable names causing syntax errors.
Using the wrong variable for keys or values in the comprehension.