static int run_python_file(int argc, const char **argv, void *data) { #ifdef WITH_PYTHON bContext *C = data; /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */ if (argc > 1) { /* Make the path absolute because its needed for relative linked blends to be found */ char filename[FILE_MAX]; BLI_strncpy(filename, argv[1], sizeof(filename)); BLI_path_cwd(filename); BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)); return 1; } else { printf("\nError: you must specify a filepath after '%s'.\n", argv[0]); return 0; } #else (void)argc; (void)argv; (void)data; /* unused */ printf("This blender was built without python support\n"); return 0; #endif /* WITH_PYTHON */ }
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 */ }