Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2022-08-02 10:46:32 +0300
committerAntonio Vazquez <blendergit@gmail.com>2022-08-02 10:46:32 +0300
commit670ced97589d3fc29feafb32e96d08541aa7b32e (patch)
tree552a0ea7a26c93ce79b942de9c5f9e3623148f14 /source/blender/io/gpencil
parentf263334529a56381adcebe8d55d829502db2c717 (diff)
GPencil: Allow import several SVG at time
For SVG is very convenient to be able to import several SVG in one operation. Each SVG is imported as a new Grease Pencil object. Also, now the SVG file name is used as Object name. Important: As all SVG imported are converted to Grease Pencil object in the same location of the 3D cursor, the SVG imported are not moved and the result may require a manual fix of location. The same is applied for depth order, the files are imported in alphabetic order according to the File list. Reviewed By: mendio, pepeland Differential Revision: https://developer.blender.org/D14865
Diffstat (limited to 'source/blender/io/gpencil')
-rw-r--r--source/blender/io/gpencil/gpencil_io.h2
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_import_base.cc17
2 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/io/gpencil/gpencil_io.h b/source/blender/io/gpencil/gpencil_io.h
index 215891e3e48..eb811fa2de8 100644
--- a/source/blender/io/gpencil/gpencil_io.h
+++ b/source/blender/io/gpencil/gpencil_io.h
@@ -35,6 +35,8 @@ typedef struct GpencilIOParams {
/** Stroke sampling factor. */
float stroke_sample;
int32_t resolution;
+ /** Filename to be used in new objects. */
+ char filename[128];
} GpencilIOParams;
/* GpencilIOParams->flag. */
diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
index 9b00fbaa027..18cbbceda0b 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
@@ -14,6 +14,7 @@
#include "BKE_material.h"
#include "ED_gpencil.h"
+#include "ED_object.h"
#include "gpencil_io_import_base.hh"
@@ -27,10 +28,22 @@ GpencilImporter::GpencilImporter(const GpencilIOParams *iparams) : GpencilIO(ipa
Object *GpencilImporter::create_object()
{
- const float *cur = scene_->cursor.location;
+ const float *cur_loc = scene_->cursor.location;
+ const float rot[3] = {0.0f};
ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uuid :
(ushort)0;
- Object *ob_gpencil = ED_gpencil_add_object(params_.C, cur, local_view_bits);
+
+ Object *ob_gpencil = ED_object_add_type(params_.C,
+ OB_GPENCIL,
+ (params_.filename != nullptr) ? params_.filename :
+ nullptr,
+ cur_loc,
+ rot,
+ false,
+ local_view_bits);
+
+ /* Set object defaults. */
+ ED_gpencil_add_defaults(params_.C, ob_gpencil);
return ob_gpencil;
}