vastprep.blogg.se

Blender print to scale
Blender print to scale












blender print to scale
  1. Blender print to scale full#
  2. Blender print to scale code#
blender print to scale

The map outline of the states you see in the GIF above was courtesy of shapefiles provided by The United States Census Bureau. In my version, it places a sphere at each coordinate set, but that can be easily changed to other objects. It scales the latitude and longitude down along the Z (height) and X (width) axes, taking into account the size of a base map oriented along those axes. So, finally, in a fit of rage this weekend, I wrote a function to do it for me. This could be aliased behind a one word command to a shell script of its own, but this seems as good a place to prune as now.Getting coordinates to scale properly to Blender units has been extremely frustrating for me since I started attempting more 3D maps. Running from the CLI, simply pass in the ‘-P’ flag and the relative path to the script: blender -P. Fortunately, Blender makes it easy to execute a Python script at launch. But that would still mean a good bit of clicking around to go into the Scripting workspace, load it up and execute. Now this script can be run within any project and it will set things up to model for export to 3D Printing. As a safeguard, in case this script gets called on a file with more objects already created, the call to the delete method is wrapped behind a conditional and will not fire if there are more than 3 objected selected.įinally, all that’s left is to call the functions: config_units() config_viewports() enable_print_util() remove_default_objects() This helper function is optional, but works simply enough - selecting all objects in the scene (to include Default Light & Default Camera) and deleting them. Long-suffering Default Cube gets it again. def remove_default_objects(): _all(action=’SELECT’) if len(C.selected_objects) <= 3: (use_global=True) The bpy method is wrapped in a try-catch to be on the safe side when handling the dependency. If it is, the function returns, otherwise, it enables the module. The function checks if the official Blender Mesh 3D-Print Toolbox add-on is already loaded and enabled. Here’s where the imports from the “addon_utils” module get used. 1000m -> 1000mm -> 100000mm def enable_print_util(): is_enabled, is_loaded = check(PRINT_UTIL) if is_enabled and is_loaded: return try: _enable(module=PRINT_UTIL) except: print(f"ERR: Error loading ") finally: return View Sidebar: Clip End has unit attached. Mass is helpful to set if you’re modeling moving parts, gears, for example, and plan to use an animation to check their smooth operation. Equivalent to updating ‘Unit Scale’, ‘Length’, and ‘Mass’ on the ‘Scene Properties’ panel. def config_units(): C.scene.unit_settings.scale_length = SCALE_LENGTH C.scene.unit_settings.length_unit = LENGTH_UNIT C.scene.unit_settings.mass_unit = MASS_UNIT “C” and “D” are Blender Python standards to alias “bpy.context” and “bpy.data”, objects which get used… frequently. The “addon_utils” functions will get used to enable the 3D Printing tools. Remove Default Scene objects import bpy from addon_utils import check, enable C = bpy.context D = bpy.data SCALE_LENGTH = 0.001 LENGTH_UNIT = ‘MILLIMETERS’ MASS_UNIT = 'GRAMS' CLIP_END = 100000 PRINT_UTIL = “object_print3d_utils”

blender print to scale

Ensure that the official 3D Print Tools Add-on is enabledĥ. Configure the Viewports to display at the updated scaleĤ. Change the Scene scale & units from Meters to Millimetersģ.

Blender print to scale full#

For full debugging, you’ll have to tab over to the CLI where Blender was launched. The default workspace includes a Console and an Info Panel that reflects the underlying Python executed by actions taken in the GUI. It’s also worth going into Edit > Preferences > Interface and enabling the Python Tooltips checkbox. Because this will vary with OS, check Blender’s documentation for yours: Launching from the Command Line.įor convenience, all of the screenshots I’m including show the Blender Scripting environment - but any text editor works. Finally, turns out this is a pretty good way to start learning the Blender Python API.įor full access to the debugging output generated in the Python script, launch Blender from the command line. I assume I’m not the only one, but even if that were the case, it would still be worth writing down these notes to help future-Jim.īlender is great for 3D Printing, but configuring the environment each time is tedious - and clicking back and forth between Blender and YouTube trying to remember all of the settings to change wasn’t cutting it.

Blender print to scale code#

Besides, writing this kind of boilerplate-useful code is 1000% the type of thing I tend to do, then forget how I did. Time to start changing both those conditions. Writing tutorials is good - and I haven’t been doing it repetitive clicky-draggy thing things are bad, and I’ve been doing it too much. Launch Blender for 3D Printing via Python














Blender print to scale