deprecation warning on export_stl
Closed this issue · 5 comments
Following the documentation, I have the following code:
from build123d import *
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
with BuildPart() as ex2:
Box(length, width, thickness)
Cylinder(radius=center_hole_dia / 2, height=thickness, mode=Mode.SUBTRACT)
ex2.part.export_stl("file.stl")
Which results in a deprecation warning:
The method "export_stl" in class "Shape" is deprecated
Use theexport_stl
function instead
But the code as written above seems to be what is recommended in the note at the beginning of "Introductory examples" section of the documentation:
If you want to save your resulting object as an STL from builder mode, you can use e.g. ex15.part.export_stl("file.stl").
Confused as to how I'm supposed to be exporting.
If I read the warning correctly, you should use the function export_stl(x, ...)
not the method y.export_stl(...)
Searched through the Discord channel:
source: https://discord.com/channels/964330484911972403/1074840524181217452/1226331307294851122
OK, I'm still lost.
The following code works with no warnings:
from build123d import *
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
with BuildPart() as ex2:
Box(length, width, thickness)
Cylinder(radius=center_hole_dia / 2, height=thickness, mode=Mode.SUBTRACT)
export_step(ex2.part, "block.step")
The following code produces an stl file but results in a deprecation warning:
from build123d import *
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
with BuildPart() as ex2:
Box(length, width, thickness)
Cylinder(radius=center_hole_dia / 2, height=thickness, mode=Mode.SUBTRACT)
ex2.part.export_stl("file.stl")
The following code does not work, and results in an error 'export_stl' is not defined:
from build123d import *
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
with BuildPart() as ex2:
Box(length, width, thickness)
Cylinder(radius=center_hole_dia / 2, height=thickness, mode=Mode.SUBTRACT)
export_stl(ex2.part, "black.stl" )
Sorry, I think I figured it out. Installing on Windows with the following results in the above problems:
pip install build123d
However, installing with the following now works as expected:
python -m pip install git+https://github.com/gumyr/build123d
The first command must have installed a version that had the deprecation warning but did not have the new function implemented?
Thanks for pointing this out. I've changed the docs to use the export_stl
function. Unfortunately I forgot to update the __init__.py
file when I made this change and a release was created before I realized it so this is a little messed up. The next release (which should happen before long) should clean things up along with this docs change.
Thank you, looking forward to the next release!