Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is there a method or function to list all the properties

Community Beginner ,
Jan 07, 2015 Jan 07, 2015

I'm looking for a method that's similar to Python's dir(x) which lists all the properties of an object. I'm looking to use this on After Effects Objects.

TOPICS
Scripting
3.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jan 07, 2015 Jan 07, 2015

You can use a for...in loop: for (var key in myObj) if (myObj.hasOwnProperty(key)){ ...}

But in ExtendScript there are also Reflection and ReflectionInfo objects. Those are not documented in the After Effects Scripting Guide but in the JavaScript Tools Guide (common to all Adobe scriptable apps).

For any ExtendScript object o you can query its reflection object. o.reflect is an object with properties and methods:

  • "properties" : an array listing all properties in o. Each entry is a ReflectionInfo ob
...
Translate
Advocate ,
Jan 07, 2015 Jan 07, 2015

You can use a for...in loop: for (var key in myObj) if (myObj.hasOwnProperty(key)){ ...}

But in ExtendScript there are also Reflection and ReflectionInfo objects. Those are not documented in the After Effects Scripting Guide but in the JavaScript Tools Guide (common to all Adobe scriptable apps).

For any ExtendScript object o you can query its reflection object. o.reflect is an object with properties and methods:

  • "properties" : an array listing all properties in o. Each entry is a ReflectionInfo object.
  • "methods" : an array listing all methods in o. Each entry is a ReflectionInfo object.
  • "name" : the class name of the object
  • "help" and "description" : some strings supposed to give some hint about the objects but those fields are invariably empty...
  • "find" : a method to find a specific property or method by its name

For what a ReflectionInfo looks like, see the JavaScript Tools Guide. (The main properties are "name", "dataType", "type")

For instance, if o is a layer position property:

o.reflect.methods = array of ReflectionInfo corresponding to all "ADBE Position" methods

o.reflect.find("setValue") => ReflectionInfo corresponding to the method "setValue"

o.reflect.find("setValue").name : "setValue"

o.reflect.find("setValue").arguments.length : 0     // SHOULD BE 1 ... arguments are not filled in 😞

Xavier.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2015 Jan 07, 2015

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 07, 2018 Mar 07, 2018
LATEST

You should accept the answer

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