WP Import from Spine JSON
Import Assets from Spine JSON (To import from Affinity, Krita, Spine, Photoshop, AfterEffects, Gimp etc.)
Category: Layers
Published: Oct 16 2023, 08:04
Last Edited: Dec 10 2023, 07:28
Created for Moho Version: 14.0
Returned Version: 1.1.3
Edition Downloads: 779

IMPORT FROM AFFINITY DESIGNER OR PHOTO
Tutorial video on how to use the script to import Affinity (Photo/Designer) Layers as Image Layers with cropped images in Moho:
IMPORT FROM KRITA
Tutorial video on how to use the script to import Krita Layers as Image Layers with cropped images in Moho:
IMPORT FROM SPINE
Short tutorial video on how to use the script to import Region Attachments (images) and their transformations at the setup pose from Spine as Moho 14 Layers:
IMPORT FROM PHOTOSHOP, AFTEREFFECTS, GIMP ETC.
There are spine JSON export scripts for many programs. Look here for export scripts made by Esoteric Software (creator of Spine) for at least Photoshop, AfterEffects, Gimp etc. : https://github.com/EsotericSoftware/spine-scripts
----------------------------------------------------------------------------------------------------------
DISCLAIMER
----------------------------------------------------------------------------------------------------------
I've tried my best to make this plugin as stable and useful as possible. But please bare in mind; I'm sharing this script, which I've created for doing my own animation work, for others to use for free as I think this could help others too. But this script/this plugin is 'as is'. There might be an update in the future, but that's not garanteed and there is no active support. Nor a garantee (always backup first!). That said; I hope you enjoy it and it helps you with your animation work!
----------------------------------------------------------------------------------------------------------
VERSION HISTORY
----------------------------------------------------------------------------------------------------------
1.1.3 [current]
- Changed: Made compatible with newer utils file
1.1.2
- Changed: Made compatible with newer utils file
- Added: Retina icon
1.1.1
- Fixed: Typo
1.1.0
- Added: If there is bone data available it now imports bones and creates the same skeleton in Moho, complete with transforms translation, rotation and scale*. Bone shearing will be ignored tho. *: Different scaling for X and Y isn't supported. If a bone has a different scale value for x and y then the x-value will be used as scale in Moho.
- Changed: Improve warnings output
- Changed: different scaleX and scaleY values in bones aren't supported. The image transformspath to calculate images from bones in the tree is now calculated accordingly to keep image transforms the same as the bone transformations.
1.0.0
- Initial release. Imports and transforms images.
----------------------------------------------------------------------------------------------------------
ABOUT THE CURRENT VERSION
----------------------------------------------------------------------------------------------------------
How to install the script in Moho?
* Click on the 'Download for Install Script command''-button below to download the zip-file
* Unzip the downloaded file
* Start Moho
* Open the Scripts menu --> choose 'Install Script' --> Browse through the unziped folder and choose the folder named 'wp_spine_import_for-moho-install-script-command' --> It should now install the script
* Once installation is done Moho shows a dialog saying 'Installation Complete!'
* Restart Moho (only after restarting the tool will become available)
* You should now see the tool with the spine logo in the tools panel. Ready to use!
Why I created this script?
1. Make exporting layers from Affinity way easier and quicker
I started this script because Affinity (Mainly Photo and Designer) (Affinity website) offers a great way to export all layers to individual cropped images on disc, together with a spine.json file containing all layer data, like positions of all images.
This makes it extremely easy and fast to import all layers and images directly into Spine. However, Moho so far couldn't open these spine.json files. So it took a long time to import all these individual images to moho layers and position all these layers in the right spot. By using this script this now is as easy in Moho as it is in Spine and it's now importing and positioning all images/layers via the spine.json file with a single click so we don't have to spend lots of time importing images anymore and can start rigging right away.
2. Make exporting layers from Krita way easier and quicker
There is also a very useful script for Krita (Krita Website) around to export Krita layers to spine.json. Although I didn't tested the outputed spine.json with that script yet, it should work just fine too. You can find it here: Krita-to-spine script download
Not shown in the tutorial video above, because I wonder if it's useful in Spine, but it's even possible to add special naming to Krita group layers that the export script recognises to automatically create bones etc.. See the krita-to-spine script readme (follow the download link) for more information.
3. Make importing images from spine.json possible too?
After having the import for Affinity-generated spine.json files working I wondered how far I could take this to import spine.json files generated by Spine itself (Esoteric Software/Spine website). These files are more complicated because Spine also has a complete skeleton system, like Mohos bones, and images inside spine files have a hierarchical tree structure with bones. But also all bones can have translations/offsets, rotations, scales and shear values. Even images bound to bones can have these transformations applied. And they all influence each other via parenting.
Besides this in Spine it's possible to tint images, which isn't currently possible in Moho.
Spine has more features, like multiple skeletons in a file, multiple skins per skeleton, meshes, several other types of attachments besides images and transforms. But these aren't supported by this script (yet?) and is way over the original use case for the script, which was to import all layers as images from Affinity.
All images are imported now and get the right transformations (except shears) in Moho, just like in Spine. And when it finds tinted images/slots in the spine.json file it generates extra reference tint-layers in Moho to have a similar effect. At the moment these aren't having exactly the same result/blending, so these will probably be tweaked later. But at least it imports. And I consider this a feature that won't be used by many people.
4. Importing from other software (Photoshop, After Effects, Gimp etc.)?
There are Spine JSON exporters around for Photoshop, Gimp and other software too. So basically any software you have and has an export script to export to Spine JSON fileformat is with this script now able to export to Moho. Esoteric Software, the creators of Spine, have a repository with some exporter scripts for several programs here: https://github.com/EsotericSoftware/spine-scripts

What does the script do?
This first version generates a group with image layers. The group is transformed to a bone layer in moho, but doesn't contain bones yet. A later version will probably add an option to load the bones too, if the spine.json contains bone data.
The bone data in the spine.json is however used to determine the transformations of the images to position/rotate/scale them on the right spots in Moho.
How to use the script?
This is a new script! Backup your moho file before use just to be sure.
Hit the tool button, browse the spine.json file (only json files are supported)
How to export Affinity or Krita layers, or Spine content to spine.json?
See tutorial videos above!
Supported Moho version
Tested in Moho 14.x.
About support of spine.json features
Everything imports fine from files generated by Affinity
About more advanced spine features as generated by Spine:
- Only the default skin (skin named 'default') will currently be imported. Multi-skin is not supported.
- Imports region attachments (= image without a mesh). Images having a mesh will not be imported.
- Like spine the valid supported image file formats are png, jpg and jpeg (will search for these formats in that order, like Spine).
- Positions, rotations and scaling* of images and bones are calculated hierarchical through the bones to their final position.
- *) Different/Individual scaling for X and Y on bones isn't supported. If a bone has a unequal values for scaleX and scaleY then the scaleX value will be used as scale for that bone in Moho.
- Shear on bones aren't currently supported.
- Constraints aren't supported.