Skip to content

Instantly share code, notes, and snippets.

@nmz787
Last active September 14, 2018 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmz787/6f4b057de631e0f150775deb8d9eb566 to your computer and use it in GitHub Desktop.
Save nmz787/6f4b057de631e0f150775deb8d9eb566 to your computer and use it in GitHub Desktop.
test rounded edge.stl brlcad-python-tcl
from python_brlcad_tcl.brlcad_tcl import *
class rounded_cube(BrlCadModel):
def __init__(self, brl_db):
super(rounded_cube, self). __init__(brl_db)
self.center_name = None
self.edge = 10
c1 = [0, 0, 0]
c2 = [self.edge, self.edge, self.edge]
cube = brl_db.cuboid(c1, c2)
c1 = [0, 0, 0]
c2 = [self.edge/8., self.edge, self.edge/8.]
print(c1)
print(c2)
sub1 = brl_db.cuboid(c1, c2, 'sub1.s')
c1 = [self.edge/8., 0, self.edge/8.]
c2 = [0, self.edge, 0]
cyl1 = brl_db.circular_cylinder(c1, c2, radius=self.edge/8.)
# finally create a region (a special combination that means it's going to be rendered)
# by unioning together the main combinations we just created
comb1 = brl_db.combination(cube - sub1)
comb2 = brl_db.combination(comb1 + cyl1)
self.final_name = comb2
print('done')
if __name__ == "__main__":
g_path_out = check_cmdline_args(__file__)
with brlcad_tcl(g_path_out, "My Database", stl_quality=0.1,verbose=True) as brl_db:
rc = rounded_cube(brl_db)
final_name = brl_db.region('u {}'.format(rc.final_name))
# process the g database into an STL file with a list of regions
brl_db.run_and_save_stl([union([final_name])])
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment