I'm creating an action for a plugin and adding it via MenuBar.addAction, passing in the action variable and the path like in the screenshot. I tried adding a condition to it but it did not seem to do anything, which is kinda strange (the button still shows in the skin and image format). Can I have some help? (Might be an awfully simple question, not sure)
#Action conditions not working
23 messages · Page 1 of 1 (latest)
sure
So I'm making a plugin that generates text. I moved the bone along an axis by a certain amount so it would be centered. It works well, but when I go and edit its position, it will snap to another location. My guess is because the cubes' position did not sync with the bone, as the cube was determined before that movement of the bone happened. I'm a little stuck on how to resolve this.
I guess when you move the group you are updating the view which you didn't update.
What i'm trying to say, did you call Canvas.updateView() ?
Yeah, see the first screenshot
Is it because I defined the cube positions beforehand, and moving the group doesn't affect that? Or I'm not sure
What's causing the snapping is when changing the origin of a group with it's children selected, the children will only visually move.
This is happening because your updating the view before finishEdit and the children are selected.
So group origins do not move it's children. you need to loop over it's children and add the offset.
try this
function formatText() {
const offset = textLength / 2;
textGroup.openUp().select();
textGroup.children.forEach(cube => {
cube.position[0] -= offset;
});
Canvas.updateView({groups: [Group.selected], transform: true});
}
It seems to bring a console error
It solves the bug of the snapping though, weirdly enough
However because of that error, undoing doesn't work
Also because it crashes at that point, the offset doesn't work
If you want I can send you my plugin file if it is easier
yeah that would be great
my bad,
cube.position[0] -= offset;
should be
cube.from[0] -= offset;
cube.to[0] -= offset;
Thanks so much for your help! It works well now.