Calling Mac programs from Python instead of from AppleScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dvschorre@sbcglobal.net

    Calling Mac programs from Python instead of from AppleScript

    When I'm running Script Editor, I can get Maya to draw a sphere by
    typing:

    tell application "Maya"
    execute "sphere"
    end tell

    When I try this using Python, I get this error message:

    IDLE 1.2.2
    >>app('Maya').e xecute('sphere' )
    Traceback (most recent call last):
    File "<pyshell#0 >", line 1, in <module>
    app('Maya').exe cute('sphere')
    NameError: name 'app' is not defined
    >>>
    Maybe I need to load some libraries first.

    Please help me to get started.

    Thanks
    Dewey V. Schorre

  • Kevin Walzer

    #2
    Re: Calling Mac programs from Python instead of from AppleScript

    dvschorre@sbcgl obal.net wrote:
    When I'm running Script Editor, I can get Maya to draw a sphere by
    typing:
    >
    tell application "Maya"
    execute "sphere"
    end tell
    >
    When I try this using Python, I get this error message:
    >
    IDLE 1.2.2
    >>>app('Maya'). execute('sphere ')
    >
    Traceback (most recent call last):
    File "<pyshell#0 >", line 1, in <module>
    app('Maya').exe cute('sphere')
    NameError: name 'app' is not defined
    >
    Maybe I need to load some libraries first.
    >
    Please help me to get started.
    >
    Thanks
    Dewey V. Schorre
    >
    Take a look at appscript:



    --
    Kevin Walzer
    Code by Kevin

    Comment

    • Python.Arno

      #3
      Re: Calling Mac programs from Python instead of from AppleScript



      On 19 mrt 2008, at 20:41, dvschorre@sbcgl obal.net wrote:
      >
      When I'm running Script Editor, I can get Maya to draw a sphere by
      typing:
      >
      tell application "Maya"
      execute "sphere"
      end tell
      >
      When I try this using Python, I get this error message:
      >
      IDLE 1.2.2
      >>>app('Maya'). execute('sphere ')
      >
      Traceback (most recent call last):
      File "<pyshell#0 >", line 1, in <module>
      app('Maya').exe cute('sphere')
      NameError: name 'app' is not defined
      >>>>
      >
      Maybe I need to load some libraries first.
      >
      I never used applescript more than to record some clicks but you might
      try

      tell application "/Applications/Autodesk/maya2008/Maya"

      (replace maya2008 with you app's foldername)
      or even

      tell application "/Applications/Autodeks/maya2008/Maya/Contents/MacOS/
      Maya"

      Please help me to get started.
      >
      like any other VFX app, maya is also adding python libs
      you can access MEL commands from a python library:


      Thanks
      Dewey V. Schorre
      >
      gr
      Arno Beekman

      Comment

      • has

        #4
        Re: Calling Mac programs from Python instead of from AppleScript

        On 19 Mar, 20:10, Kevin Walzer <k...@codebykev in.comwrote:
        Take a look at appscript:
        >
        http://appscript.sourceforge.net/

        Also, once appscript is installed, don't forget to import it before
        use:

        from appscript import *
        app('Maya').exe cute('sphere')


        HTH

        has
        --
        Control AppleScriptable applications from Python, Ruby and ObjC:


        Comment

        Working...