diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2022-08-02 10:46:32 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2022-09-22 10:14:58 +0300 |
commit | 345cdf71e96ed4c26307417565154b57fc588884 (patch) | |
tree | 23b72144b25f47baad35de3d58e1cbeb4192b82e /source/blender/io | |
parent | dba599c8064731df4b68b7e983fba1ce2d41c4eb (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')
-rw-r--r-- | source/blender/io/gpencil/gpencil_io.h | 2 | ||||
-rw-r--r-- | source/blender/io/gpencil/intern/gpencil_io_import_base.cc | 17 |
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; } |