So far this is a small subset of the brl-cad primitives with some notion of object-oriented design, being emitted as tcl scripts that mged can directly process into database (.g) files. Requirements are Python and brl-cad.
# git clone this repository
cd python-brlcad-tcl
python -m examples.motor_28BYJ_48__example output.tcl
- note that
motor_28BYJ_48__COMPLETE1.r
here is the 'region' that was created at the end of the motor's init function, it is a special type of combination that 'instantiates' all of the non-region 'object definitions' (primitives and combinations).
- note that
meshlab output.stl
The multi-part example shows how to use two python-brlcad-tcl objects (including motor_28BYJ_48__example.py
). In addition to emitting the tcl script, it runs mged to create a new geometry database, and then converts that to an STL.
To view the resulting (.g) file in mged
:
# git clone this repository
cd python-brlcad-tcl
python -m examples.multi_part_example.py multi_part.tcl
mged multi_part.g
- (if you don't have meshlab installed, you could comment out the line starting with
brl_db.save_stl
to save some run-time time) I was running this example then opening the resulting (.STL) file in meshlab (because I don't know how/if mged has a real-time raytracing display mode) :
- (if you don't have meshlab installed, you could comment out the line starting with
meshlab multi_part.stl
Looking at the stack of STL files emitted:
Looking at the raster output, with greyscale output option:
Looking at the raster output:
- find the usage syntax - https://brlcad.org/wiki/MGED_Commands
- add a new method that users will use to call the new feature from their scripts
- code the method to use string-formatting, then append it to the
self.script_string_list
object
name = self._default_name_(name)
- this will do a few things
- checks if the name is empty-string or
None
- if so, then uses the
inspect
module to learn the caller-function name, and uses that function name as a "new name"
- if so, then uses the
- checks if the name is in a lookup-table of already-used names
- if so, appends a number to the name, then adds this name to the lookup-table
- checks if the name is empty-string or
- this will do a few things
return name
- return the name of the final object or primitive so the users can use it if they want