Hello,
Here's a quick patch to add STL import/export ops wrapper around BKE_exotic.
Thanks,
Banlu.
--
.----. Banlu Kemiyatorn
/.../\...\ Free Software Yogi
|.../ \...| 漫画家 GZSC
|../ \..| http://groundzerostudiocomplex.blogspot.com
\/ \/ http://qstx.blogspot.com
Index: source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- source/blender/windowmanager/intern/wm_operators.c (revision 24920)
+++ source/blender/windowmanager/intern/wm_operators.c (working copy)
@@ -60,6 +60,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h" /* BKE_ST_MAXNAME */
#include "BKE_utildefines.h"
+#include "BKE_exotic.h"
#include "BIF_gl.h"
#include "BIF_glutil.h" /* for paint cursor */
@@ -1569,6 +1570,85 @@
}
+/* STL export */
+static int wm_stl_export_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int wm_stl_export_exec(bContext *C, wmOperator *op)
+{
+ char filename[FILE_MAX];
+
+ if(RNA_property_is_set(op->ptr, "path"))
+ RNA_string_get(op->ptr, "path", filename);
+ else {
+ BLI_strncpy(filename, G.sce, FILE_MAX);
+ untitled(filename);
+ }
+
+ write_stl(CTX_data_scene(C), filename);
+
+ return OPERATOR_FINISHED;
+}
+
+static void WM_OT_stl_export(wmOperatorType *ot)
+{
+ ot->name= "Export STL";
+ ot->idname= "WM_OT_stl_export";
+ ot->invoke= wm_stl_export_invoke;
+ ot->exec= wm_stl_export_exec;
+ ot->poll= WM_operator_winactive;
+
+ ot->flag = 0;
+
+ RNA_def_property(ot->srna, "path", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property(ot->srna, "directory", PROP_STRING, PROP_FILEPATH);
+}
+/* STL import */
+static int wm_stl_import_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int wm_stl_import_exec(bContext *C, wmOperator *op)
+{
+ char filename[FILE_MAX];
+
+ if(RNA_property_is_set(op->ptr, "path"))
+ RNA_string_get(op->ptr, "path", filename);
+ else {
+ BLI_strncpy(filename, G.sce, FILE_MAX);
+ untitled(filename);
+ }
+
+ if (BKE_read_exotic(CTX_data_scene(C), filename) == 0) {
+ BKE_report(op->reports, RPT_ERROR, "The file could not be read.");
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+static void WM_OT_stl_import(wmOperatorType *ot)
+{
+ ot->name= "Import STL";
+ ot->idname= "WM_OT_stl_import";
+ ot->invoke= wm_stl_import_invoke;
+ ot->exec= wm_stl_import_exec;
+ ot->poll= WM_operator_winactive;
+
+ ot->flag = 0;
+
+ RNA_def_property(ot->srna, "path", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property(ot->srna, "directory", PROP_STRING, PROP_FILEPATH);
+}
+
+
/* XXX: move these collada operators to a more appropriate place */
#ifdef WITH_COLLADA
@@ -2596,7 +2676,8 @@
WM_operatortype_append(WM_OT_collada_export);
WM_operatortype_append(WM_OT_collada_import);
#endif
-
+ WM_operatortype_append(WM_OT_stl_export);
+ WM_operatortype_append(WM_OT_stl_import);
}
/* called in transform_ops.c, on each regeneration of keymaps */
_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers