SS - SVG Import tool (v1.12) [Layer Grouping, Masking, matched Colors and Adobe Illustrator/Affinity friendly]

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
EricTheFish
Posts: 85
Joined: Thu Jun 15, 2017 4:37 pm
Location: Lymm, UK

Re: SS - SVG Import tool [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by EricTheFish »

Just awesome Sam!!!!!

Finally we can import vectors and preserve colours and file scale in pixels! Maintaining groups and layer structure too is a massive bonus!

Thank you so much for your hard work! :D
EricTheFish
Artist, musician, animator, coder and dabbler in stuff
www.tech-nique.co.uk
User avatar
SuperSGL
Posts: 366
Joined: Wed Mar 11, 2015 2:55 am
Location: New Hampshire
Contact:

Re: SS - SVG Import tool [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by SuperSGL »

This looks great. Thank You!! I'm gonna have to re-learn CorelDraw! now. :lol: :D
"Animation is not the art of drawings that move but the art of movements that are drawn."
Norman McLaren


My Animations
User avatar
hayasidist
Posts: 3557
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: SS - SVG Import tool [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by hayasidist »

hayasidist wrote: Thu Oct 27, 2022 7:10 pm I'm on the road right now - back at base in a few days -- where I have an SVG file that Moho would never load properly ... this, I hope, will be the answer! Great work!
I'm back at base and have dug out the offending .svg which I've run through Sam's tool.

Here's the result:

Image

Compared to the Edge render (which is as close to the inkscape render as makes no real difference)
-- the Moho import is very poor especially head, left leg, scroll, toenails
-- Sam's version has a faint line at the nose/face boundary and the scroll strokes are broader. Minor glitch with the toenails and stroke widths in the sandals -- but a VAST improvement over native moho.

A couple of observations.

Sam's tool creates multiple layers (maybe only because of the way I used the tool???) which will make rigging and animating an svg import tricky -- is there a way to merge the vectors?? (I did have all the "consolidate" boxes checked as per the default)
(Moho creates 59 shapes but all on one layer - Sam's has 59 vector layers (assuming I counted correctly) in a number of groups.)

[EDIT: -- yeah -- it's the last checkbox: this does the trick! -- might be worth making that a default?!]

There are multiple "undo" checkpoints, so control-z -ing my way out of an import was not viable.
User avatar
SimplSam
Posts: 1060
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: SS - SVG Import tool [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by SimplSam »

hayasidist wrote: Sun Oct 30, 2022 4:17 pm -- Sam's version has a faint line at the nose/face boundary and the scroll strokes are broader. Minor glitch with the toenails and stroke widths in the sandals -- but a VAST improvement over native moho.
A couple of observations.
Sam's tool creates multiple layers (maybe only because of the way I used the tool???) which will make rigging and animating an svg import tricky -- is there a way to merge the vectors?? (I did have all the "consolidate" boxes checked as per the default)
(Moho creates 59 shapes but all on one layer - Sam's has 59 vector layers (assuming I counted correctly) in a number of groups.)
[EDIT: -- yeah -- it's the last checkbox: this does the trick! -- might be worth making that a default?!]
There are multiple "undo" checkpoints, so control-z -ing my way out of an import was not viable.
Thanks for test/post. I would love to see the source especially the feet and scroll bits. You can PM if reqd. I suspect they use a slightly different unit measure than the rest of the doc.

One of the intentions was to have the ability to retain grouping and layers - especially for characters with body parts - similar to how people set up characters in PhotoShop, and one option to decide what to consolidate or not - is the 'Only Unnamed' option. Now if you are importing from InkScape - you don't want this ticked - because InkScape names (IDs) all its elements and groups - and having that option with inkScape effectively disables consolidation during data load. Removing it should allow you to get rid of most neighbouring layers - without using the final post-op reduce which repeatedly attempts/performs a reduction (after all the layers are created in Moho) until it sees no change.

Undoing is a nightmare. I think i tried every combo of the PrepUndo commands and no good. Unfortunately - I think Moho makes a Undo check point (or similar) every time a layer is created. I would recommend just deleting the new group -or- importing into a new document - which can be discarded easily. Also, new doc tends to be faster - as the importing can slow down as the number of layers already in the doc increases.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
hayasidist
Posts: 3557
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: SS - SVG Import tool [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by hayasidist »

SimplSam wrote: Sun Oct 30, 2022 9:00 pm
Thanks for test/post. I would love to see the source especially the feet and scroll bits. You can PM if reqd. I suspect they use a slightly different unit measure than the rest of the doc.
This from my original post on the subject (from 2016!)

https://www.mediafire.com/?z1dghc7w62agwcm

the .zip has the original SVG, a render of frame 0 and an AS file from build 18907 -- the top of the head and the left leg / sandal are not right
User avatar
8BitHobo
Posts: 12
Joined: Fri Jul 06, 2018 8:02 pm

Re: SS - SVG Import tool (v1.10) [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by 8BitHobo »

One thing I did find, I dunno If its even something that needs fixed but might help someone out.
When you import an incomplete shape, Moho will make the non connecting line invisible, which is really handy. however I noticed it only sometimes imported this way.
I found out with some trial and error that If the anchor point doesn't have 2 handles it will import without a fill.
see below
Image
Shape on the Left has the default anchor points on the ends, Shape on the right has added handles to the anchor points if that makes sense
Image

Loving this tool it is a lifesaver for sure!
User avatar
SimplSam
Posts: 1060
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: SS - SVG Import tool [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by SimplSam »

hayasidist wrote: Mon Oct 31, 2022 8:45 am This from my original post on the subject (from 2016!) the .zip has the original SVG, a render of frame 0 and an AS file from build 18907 -- the top of the head and the left leg / sandal are not right ...
Thanks. I have fixed (v1.10+) an issue with transformation matrix scaling so that line-width is scaled accordingly. This addresses the fat line widths i.e. scroll. The odd shapes on the toe divides - appears to be a Moho draw/display issue when showing certain butted/unrounded line ends. If you change to 'round caps' they look better - or else you'll need to adjust the bezier handle/s.

8BitHobo wrote: Wed Nov 02, 2022 9:03 pm When you import an incomplete shape, Moho will make the non connecting line invisible, which is really handy. however I noticed it only sometimes imported this way. ...
Good catch. The 2 cases were represented differently in SVG (Polyline vs Paths). I have fixed (v1.11) an issue with Filled Polylines which appears to address the problem.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
hayasidist
Posts: 3557
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: SS - SVG Import tool (v1.11) [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by hayasidist »

thanks Sam. I got v1.11 - the line width problem is solved - good stuff... and thanks for the explanation about the raggedy ends on the toe dividers.

The "post-op reduce" option seems to behave differently??? I'm not 100% convinced I've chosen the same set of options -- but 1.11 won't consolidate named unless that checkbox is clear (but 1.00 did?????) - or maybe I'm mis-remembering (and I really can't be bothered to see if windows kept a 1.0 version somewhere to re-install to try ...)
User avatar
SimplSam
Posts: 1060
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: SS - SVG Import tool (v1.11) [Layer Grouping, Masking, matched Colors and Adobe Illustrator friendly]

Post by SimplSam »

hayasidist wrote: Thu Nov 03, 2022 2:15 pm thanks Sam. I got v1.11 - the line width problem is solved - good stuff... and thanks for the explanation about the raggedy ends on the toe dividers.
The "post-op reduce" option seems to behave differently??? I'm not 100% convinced I've chosen the same set of options -- but 1.11 won't consolidate named unless that checkbox is clear (but 1.00 did?????) - or maybe I'm mis-remembering (and I really can't be bothered to see if windows kept a 1.0 version somewhere to re-install to try ...)
No you are quite right. v1.00 incorrectly ignored Unnamed for PostOp, and now it doesn't. There is a small note in the changelog update of the initial post. This basically allows for better control, allowing you to maximally minimize anything that isn't labelled/named - thus allowing more freedom over what gets crushed.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
Post Reply