Last active
April 17, 2021 17:30
-
-
Save ocommaj/6ade48f5838de85da42ad3449a7571ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
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 | |
def config_viewports(): | |
screens = D.screens | |
viewareas = [area for screen in screens for area in screen.areas if area.type == 'VIEW_3D'] | |
for area in viewareas: | |
area.spaces.active.overlay.grid_scale = SCALE_LENGTH | |
area.spaces.active.clip_end = CLIP_END | |
def enable_print_util(): | |
is_enabled, is_loaded = check(PRINT_UTIL) | |
if is_enabled and is_loaded: | |
return | |
bpy.ops.preferences.addon_enable(module=PRINT_UTIL) | |
def remove_default_objects(): | |
bpy.ops.object.select_all(action='SELECT') | |
if len(C.selected_objects) <= 3: | |
bpy.ops.object.delete(use_global=True) | |
config_units() | |
config_viewports() | |
enable_print_util() | |
remove_default_objects() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment