static int workspace_append_activate_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); char idname[MAX_ID_NAME - 2], filepath[FILE_MAX]; if (!RNA_struct_property_is_set(op->ptr, "idname") || !RNA_struct_property_is_set(op->ptr, "filepath")) { return OPERATOR_CANCELLED; } RNA_string_get(op->ptr, "idname", idname); RNA_string_get(op->ptr, "filepath", filepath); if (workspace_append(C, filepath, idname) != OPERATOR_CANCELLED) { WorkSpace *appended_workspace = BLI_findstring( &bmain->workspaces, idname, offsetof(ID, name) + 2); BLI_assert(appended_workspace != NULL); if (appended_workspace) { /* Reorder to last position. */ BKE_id_reorder(&bmain->workspaces, &appended_workspace->id, NULL, true); /* Changing workspace changes context. Do delayed! */ WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, appended_workspace); return OPERATOR_FINISHED; } } return OPERATOR_CANCELLED; }
static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **scene, SceneRenderLayer **srl) { /* single layer re-render */ if (RNA_struct_property_is_set(op->ptr, "scene")) { Scene *scn; char scene_name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "scene", scene_name); scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2); if (scn) { /* camera switch wont have updated */ scn->r.cfra = (*scene)->r.cfra; BKE_scene_camera_switch_update(scn); *scene = scn; } } if (RNA_struct_property_is_set(op->ptr, "layer")) { SceneRenderLayer *rl; char rl_name[RE_MAXNAME]; RNA_string_get(op->ptr, "layer", rl_name); rl = (SceneRenderLayer *)BLI_findstring(&(*scene)->r.layers, rl_name, offsetof(SceneRenderLayer, name)); if (rl) *srl = rl; } }
static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr) { bool is_save_internal; bScreen *sc = CTX_wm_screen(C); bkr->ob = CTX_data_active_object(C); bkr->main = CTX_data_main(C); bkr->scene = CTX_data_scene(C); bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; bkr->pass_type = RNA_enum_get(op->ptr, "type"); bkr->pass_filter = RNA_enum_get(op->ptr, "pass_filter"); bkr->margin = RNA_int_get(op->ptr, "margin"); bkr->save_mode = RNA_enum_get(op->ptr, "save_mode"); is_save_internal = (bkr->save_mode == R_BAKE_SAVE_INTERNAL); bkr->is_clear = RNA_boolean_get(op->ptr, "use_clear"); bkr->is_split_materials = (!is_save_internal) && RNA_boolean_get(op->ptr, "use_split_materials"); bkr->is_automatic_name = RNA_boolean_get(op->ptr, "use_automatic_name"); bkr->is_selected_to_active = RNA_boolean_get(op->ptr, "use_selected_to_active"); bkr->is_cage = RNA_boolean_get(op->ptr, "use_cage"); bkr->cage_extrusion = RNA_float_get(op->ptr, "cage_extrusion"); bkr->normal_space = RNA_enum_get(op->ptr, "normal_space"); bkr->normal_swizzle[0] = RNA_enum_get(op->ptr, "normal_r"); bkr->normal_swizzle[1] = RNA_enum_get(op->ptr, "normal_g"); bkr->normal_swizzle[2] = RNA_enum_get(op->ptr, "normal_b"); bkr->width = RNA_int_get(op->ptr, "width"); bkr->height = RNA_int_get(op->ptr, "height"); bkr->identifier = ""; RNA_string_get(op->ptr, "uv_layer", bkr->uv_layer); RNA_string_get(op->ptr, "cage_object", bkr->custom_cage); if ((!is_save_internal) && bkr->is_automatic_name) { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type"); RNA_property_enum_identifier(C, op->ptr, prop, bkr->pass_type, &bkr->identifier); } CTX_data_selected_objects(C, &bkr->selected_objects); bkr->reports = op->reports; bkr->result = OPERATOR_CANCELLED; bkr->render = RE_NewSceneRender(bkr->scene); /* XXX hack to force saving to always be internal. Whether (and how) to support * external saving will be addressed later */ bkr->save_mode = R_BAKE_SAVE_INTERNAL; }
static int mask_new_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); Mask *mask; char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); mask = BKE_mask_new(name); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: { SpaceClip *sc = sa->spacedata.first; ED_space_clip_set_mask(C, sc, mask); break; } case SPACE_SEQ: { /* do nothing */ break; } case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; ED_space_image_set_mask(C, sima, mask); break; } } } return OPERATOR_FINISHED; }
static int strip_modifier_move_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Sequence *seq = BKE_sequencer_active_get(scene); char name[MAX_NAME]; int direction; SequenceModifierData *smd; RNA_string_get(op->ptr, "name", name); direction = RNA_enum_get(op->ptr, "direction"); smd = BKE_sequence_modifier_find_by_name(seq, name); if (!smd) return OPERATOR_CANCELLED; if (direction == SEQ_MODIFIER_MOVE_UP) { if (smd->prev) { BLI_remlink(&seq->modifiers, smd); BLI_insertlinkbefore(&seq->modifiers, smd->prev, smd); } } else if (direction == SEQ_MODIFIER_MOVE_DOWN) { if (smd->next) { BLI_remlink(&seq->modifiers, smd); BLI_insertlinkafter(&seq->modifiers, smd->next, smd); } } BKE_sequence_invalidate_cache(scene, seq); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; }
static int poselib_rename_exec (bContext *C, wmOperator *op) { Object *ob= object_pose_armature_get(CTX_data_active_object(C)); bAction *act= (ob) ? ob->poselib : NULL; TimeMarker *marker; char newname[64]; /* check if valid poselib */ if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data"); return OPERATOR_CANCELLED; } /* get index (and pointer) of pose to remove */ marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; } /* get new name */ RNA_string_get(op->ptr, "name", newname); /* copy name and validate it */ BLI_strncpy(marker->name, newname, sizeof(marker->name)); BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name)); /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; }
static int wm_alembic_import_exec(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } char filename[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filename); const float scale = RNA_float_get(op->ptr, "scale"); const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence"); const bool set_frame_range = RNA_boolean_get(op->ptr, "set_frame_range"); const bool validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes"); const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job"); int offset = 0; int sequence_len = 1; if (is_sequence) { sequence_len = get_sequence_len(filename, &offset); if (sequence_len < 0) { BKE_report(op->reports, RPT_ERROR, "Unable to determine ABC sequence length"); return OPERATOR_CANCELLED; } } bool ok = ABC_import(C, filename, scale, is_sequence, set_frame_range, sequence_len, offset, validate_meshes, as_background_job); return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; }
static int ed_undo_push_exec(bContext *C, wmOperator *op) { char str[BKE_UNDO_STR_MAX]; RNA_string_get(op->ptr, "message", str); ED_undo_push(C, str); return OPERATOR_FINISHED; }
/* function used for WM_OT_save_mainfile too */ static int wm_collada_import_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; int import_units; int find_chains; int fix_orientation; int min_chain_length; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } /* Options panel */ import_units = RNA_boolean_get(op->ptr, "import_units"); find_chains = RNA_boolean_get(op->ptr, "find_chains"); fix_orientation = RNA_boolean_get(op->ptr, "fix_orientation"); min_chain_length = RNA_int_get(op->ptr, "min_chain_length"); RNA_string_get(op->ptr, "filepath", filename); if (collada_import( C, filename, import_units, find_chains, fix_orientation, min_chain_length)) { return OPERATOR_FINISHED; } else { BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document (see console for details)"); return OPERATOR_CANCELLED; } }
/** Jump to the object or bone referenced by the pointer, or check if it is possible. */ static bool jump_to_target_ptr(bContext *C, PointerRNA ptr, const bool poll) { if (RNA_pointer_is_null(&ptr)) { return false; } /* Verify pointer type. */ char bone_name[MAXBONENAME]; const StructRNA *target_type = NULL; if (ELEM(ptr.type, &RNA_EditBone, &RNA_PoseBone, &RNA_Bone)) { RNA_string_get(&ptr, "name", bone_name); if (bone_name[0] != '\0') { target_type = &RNA_Bone; } } else if (RNA_struct_is_a(ptr.type, &RNA_Object)) { target_type = &RNA_Object; } if (target_type == NULL) { return false; } /* Find the containing Object. */ ViewLayer *view_layer = CTX_data_view_layer(C); Base *base = NULL; const short id_type = GS(((ID *)ptr.id.data)->name); if (id_type == ID_OB) { base = BKE_view_layer_base_find(view_layer, ptr.id.data); } else if (OB_DATA_SUPPORT_ID(id_type)) { base = ED_object_find_first_by_data_id(view_layer, ptr.id.data); } bool ok = false; if ((base == NULL) || ((target_type == &RNA_Bone) && (base->object->type != OB_ARMATURE))) { /* pass */ } else if (poll) { ok = true; } else { /* Make optional. */ const bool reveal_hidden = true; /* Select and activate the target. */ if (target_type == &RNA_Bone) { ok = ED_object_jump_to_bone(C, base->object, bone_name, reveal_hidden); } else if (target_type == &RNA_Object) { ok = ED_object_jump_to_object(C, base->object, reveal_hidden); } else { BLI_assert(0); } } return ok; }
int file_directory_new_exec(bContext *C, wmOperator *op) { char name[FILE_MAXFILE]; char path[FILE_MAX]; int generate_name = 1; wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); if (!sfile->params) { BKE_report(op->reports, RPT_WARNING, "No parent directory given"); return OPERATOR_CANCELLED; } path[0] = '\0'; if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", path); if (path[0] != '\0') generate_name = 0; } if (generate_name) { /* create a new, non-existing folder name */ if (!new_folder_path(sfile->params->dir, path, name)) { BKE_report(op->reports, RPT_ERROR, "Could not create new folder name"); return OPERATOR_CANCELLED; } } /* create the file */ BLI_dir_create_recursive(path); if (!BLI_exists(path)) { BKE_report(op->reports, RPT_ERROR, "Could not create new folder"); return OPERATOR_CANCELLED; } /* now remember file to jump into editing */ BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); /* set timer to smoothly view newly generated file */ sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ sfile->scroll_offset = 0; /* reload dir to make sure we're seeing what's in the directory */ ED_fileselect_clear(wm, sfile); if (RNA_boolean_get(op->ptr, "open")) { BLI_strncpy(sfile->params->dir, path, sizeof(sfile->params->dir)); file_change_dir(C, 1); } WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; }
static int mask_new_exec(bContext *C, wmOperator *op) { char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); ED_mask_new(C, name); return OPERATOR_FINISHED; }
static int controller_add_exec(bContext *C, wmOperator *op) { Object *ob; bController *cont; PointerRNA cont_ptr; PropertyRNA *prop; const char *cont_name; int bit; char name[MAX_NAME]; int type = RNA_enum_get(op->ptr, "type"); ob = edit_object_property_get(C, op); if (!ob) return OPERATOR_CANCELLED; cont = new_controller(type); BLI_addtail(&(ob->controllers), cont); /* set the controller name based on rna type enum */ RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &cont_ptr); prop = RNA_struct_find_property(&cont_ptr, "type"); RNA_string_get(op->ptr, "name", name); if (*name) { BLI_strncpy(cont->name, name, sizeof(cont->name)); } else { RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name); BLI_strncpy(cont->name, cont_name, sizeof(cont->name)); } BLI_uniquename(&ob->controllers, cont, DATA_("Controller"), '.', offsetof(bController, name), sizeof(cont->name)); /* set the controller state mask from the current object state. * A controller is always in a single state, so select the lowest bit set * from the object state */ for (bit = 0; bit < OB_MAX_STATES; bit++) { if (ob->state & (1 << bit)) break; } cont->state_mask = (1 << bit); if (cont->state_mask == 0) { /* shouldn't happen, object state is never 0 */ cont->state_mask = 1; } ob->scaflag |= OB_SHOWCONT; WM_event_add_notifier(C, NC_LOGIC, NULL); return OPERATOR_FINISHED; }
static bool wm_alembic_export_check(bContext *UNUSED(C), wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); if (!BLI_path_extension_check(filepath, ".abc")) { BLI_path_extension_ensure(filepath, FILE_MAX, ".abc"); RNA_string_set(op->ptr, "filepath", filepath); return true; } return false; }
static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) { char modifier_name[MAX_NAME]; ModifierData *md; RNA_string_get(op->ptr, "modifier", modifier_name); md = modifiers_findByName(ob, modifier_name); if (md && type != 0 && md->type != type) md = NULL; return md; }
static bController *edit_controller_property_get(bContext *C, wmOperator *op, Object **ob) { char controller_name[MAX_NAME]; bController *cont; RNA_string_get(op->ptr, "controller", controller_name); *ob = edit_object_property_get(C, op); if (!*ob) return NULL; cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name)); return cont; }
static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object **ob) { char actuator_name[MAX_NAME]; bActuator *act; RNA_string_get(op->ptr, "actuator", actuator_name); *ob = edit_object_property_get(C, op); if (!*ob) return NULL; act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name)); return act; }
static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **ob) { char sensor_name[MAX_NAME]; bSensor *sens; RNA_string_get(op->ptr, "sensor", sensor_name); *ob = edit_object_property_get(C, op); if (!*ob) return NULL; sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name)); return sens; }
static bool wm_collada_export_check(bContext *UNUSED(C), wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); if (!BLI_testextensie(filepath, ".dae")) { BLI_ensure_extension(filepath, FILE_MAX, ".dae"); RNA_string_set(op->ptr, "filepath", filepath); return true; } return false; }
static int parent_drop_exec(bContext *C, wmOperator *op) { Object *par = NULL, *ob = NULL; Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); int partype = -1; char parname[MAX_ID_NAME], childname[MAX_ID_NAME]; partype = RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); par = (Object *)BKE_libblock_find_name(ID_OB, parname); RNA_string_get(op->ptr, "child", childname); ob = (Object *)BKE_libblock_find_name(ID_OB, childname); ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; }
void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) { int change= FALSE; if(RNA_struct_find_property(op->ptr, "filename")) { RNA_string_get(op->ptr, "filename", sfile->params->file); change= TRUE; } if(RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", sfile->params->dir); change= TRUE; } /* If neither of the above are set, split the filepath back */ if(RNA_struct_find_property(op->ptr, "filepath")) { if(change==FALSE) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file); } } /* XXX, files and dirs updates missing, not really so important though */ }
static int poselib_add_exec (bContext *C, wmOperator *op) { Object *ob= get_poselib_object(C); bAction *act = poselib_validate(ob); bPose *pose= (ob) ? ob->pose : NULL; TimeMarker *marker; KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ int frame= RNA_int_get(op->ptr, "frame"); char name[64]; /* sanity check (invoke should have checked this anyway) */ if (ELEM(NULL, ob, pose)) return OPERATOR_CANCELLED; /* get name to give to pose */ RNA_string_get(op->ptr, "name", name); /* add pose to poselib - replaces any existing pose there * - for the 'replace' option, this should end up finding the appropriate marker, * so no new one will be added */ for (marker= act->markers.first; marker; marker= marker->next) { if (marker->frame == frame) { BLI_strncpy(marker->name, name, sizeof(marker->name)); break; } } if (marker == NULL) { marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, name, sizeof(marker->name)); marker->frame= frame; BLI_addtail(&act->markers, marker); } /* validate name */ BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name)); /* use Keying Set to determine what to store for the pose */ // FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't (Whole Character) // so perhaps we need either a new Keying Set, or just to add overrides here... ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ act->active_marker= BLI_countlist(&act->markers); /* done */ return OPERATOR_FINISHED; }
static int masklay_new_exec(bContext *C, wmOperator *op) { Mask *mask = CTX_data_edit_mask(C); char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); BKE_mask_layer_new(mask, name); mask->masklay_act = mask->masklay_tot - 1; WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); return OPERATOR_FINISHED; }
static int create_orientation_exec(bContext *C, wmOperator *op) { char name[36]; int use = RNA_boolean_get(op->ptr, "use"); int overwrite = RNA_boolean_get(op->ptr, "overwrite"); RNA_string_get(op->ptr, "name", name); BIF_createTransformOrientation(C, op->reports, name, use, overwrite); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_SCENE|NA_EDITED, CTX_data_scene(C)); return OPERATOR_FINISHED; }
static int run_pyfile_exec(bContext *C, wmOperator *op) { char path[512]; RNA_string_get(op->ptr, "filepath", path); #ifdef WITH_PYTHON if (BPY_filepath_exec(C, path, op->reports)) { ARegion *ar = CTX_wm_region(C); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } #else (void)C; /* unused */ #endif return OPERATOR_CANCELLED; /* FAIL */ }
/* rename first selected TimeMarker */ static int ed_marker_rename_exec(bContext *C, wmOperator *op) { TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C)); if (marker) { RNA_string_get(op->ptr, "name", marker->name); WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } else { return OPERATOR_CANCELLED; } }
static Object *edit_object_property_get(bContext *C, wmOperator *op) { char ob_name[MAX_NAME]; Object *ob; RNA_string_get(op->ptr, "object", ob_name); /* if ob_name is valid try to find the object with this name * otherwise gets the active object */ if (*ob_name) ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); else ob = ED_object_active_context(C); return ob; }
/* function used for WM_OT_save_mainfile too */ static int wm_collada_import_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } RNA_string_get(op->ptr, "filepath", filename); if (collada_import(C, filename)) return OPERATOR_FINISHED; BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); return OPERATOR_FINISHED; }
static int screenshot_exec(bContext *C, wmOperator *op) { ScreenshotData *scd = op->customdata; bool ok = false; if (scd == NULL) { /* when running exec directly */ screenshot_data_create(C, op); scd = op->customdata; } if (scd) { if (scd->dumprect) { ImBuf *ibuf; char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); BLI_path_abs(path, BKE_main_blendfile_path_from_global()); /* operator ensures the extension */ ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); ibuf->rect = scd->dumprect; /* crop to show only single editor */ if (!RNA_boolean_get(op->ptr, "full")) { screenshot_crop(ibuf, scd->crop); } if (scd->im_format.planes == R_IMF_PLANES_BW) { /* bw screenshot? - users will notice if it fails! */ IMB_color_to_bw(ibuf); } if (BKE_imbuf_write(ibuf, path, &scd->im_format)) { ok = true; } else { BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno)); } IMB_freeImBuf(ibuf); } } screenshot_data_free(op); return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; }
static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); Object *ob = NULL; char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); ob = (Object *)BKE_libblock_find_name(ID_OB, obname); /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); return OPERATOR_FINISHED; }