Transition information from XD file

Hi ,

Can someone please help me out to get transition information from XD file in Javascript.(custom plugin).

Thanks in advance !!!

1 Like

Hi @Ashish,

Since XD 19, you can use the interactions module for retrieving all transition data for a document (see https://adobexdplatform.com/plugin-docs/reference/interactions.html?h=interaction). Also, since that release, you can get per-node data by using SceneNode.triggeredInteractions, see https://adobexdplatform.com/plugin-docs/reference/scenegraph.html#scenenodetriggeredinteractions--arrrayinteraction.

With this, you can, e.g., retrieve such info like this:

const interactions = require('interactions');

function main(selection, root) {
    console.log('Selection node transition data:');
    const selectionInteractions = selection.items[0].trigerredInteractions;
    console.log(JSON.stringify(selectionInteractions));
    console.log('All interactions:');
    console.log(JSON.stringify(interactions.allInteractions));
}

module.exports.commands = { main }

I hope this helps :wink:, and, by the way: Welcome to the forums :wave::slightly_smiling_face:

2 Likes

Hi @pklaschka ,

Thanks for your help. i used Interactions module and got the below JSON
“interactions”: [
{
“trigger”: {
“type”: “tap”
},
“action”: {
“type”: “goToArtboard”,
“destination”: {
“_childrenList”: {}
},
“preserveScrollPosition”: false,
“transition”: {
“type”: “push”,
“fromSide”: “L”,
“easing”: “ease-out”,
“duration”: 0.3
}
}
}
]

in the above JSON, Destination Artboard node info not exists. May you please sugggest me how to get these information.

Thanks,
Ashish

@Ashish

destination field should give you that information. Try console.loging that property only (drill down to it). Ref: https://adobexdplatform.com/plugin-docs/reference/interactions.html?h=interactions

Can I create an interaction to a new element??
I mean, if I create for example a new Text(element) and I want with a click in that Text, it goes to some Artboard, is that already possible??

1 Like

@victor_puentes
No. Unfortunately, interaction data still is read-only. Cf. interactions ¡ Adobe XD Plugin Reference

APIs provide read only information about the document’s interactive prototype mode

(as of April the 2nd, 2020).

According to the discussion in Ability to move interactions from node to node - #4 by kwiksher, a writing API, however, at least seems to be in the works:

1 Like

Thank you for answering so quickly :+1:

1 Like

Hello, I am having trouble getting the whole interactions thing to work.
let interactions = require(‘interactions’);
let allInteractions = interactions.allInteractions;

trace(allInteractions.length);
trace(${allInteractions.length}); //returns 0 even though I do have interactions in my artboard.

trace(incomingInteractions ${xdNode.incomingInteractions}); //incomingInteractions is null

trace(triggeredInteractions ${JSON.stringify(xdNode.triggeredInteractions)}); // triggeredInteractions is null also.

All these return null or 0 (in case it is a list) I can’t seem to find a way to get those interactions from an SceneNode, and I am sure they do have them bc of two things:

  1. I set them up in xd, and I verified they worked on the preview.
  2. I know the scenenode is the one I am trying to get the interactions from bc it’s children change depending on the component’s actual state when I run the plugin.

Your help will be greatly appreciated.