Title here
Summary here
A CAD Function is reusable function designed to perform a specific task or operation related to CAD.
openscad_async(model: str)
Compile an OpenSCAD geometry asynchronously and return an STL file encoded as a base64 string.
model (str)
: The OpenSCAD model code as a string.str
representing the STL file encoded as a base64 string.
stl = await openscad_async("""cube(10);""")
convert_stl_to_glb_async(stl: str, r=100: int, g=100: int, b=100: int)
Convert an STL file encoded as a base64 string to a GLB file encoded as a base64 string.
stl (str)
: The STL file encoded as a base64 string.r=100
: The red channel value for the color of the model.g=100
: The green channel value for the color of the model.b=100
: The blue channel value for the color of the model.str
representing the GLB file encoded as a base64 string.
import story
ctx = story.get_context()
viewer = ctx.model_viewer()
viewer = await viewer.init_async()
stl = await openscad_async("""
cube(10);
""")
glb = await convert_stl_to_glb_async(stl)
viewer.set_data(glb)