Highlighted

[Script] Only affect changed properties?

New Here ,
Oct 17, 2020

Copy link to clipboard

Copied

Is there a way to make a script that only affect the properties that are changed (the ones that appear when you hit U U on a layer.)

 

Thank you!

TOPICS
Scripting

Views

46

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

[Script] Only affect changed properties?

New Here ,
Oct 17, 2020

Copy link to clipboard

Copied

Is there a way to make a script that only affect the properties that are changed (the ones that appear when you hit U U on a layer.)

 

Thank you!

TOPICS
Scripting

Views

47

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 17, 2020 0
Most Valuable Participant ,
Oct 17, 2020

Copy link to clipboard

Copied

There is no function to query the default property values, so I don't think it is easily doable. If at all you need to implement your own compare lists and whatnot to check whether props have expressions, keyframes, masks actually have shape paths and so on. This could end up being a massive undertaking. Therefore it would be smarter to focus on the actual tasks at and and fetch the relevant properties only, not trying to have a generic bit of code that combs over everything.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2020 0
New Here ,
Oct 17, 2020

Copy link to clipboard

Copied

Thank you for the fast answer!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2020 0
Engaged ,
Oct 17, 2020

Copy link to clipboard

Copied

There is a property.isModifed attribute.

"When true, this property has been changed since its creation."

http://docs.aenhancers.com/properties/propertybase/

But you'd still have to use a way of cycling through all properties to see if they have been modified. As Mylenium says, it's no easy task.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 17, 2020 1
Community Beginner ,
Oct 19, 2020

Copy link to clipboard

Copied

Here you go!

This works on the properties of a normal layer for position, scale and such.

Modify for use on TextLayers and ShapeLayers.

function FindChangedProperties(obj, max, lvl, msg) {
	lvl = lvl ? lvl+1 : 1;
	msg = msg ? msg : "";
	for(i=1; i<=obj.numProperties; i++) {
		try {
			var prop = obj.property(i);
			if(prop.isModified) {
				//do something
				if(prop.propertyType === PropertyType.PROPERTY) {
					msg += prop.name;
					try {
						msg += " : "+prop.value.toString();
					} catch (e) {}
					msg += "\r";
				}
				//go deeper
				if (lvl < max && Object.isValid(prop)) {
					msg += FindChangedProperties(prop, max, lvl, msg) + "\r";
				}
			}
		} catch (e) {}
		
	};
	return msg;
};
var msg = FindChangedProperties(app.project.activeItem.selectedLayers[0], 2);
alert("Modified Props\r"+msg);
​

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 19, 2020 0