You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there,
first of all let me thank you for sharing this, along with ID and PS this information is extremely valuable!
I'm still a novice with Python, so maybe I'm asking something obvious and probably unrelated to this, but basically how can I inspect AI object properties and methods?
Doing a basic dir returns methods from the win32com.client.GetActiveObject class, so how can I get the details of the app.Documents object for example?
I don't know much (nothing probably is more appropriate) about the whole .NET/COM structure, Googling around I found that is not something easy to achieve, so I was wondering also what is your workflow and dev setup for scripting.
Thank you!
The text was updated successfully, but these errors were encountered:
There's not a straight forward way, have to read the documentation to understand what properties/attributes are available for a scripting object, or possibly a COM browser. For example, I've extracted the Python scripting object reference for Illustrator CC 2018 at doc_reference
Example: app.Documents object has properties like AddAddDocumentAddDocumentWithDialogOptionArrangeIndexItem
Thanks a lot for your answer and sorry for the very late reply.
I've searched a bit and found that basically what you say is true, but there are margin of improvements based on the working setup. For example this definition will ensure that the client object will generate a library file that will be used as a reference:
importwin32com.client# Get the Application object and ensure there is a library file generated # via makepy.py from win32com with COM class definitions and methodsAPP=win32com.client.gencache.EnsureDispatch("InDesign.Application")
This way the autocomplete mechanism should find the methods available for the object.
Unfortunately normal autocomplete mechanisms won't display the properties of the object, buried inside the _prop_map_get_ dict.
Related to this, I found a nice addition for IPython allowing auto complete for objects too.
# from https://stackoverflow.com/a/47613008/1262357fromIPython.utils.genericsimportcomplete_object@complete_object.when_type(win32com.client.DispatchBaseClass)defcomplete_dispatch_base_class(obj, prev_completions):
try:
ole_props=set(obj._prop_map_get_).union(set(obj._prop_map_put_))
returnlist(ole_props) +prev_completionsexceptAttributeError:
pass
Hope this can be useful, and that some one can improve and suggest more on this matter!
Hey there,
first of all let me thank you for sharing this, along with ID and PS this information is extremely valuable!
I'm still a novice with Python, so maybe I'm asking something obvious and probably unrelated to this, but basically how can I inspect AI object properties and methods?
Picking from your
Hello World
example:Doing a basic
dir
returns methods from thewin32com.client.GetActiveObject
class, so how can I get the details of theapp.Documents
object for example?I don't know much (nothing probably is more appropriate) about the whole .NET/COM structure, Googling around I found that is not something easy to achieve, so I was wondering also what is your workflow and dev setup for scripting.
Thank you!
The text was updated successfully, but these errors were encountered: