Wednesday, July 24, 2013

Using Eclipse as Maya IDE

This post is going to be a little step-by-step guide to setup Ecplipse and use it as python IDE for Maya on windows7 (BTW I'm using  Maya 2013 x64). Well, let's begin!

What we need?


Eclipse Standard - http://www.eclipse.org/downloads/


Maya Editor script - http://www.creativecrash.com/maya/downloads/applications/syntax-scripting/c/eclipse-maya-editor


Setup:


1. Unzip eclipse-standard-kepler-R-win32-x86_64.zip (I downloaded the 64bit version but you can use the 32bit version if you don't have a x64 processor).

2. Unzip org.eclipse.EclipseMayaEditorProject.zip in a temp folder (after the installing we are not gonna need it anymore)


3. Enter in eclipse folder and execute eclipse.exe. Go to Help > Install new software

4. Press Add button and then in Local select the folder where you have unzipped EclipseMayaEditorProject.


5. It will appear as Uncategorized, select it and press Next. Accept license, etc.


Maya editor buttons:

  • Send entire contents to Maya
  • Send highlighted selection to Maya
  • Button menu to open various documentation
  • Reconnect Eclipse to Maya


6. Let's install PyDev! In eclipse go to Window > Preferences


7.  Go to Install/Update > Available Software Sites.. and press Add...

8. Type PyDev on Name and paste the url http://pydev.org/updates


9. Now, go back to Help > Install new software. On "Work with" choose PyDev and choose the 2 items. Press Next.


10. Choose "Keep my installation the same..." and press Next.

11. Select and accept certificates.



12. Configure the python interpreter on Eclipse. Go to Window > Preferences. On PyDev > Interpreter - Python... press "New.." button.

13. Browse and select where mayapy.exe is.


14. Select all the paths you will need and press OK.


15. Server setup to send info from eclipse to Maya. Go to Window > Preferences > Maya Editor Preferences. The default port is 7720.


16. Create a userSetup.py (if we dont have it) and add the next lines. The next time we open Maya will receive data from the port 7720.

import sys
import maya.cmds as cmds

newPath = "D:/+ENGINES/MAYA/Maya-Scripts"
sys.path.append(newPath)

if cmds.commandPort(':7720', q=True) !=1:
    cmds.commandPort(n=':7720', eo = False, nr = True)


17. Create a new Project. New > New > Project... and select PyDev Project


18. Select the Directory project, set Grammar Version to 2.6 and select mayapy.exe as Interpreter.


17. And finally the funny part!! Let's test it. Create a new file on our project folder and write a name (ex: test.py). It's important to add the .py extension.


18. Write some code and send to Maya pressing Ctrl+Enter or the menu button.


19. The result :)


This tutorial is based/inspired on rbublitz work on CreativeCrash:
http://www.creativecrash.com/maya/tutorials/using-tools-scripts/c/using-eclipse-as-a-maya-ide

Wednesday, July 3, 2013

Write and Read a XML in Maya with Python

It's been a while since the last post. I'm not in Andorra anymore... so I have been working on new stuff. In this case I bring to you 2 simple scripts to write and read a xml file in Maya using Python.

Some example uses:

  • Construct our game level on maya and import it to the game engine with the xml file. 
  • Copying animation poses.
  • Copying light settings.
  • ... 


Write the XML file:
from xml.dom.minidom import Document
import maya.cmds as cmds

doc = Document()

root_node = doc.createElement("scene")
doc.appendChild(root_node)

# Selection: 
# grab all selected objects
#selection = cmds.ls(sl=True)

# grab all visible objects, which type is transform
selection = cmds.ls(type="transform", v=True )

for object in selection:
    
    # create object element
    object_node = doc.createElement("object")
    root_node.appendChild(object_node)
    
    # BEWARE: after freeze transformations the translate is a bit tricky
    #object_translation = cmds.getAttr(object + ".translate")[0]
    object_translation = cmds.xform(object, query = True, worldSpace = True, rotatePivot = True) 
    
    # set attributes
    object_node.setAttribute("name", str(object))
    object_node.setAttribute("translateX", str(object_translation[0]))
    object_node.setAttribute("translateY", str(object_translation[1]))
    object_node.setAttribute("translateZ", str(object_translation[2]))
    

xml_file = open("C:/Temp/test.xml", "w")
xml_file.write(doc.toprettyxml())
xml_file.close()

print
print doc.toprettyxml()

Reading the XML file:
from xml.dom.minidom import parse

dom = parse("C:/Temp/test.xml")

 # visit every object node 
for node in dom.getElementsByTagName('object'): 
    
    # method 1: using keys
    attrs = node.attributes.keys()
    for a in attrs:
        pair = node.attributes[a]
        print (str(pair.name) + " = " + str(pair.value))
    print
    
    #method 2: by attribute name
"""        
    print str(node.getAttribute("name"))
    print str(node.getAttribute("translateX"))
    print str(node.getAttribute("translateY"))
    print str(node.getAttribute("translateZ"))
    print
"""

Based and inspired from Luiz Kruel's script

Monday, March 11, 2013

Stargate SG1: Unleashed is coming!!

Stargate SG1: Unleashed will be released on March 14 where I've worked as gameplay programmer. You can find the teaser and ingame trailer in the portfolio section.

Here the game promo description:

Monday, January 28, 2013

Animating in Blender

I broke my right arm doing snowboard in Andorra so... I have spent my free time learning and watching some rigging and animation tutorials, among other programming stuff. The objective: make my own short-film.

I choose Blender over other 3D apps because it's opensource and has a lot of potential. It's an amazing software and free. You can support then buying books or DVDs in the Blender shop.

Well, this was my first try with CG Cookier Flex Rig. It has no sense, but I wanted to animate and render it.



Test - doing a simple animation with Blender from orekamenpe on Vimeo.

Hi to my visitor from Dallas!

Don't be shy and leave a comment :P.

Saturday, June 9, 2012

Faltan bota...

Badaramat urte pare bat Euskal Herritik kanpo, ta gero ta gehixau botatzen dot faltan. Batez ere han laga ditudan pertsonak...

Hasieran, Bartzelonan nengoenean, pilo bat gauza zeuden egiteko, ikusteko,... beti zegoen zeozer. Hiri handiko bitzitza jota azkar mugitzen da. Dana berehala egiten da, eta ez bada suertatzen beste bat agertzen da. Gainera, dana komunikatuta dago. Garraiobideak kristonak dira, ez dakazu kotxea zertan erabili behar!!

Oin, Andorran gauzak poliki mugitzen dira. Denbora dexente daukat nire gauzetan pentsatzeko ta nabari dot nire bizitza erritmoa moteldu egin dela. Hau ez dakit zelan hartu ze Bartzelonan kriston estresakin bizi nintzan jajaja (baina azken lanaren errua izan da gehien bat).

Lekotu beharrean nago oraindik... ta zer egiteko aurkitu behar dot jajaja. Jakin dudanez jendia lanean oinarritzen du denbora guztia, ta neguan eskiatzera juten dira. Baina udaberrian gauz!!

En fin, ikusikou denborakin zelan suertatzen den abentura hau!


Sunday, April 15, 2012

Busy, busy, busy...

The last months I have been working on a secret project that will be released early in May. I'm very excited about this project and I wish I could show you anything... but I beg you some more patience :P.

More news coming soon...

Here you have my new high score on Triple Town! It's the only game I can play, because the limited turns... hohoho.