Skip to content

Instantly share code, notes, and snippets.

@akaleeroy
Last active April 4, 2016 19:34
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 akaleeroy/453f5ab97e1347eeede0 to your computer and use it in GitHub Desktop.
Save akaleeroy/453f5ab97e1347eeede0 to your computer and use it in GitHub Desktop.
Configure Blender STL Import/Export default settings

Configure Blender STL default settings

Blender STL default settings aren't what I like to have by default. Working in millimeters inside Blender makes the STLs come out tiny, so I tried to find a way to change these defaults and keep it that way.

Turns out they're baked into the io_mesh_stl script. This gist is a Windows PowerShell script to make the necessary adjustments. They are:
ImportSTL global_scale at _init_.py#L102 becomes default=0.1

ExportSTL use_selection below at _init_.py#L166 becomes default=True.

ExportSTL global_scale at _init_.py#L171 becomes default=10.0

Usage

Run from gist:

PS:>iex ((new-object net.webclient).DownloadString('https://gist.github.com/akaleeroy/453f5ab97e1347eeede0/raw/configure-blender-stl.ps1'))
# Find python init file regardless of Blender version in path
$file = (Resolve-Path "$env:ProgramFiles\Blender Foundation\Blender\*\scripts\addons\io_mesh_stl\__init__.py")
if ($file) {
# Read the file
$x = [IO.File]::ReadAllText($file)
# For some reason in Blender 2.77 you have to correct ImportSTL to global_scale = 0.1
$import_global_scale = [regex] '(?s)(ImportSTL.+?global_scale = .+?default=)(.+?),'
# On export tick Use Selection
$export_use_selection = [regex] '(?s)(ExportSTL.+?use_selection = .+?default=)(.+?),'
# Change export scale unit because STL uses centimeters
$export_global_scale = [regex] '(?s)(ExportSTL.+?global_scale = .+?default=)(.+?),'
# Do the substitution and write it to file
$x -replace $import_global_scale, '${1}0.1, # MODIFIED' -replace $export_global_scale, '${1}10.0, # MODIFIED' -replace $export_use_selection, '${1}True, # MODIFIED' | Set-Content $file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment