GithubHelp home page GithubHelp logo

Comments (2)

lohriialo avatar lohriialo commented on May 20, 2024

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 Add AddDocument AddDocumentWithDialogOption Arrange Index Item

from illustrator-scripting-python.

GlassGruber avatar GlassGruber commented on May 20, 2024

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:

import win32com.client
# Get the Application object and ensure there is a library file generated 
# via makepy.py from win32com with COM class definitions and methods
APP = 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/1262357
from IPython.utils.generics import complete_object

@complete_object.when_type(win32com.client.DispatchBaseClass)
def complete_dispatch_base_class(obj, prev_completions):
    try:
        ole_props = set(obj._prop_map_get_).union(set(obj._prop_map_put_))
        return list(ole_props) + prev_completions
    except AttributeError:
        pass

Hope this can be useful, and that some one can improve and suggest more on this matter!

from illustrator-scripting-python.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.