Hi,
I have a hard time trying to find documentation of the API, I just want to select shapes that match the size of the shape I have selected.
How do I use EASEL.selection.selectObject();
?
Hi,
I have a hard time trying to find documentation of the API, I just want to select shapes that match the size of the shape I have selected.
How do I use EASEL.selection.selectObject();
?
Are you looking to match shapes by their bounding box size or an exact match of the path data?
Bounding box its ok I guess
I am running Deepnest to optmize the svg layout but I lose the “outline” “on-path” etc features, so an easy way would be to select all the similar ones and change that. But how
So looking into it a little bit… There is no api for the UI, you can only create an app.
But that being said and with what you’re trying to accomplish here is the bare-bones code that you would need to accomplish this task:
var properties = [{
type: 'list',
id: "Cut Type",
value: "fill",
options: ["fill", "outline"]
},
{
type: 'list',
id: "Outline Style",
value: "on-path",
options: ["on-path", "outside", "inside"]
},
];
var getSelectedVolumes = function(volumes, selectedVolumeIds) {
var selectedVolumes = [];
var volume;
for (i = 0; i < volumes.length; i++) {
volume = volumes[i];
if (selectedVolumeIds.indexOf(volume.id) !== -1) {
selectedVolumes.push(volume);
}
}
return selectedVolumes;
};
var executor = function(args, success, failure) {
var params = args.params;
var volumes = [];
var selectedVolumes = getSelectedVolumes(args.volumes, args.selectedVolumeIds);
if (selectedVolumes.length > 1) {
failure("Please select only 1 volume.");
return false;
}
args.volumes.forEach(function(vol) {
if (vol.shape.width == selectedVolumes[0].shape.width && vol.shape.height == selectedVolumes[0].shape.height) {
vol.cut.type = params["Cut Type"];
vol.cut.outlineStyle = params["Outline Style"];
volumes.push(vol);
}
});
success(volumes);
};
Also, API documentation is found here: http://developer.easel.com/
(So long as you are using v2 of the API)
Yes I saw that but I didn’t thought it was the documentation because is so short. Thanks for the code, I’ll take a look. looks like a very nice alternative.
Yeah it’s taken a lot of trial and error to figure out how the api works. Hope the code works out for you.
I ended writing a small script that adds the function to the UI:
Oh boy, you’ve just opened up a new door for me! Think of the chaos I can cause now!
Much thanks!
Unleash the kraken!
It is kinda a continuation of: Adding new functionality to Easel: Quick app search - Easel - Inventables Community Forum
and they added a similar search to apps after few months