def locator_type_update(self, context): obj = context.object # PREVIEW MODELS LOADING if obj.scs_props.locator_type in ("Collision", "None"): _preview_models.unload(obj) elif not obj.scs_props.locator_preview_model_present: _preview_models.load(obj) # SCS_PART RESET if not _object_utils.has_part_property(obj): obj.scs_props.scs_part = "" else: scs_root_object = _object_utils.get_scs_root(obj) if scs_root_object: part_inventory = scs_root_object.scs_object_part_inventory # set part index to active or first # NOTE: direct access needed otherwise get function sets invalid index because # active object has still old part value part_index = scs_root_object.scs_props.active_scs_part_get_direct() if part_index >= len(part_inventory) or part_index < 0: part_index = 0 obj.scs_props.scs_part = part_inventory[part_index].name else: # if no root assign default obj.scs_props.scs_part = _PART_consts.default_name
def locator_type_update(self, context): obj = context.object # PREVIEW MODELS LOADING if obj.scs_props.locator_type in ("Collision", "None"): _preview_models.unload(obj) elif not obj.scs_props.locator_preview_model_present: _preview_models.load(obj) # SCS_PART RESET if not _object_utils.has_part_property(obj): obj.scs_props.scs_part = "" else: scs_root_object = _object_utils.get_scs_root(obj) if scs_root_object: part_inventory = scs_root_object.scs_object_part_inventory # set part index to active or first # NOTE: direct access needed otherwise get function sets invalid index because # active object has still old part value part_index = scs_root_object.scs_props.active_scs_part_get_direct( ) if part_index >= len(part_inventory) or part_index < 0: part_index = 0 obj.scs_props.scs_part = part_inventory[part_index].name else: # if no root assign default obj.scs_props.scs_part = _PART_consts.default_name
def locator_show_preview_model_update(self, context): """Update function for Locator Show Preview Model record on Objects. :param context: Blender Context :type context: bpy.types.Context :return: None """ obj = context.object if not _preview_models.load(obj): _preview_models.unload(obj) return None
def show_preview_models_update(self, context): """ :param context: :return: """ scene = context.scene for obj in bpy.data.objects: if obj.type == 'EMPTY': if scene.scs_props.show_preview_models: if not _preview_models.load(obj): _preview_models.unload(obj) else: _preview_models.unload(obj) return None
def locator_preview_model_path_update(self, context): """Update function for Locator Preview Model record on Objects. :param context: Blender Context :type context: bpy.types.Context :return: None """ obj = context.object if _preview_models.load(obj): # fix selection because in case of actual loading model from file selection will be messed up obj.select = True bpy.context.scene.objects.active = obj else: _preview_models.unload(obj) return None
def locator_type_update(self, context): obj = context.object # safety check to ensure we are dealing with proper object # NOTE: if this gets triggered during import, it's very likely that another object # was already set as active. In that case error might occur while accessing scs properties. if not hasattr(obj, "scs_props"): return # PREVIEW MODELS LOADING if obj.scs_props.locator_type in ("Collision", "None"): _preview_models.unload(obj) elif not obj.scs_props.locator_preview_model_present: _preview_models.load(obj) # SCS_PART RESET if not _object_utils.has_part_property(obj): obj.scs_props.scs_part = "" else: scs_root_object = _object_utils.get_scs_root(obj) if scs_root_object: part_inventory = scs_root_object.scs_object_part_inventory # set part index to active or first # NOTE: direct access needed otherwise get function sets invalid index because # active object has still old part value part_index = scs_root_object.scs_props.active_scs_part_get_direct( ) if part_index >= len(part_inventory) or part_index < 0: part_index = 0 obj.scs_props.scs_part = part_inventory[part_index].name else: # if no root assign default obj.scs_props.scs_part = _PART_consts.default_name