473,378 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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').execute('sphere')
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
app('Maya').execute('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

Mar 19 '08 #1
3 1818
dv*******@sbcglobal.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').execute('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:

http://appscript.sourceforge.net/

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Mar 19 '08 #2


On 19 mrt 2008, at 20:41, dv*******@sbcglobal.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').execute('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:
http://www.autodesk.com/us/maya/docs...ython_API.html

Thanks
Dewey V. Schorre
gr
Arno Beekman
Mar 20 '08 #3
has
On 19 Mar, 20:10, Kevin Walzer <k...@codebykevin.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').execute('sphere')
HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

Mar 20 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tubby Tudor | last post by:
What is the best way to call one python script from within another python script? For example: one.py finishes succesfully and calls two.py which finishes OK and then calls three.py Thanks...
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
9
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so...
1
by: Michael Livingston | last post by:
Hi all, I'm currently working on a project to develop an online simulation model of the juvenile justice system in Queensland. We've developed the simulation model using the python module simPy...
2
by: lamthierry | last post by:
Let's say I have a python function do some math like the following: def doMath(self): self.val = self.val + 1 How can I call this python function from C++? Assuming I have some sort of...
29
by: Frank Millman | last post by:
Hi all I am writing a multi-user accounting/business system. Data is stored in a database (PostgreSQL on Linux, SQL Server on Windows). I have written a Python program to run on the client,...
4
by: soumitra.mishra | last post by:
Hi All, I want to call (execute) some python scripts from my C# program. I know that this can be done but have not idea how. The other option that I can think of is developing python web...
7
by: hlubenow | last post by:
Hi, recently there was a thread about hiding the python-script from the user. The OP could use http://freshmeat.net/projects/pyobfuscate/ H.
14
by: jmDesktop | last post by:
Hi, I'm trying to learn Python. I using Aquamac an emac implementation with mac os x. I have a program. If I go to the command prompt and type pythong myprog.py, it works. Can the program be...
2
by: vgkhle | last post by:
hi all How can diff python scripts be called from a main script which is again a .py? os.system("python external_script.py") works fine, but what if I want to handle the un handled...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.