Feb 5 2014

PySide QThread and Dynamicly updateing ui’s

 

I’ve recently have been diving more in depth into qthread and how it can help make  GUIs  more interactive, specially when dealing with large data sets, where the programer might want to offload the data collection and processing methods to secondary threads as not to lock up the ui.

I’m still kind of new to the subject, so it’s taken me a while to get a clean working example, and how to set this up. I’ve used q thread before to achieve the effect, but it’s always been hard to know if my over understanding and approach to the method is the most optimized. after lot’s of online digging i found this approach to dealing with threading to work pretty well and be relatively easy to setup.

enjoy!

'''
testing thread ui
by Carlos Anguiano
'''
from PySide import QtCore,QtGui
import sys, random

#inherit from Qthread and setup our own thread class
class upateThread(QtCore.QThread):
    progress = QtCore.Signal(str) #create a custom sygnal we can subscribe to to emit update commands
    def __init__(self,parent=None):
        super(upateThread,self).__init__(parent)
        self.exiting = False

    def run(self):
        while True:
            self.msleep(10)
            self.progress.emit(str(random.randint(0,100)))

class myDialog(QtGui.QDialog):
    def __init__(self,parent=None):
        super(myDialog,self).__init__(parent)
        self.resize(200,0)
        self.qlabel = QtGui.QLabel(self)
        self.qlabel.setText('Processor:')
        self.qlabelSt = QtGui.QLabel(self)
        self.btn = QtGui.QToolButton(self)
        l = QtGui.QVBoxLayout(self)

        l.addWidget(self.qlabel)
        l.addWidget(self.qlabelSt)
        l.addWidget(self.btn)

        self.btn.pressed.connect(lambda :self.qlabelSt.setText(str(random.randint(0,100))))

        self.setupUpdateThread()

    def updateText(self,text):
        self.qlabel.setText('random number: '+text)

    def setupUpdateThread(self):
        self.updateThread = upateThread()
        #connect our update functoin to the progress signal of the update thread
        self.updateThread.progress.connect(self.updateText,QtCore.Qt.QueuedConnection) 
        if not self.updateThread.isRunning():#if the thread has not been started let's kick it off
            self.updateThread.start()

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    win = myDialog()
    win.show()
    sys.exit(app.exec_())

Oct 4 2013

Python in 3ds Max 2014 first impressions..

Well folks, it’s finally here… just a few days ago Autodesk released it’s 3dsmax 2014 extension to those who are members of the subscription program.

This extension release is something that I’ve been very excited about ,and have been looking forward to  ever since the new features were first announced.

Well thankfully the wait is over. I’ve spent some time today checking out the new implementation trying to figure out what this update will mean to future mango development for 3ds max (which I would rather do in python and PySide so that apps can float between Max, Maya, Nuke).

Anyway here are some of my first impressions along with some snippets from today’s familiarization session, I hope they might be insightful.

This is not Blur Python

While evaluating the new python implementation in max 2014, it becomes very hard not to compare it to Blur python. They are both CPython implementations. But that’s about where the similarities end. If you have experience working with Blur Python this first installment of 3dsmax python by autodesk is going to be somewhat of hard pill to swallow.
Unlike Py3dsMax(blur python), maxPlus (autodesk python) does not really expose the same set of libraries and methods that people familiar with maxscript already know and love. Instead it exposed a very small (it’s actually pretty large) subset of the max SDK, and relies heavily on the idea, that programers will do most of the max interactions by writing python string containing max script code.
This string are then to be evaluated by “maxPlus.Core.EvalMAXScript” python method. In my opinion this will alienate allot of people.

  • Those who are familiar with maxscript but are new to python will have to learn a whole new way of working with the limited set of exposed functions, and a brand new methodology behind creating and manipulating objects and data in max. Everything you know about max-script is now obsolete.
  •  Those who looked at python as a bridge to write tools for max with out having to learn maxscript will still have to learn maxscript to access the majority of functions and methods available via maxscript.

I’m hoping that the awkwardness of MaxPlus is just due to it’s infancy, and that in the next year or so it will be expanded to equal or even best blur python. At first glance it seems Autodesk really did the bare minimum. We can only hope that this was a time limitation, and that they will continue to devote time to growing the max python ecosystem.

No Python.import

One of Blur Python’s coolest features was the ability to import python modules right into maxscript via the “python.import” method.
This was really great for production, since any max scripter could use python libraries straight in maxscript with out knowing anything about python. For anyone that has used this feature to quickly harness the power of python external libraries inside of their native maxscript code, this will more than likely be very sad news. I really hope Autodesk can bring this feature back since it opens up the power of python to a much larger sets of users.

Where is PySide/PyQt?

Well not surprisingly Autodesk has decided not include PySide or PyQt with it’s new implementation of Python. The fact that PySide doesn’t come integrated with this first release of python is incredibly disappointing. Especially since I have been running Blur Python (Without Qt) in 2014 for months now, the Autodesk implementation of Python is a major downgrade when compared to Blur Python. This alone will keep me from upgrading current mango clients to this new extension (mango currently uses blur Python).

I really hope that they will spend sometime integrating PySide by the time 3ds max 2015 comes out. Switching from Py3dsMax (Blur Python) to MaxPlus (Autodesk Python) is going to be painful, but a properly supported PySide module would really make the switch worth it.

DIY PySide?

While Autodesk failed to give us an easy to use PySide implemention similar to the ones natively supported in Nuke and Maya, they were nice enough to include some documentation that the more technically inclined can use to compile PySide (that’s right! you going to compile stuff!!) against the proper builds of qt and python that are now bundled with max (Python 2.7.3, Qt 4.8.2). From the documentation hints, I was able to actually make my own image of PySide that allows me to start using Qt inside of 3dsmax 2014. This process while a bit technical and esoteric, is actually not to difficult and requires zero programing experience, I recommend that anyone interested actually try it. If you are too lazy to do it your self,  you can try using my compiled installer (use it at your own risk) , which can be found here .
After installing my newly compiled PySide build, I set to do some basic testing using the following snippets. My initial test was just a QMessageBox…

st = "
import sys
import MaxPlus
from PySide import QtGui, QtCore
msg = 'hello'

n = MaxPlus.Core.GetRootNode()
msg = 'objects in scene:\\n'
for c in n.Children:
	msg += '%s%s%s' % ('\\t',c.Name,'\\n')

msg = str(msg)

app = QtGui.QApplication.instance()
if app == None:
	app = QtGui.QApplication([])

QtGui.QMessageBox.about(None,'PySide',msg)
"
python.execute st

This messagebox was just a way to test that the PySide was actually being loaded and working in max, and that python could collect some data from max and pass it to Qt.

While I was writing this snippet there were a few things that I noticed that seem strange.

  • Modal windows have no effect on the max session. It’s not really clear to me how to parent Qt windows to the max application it self. So modal windows which would usually freeze max until the user close the dialog are not actually freezing max.
  • Executing a QApplication is not needed, doing so actually really screws up the max environment, the behavior makes seem as if qt and python are not running on the main max thread. But I’m more than likely just missing a step.

Other than those strange oddities PySide seems to actually be working. Even with out executing the QApplication I can launch dialogs add widgets via the .show() and exec_() methods. exec_() seems to have absolutely no effect on the max session itself (same as qmessagebox) which is very strange.

Here’s my second test a simple Dialog snippet example…

st = "
from PySide import QtCore, QtGui

class mApp(QtGui.QDialog):
	def __init__(self,parent=None):
		super(mApp,self).__init__(parent)
		vL = QtGui.QVBoxLayout(self)
		for i in range(5):
			cb = QtGui.QComboBox(self)
			vL.addWidget(cb)
		btn = QtGui.QPushButton(self)
		vL.addWidget(btn)
		btn.setText('press me')
		btn.clicked.connect(lambda:QtGui.QMessageBox.about(self,'Modal Test','is this modal?'))

app = QtGui.QApplication.instance()
if app == None:
	app = QtGui.QApplication([''])

ui = mApp()
ui.show()

"
python.execute st

here’s what it looks like..

 

Conclusion

Even though Autodesk’s first version of Python for max leaves a lot to be desired, I’m vary happy that Autodesk has actually taken on the task of bringing this very important feature to max. Not having to depend on a 3rd party to provided python support will make it much easier for studios to migrate to feature version of 3ds max with out fear of breaking their pipeline. With today’s need for python and Qt in the never ending realm of unified pipelines an awkward implementation of python, and a ghetto home brew of PySide are much better than NO PYTHON and NO PYSIDE.

I’m looking forward to experimenting with Mango and 3ds Max using this setup, and seeing what new knowledge tips and tricks the community will bring forth in the upcoming months…

Until next time..

Stay frosty my friends 🙂


Sep 12 2013

Mango Version Viewer & Dependecy Tracking

I’m happy to share with you guys a screen grab of the dependency viewer for “mango version viewer”.. view the versions associated with any element being reviewed any time any place with out out having to open the work-files them self’s
dependencies are hierarchical so that you can easily view them in a natural way…

 


Sep 12 2013

Rigging Demos

Some one had asked for samples of animation setups i have done through out my career..
i lost allot of my work a few years back when my external drive died.. but recently i found this videos, which are a bit dated, but still hold a special place in my hart 🙂
anyway, if you are bored and looking for something to bore you even more check them out 🙂
httpv://youtu.be/FO3JVHBdwI8
httpv://youtu.be/6fQINze9c0I
httpv://youtu.be/307PdswKUJs


Sep 1 2013

Mango Phase 1

Some time has passed since my last Mango related post. Thankfully, I have made significant progress. I’m glad to announce that Mango Phase 1 will be completed in the next few weeks. There are three important developments which I will address in this post: resource-tracking, the Software Launcher, and user applications and tools (stand-alone and software-integrated).

 

Mango’s Resource-Tracking

Mango Phase 1 has been about setting up the structure on which the entire pipeline is based. I implemented base APIs that will support all of the core stand-alone applications and software-integrated tools. The two most significant APIs in this stage of development are:

  • versionTracker (API for versioning of resources with database backend)
  • namingAPI (API for generating the folder structure that host the files that make up the files associated with versions made by versionTracker)

These two main components come together to create a resource-tracking system. In Phase 1, the development of the resource-tracking system has been focused on the needs of smaller studios in rapid production environments. This focus allows smaller studios to start using resource-tracking without being overly intrusive or creating a bottleneck for the artist by over-departmentalizing the process. To achieve this implementation, Mango Phase 1 concentrated on establishing the standards and practices necessary for creating and tracking the main resource types that are the most important in the “generalist” environment. In particular, I have focused on artist “work files”, “render elements”, and “shot plates.” In Phase 2, I will move toward more detailed resource-tracking and implement new resource types for “models”, “rigs”, “animation caches”, “cameras,” and “shaders.”

Mango’s Software Launcher

The Software Launcher is the common entrance to the pipeline. It is a stand-alone application that allows supervisors to control the software configuration by creating unique profiles for their projects. These profiles control which software, plug-ins, third party tools, and extensions are used by artists on their projects. Profiles allow artist to jump between projects, while guaranteeing that every artist under the same project has the same set of tools. Moreover, this profile mechanism allows supervisors to adopt new software or plugin versions without unintended negative effects on concurrent projects.  The Software Launcher and its profile mechanisms means that studios no longer have to rely on IT to push plug-in installations over large networks via more traditional time-consuming means that can be unreliable (e.g., MSI, Psexec, manual installations).

The connection between Mango and the artist’s software relies on the modular plug-in distribution system of the Software Launcher. Mango and its tools get attached to the target application via the “LosPipeLine” Software Launcher module which should be part of every Software Launcher profile. The Software Launcher also offers and optional command line mode. This mode is used to apply the profile-based software configuration approach to network rendering solutions, such as Thinkbox’s Deadline.

User Applications ( stand alone and software-integrated)

Additionally, the deployment of Phase 1  focused on the “hand off” of  resources across the different disciplines of the shot creation process (e.g., how a lighter hands off lighting elements to a compositor). Mango is composed of several applications and tools, both stand-alone and software-integrated. These tools are easy-to-use interfaces for artists, supervisors, and managers to facilitate the adoption of the Mango workflow. Here’s a list of the initial set of applications and tools that are bundled with Mango Phase 1:

  • Project Manager (stand-alone)
    • Simple interface for quickly creating the base directory for a new project
    • Allows for adding sequences and shots at anytime to any project

 

  • Workspace Manager (Integrated with 3ds max, maya, and nuke)
    • Simple interface for creating and navigating artists’ work areas, work files, and snap shots

  • Render Element Farm Submission Tool (Integrated with 3ds max via custom render pass manager)
    • Integrated element publishing and dependency tracking

  • Comp Central (Integrated with nuke)
    • Interface for browsing, importing, and updating render elements, plates, and cameras related to a shot directly from nuke

  • Element Publish (Nuke)
    • Publish comp, precomp, paint resources out of nuke
    • Automatically configure and version up your read nodes
    • Local or farm (via Deadline) publishing

  • Version Viewer (stand-alone)
    • Tool for quickly listing, navigating, and filtering all resources and their versions for a particular project, sequence, or shot

  • Plate Ingestion Tool (Integrated with Version Viewer)
    • Quickly publishes plate resources into the pipeline along with any other auxiliary data (e.g., camera information, hdri data, lens distortion, and LUTs)


May 23 2013

“Mango” Production Tracking System + Full Service Pipeline (PTS)

What is PTS?

A PTS (Production Tracking System) is a database that manages VFX/Animation projects and studio resources. This system helps producers, supervisors, and artists keep track of the multiple tasks that are required to successfully complete a show. It facilitates communication between departments and provides real-time reports on the current progress and cost of work. The PTS represents the integration of a “back-end” database (e.g., postgreSQL or MySQL) and “front-end” applications. The everyday user interacts with “front-end” applications which are designed to meet his unique needs. These applications can be stand-alone or integrated into third party commercial or proprietary software (e.g., task management application or resource publishing tools inside of Maya, Nuke, etc.).

Why is there a need for a PTS?

A well-designed PTS is integral to an effective studio. It allows artists, supervisors, and producers to find relevant information quickly. For example, an artist can see a list of incomplete tasks that are assigned to him. Then, a supervisor can use PTS to comment on the tasks which artists marked “ready for review” and keep a historical log of these comments. While a producer can use PTS to see which shots are over-budget and the human resources department can have a record of billable hours that are connected to specific tasks. Everyone involved in the production process is able to input and query this information through applications that are stand-alone and/or integrated with third-party commercial or proprietary software.

A few examples of common stand-alone applications in PTS are:

  • A Time-Card Application
    • creates an electronic record of billable hours in the database which replaces paper time-cards.
    • allows artists to connect these hours to a particular task which can be used to create more detailed reports.
  • A Task Management Application
    • allows supervisors to break large scale work into smaller easily-delegated tasks.
    • holds other important information to facilitate time-management (e.g., priorities and due-dates).
    • connects tasks to progress-tracking statuses (e.g., “in progress” or “awaiting supervisor review) which can be filtered by supervisors and artists.
  • A Dailies Application
    • lists all the image sequences sent by artists to be reviewed in dailies.
    • uses the versioning system in PTS to help supervisors quickly find older versions of the same sequence for comparison during review.
    • connects comments about the work being reviewed in dailies to the task that generated it to ensure the artist has a record of the notes.

A few examples of common applications which are integrated into third-party software in PTS are:

  • Publishing and Versioning Tools
    • help artists version their work while keeping a historical record of changes.
    • allow for easier hand-off of versioned work to the next step in the pipeline.
    • when necessary, allow artists to easily roll-back to previous versions of their work.
    • adds a layer of programmable quality control to ensure smooth ingestion into the pipeline.
  • An Asset Catalog
    • helps animators and layout artists quickly find and reference show-specific and updatable set-ups.
  • A Shot Resource Catalog
    • allows lighters and effects artists to quickly know the resources that make-up a 3d scene.
    • allows artists to compare version information about the resources currently in the scene.
    • Alerts artists when scene resources need to be updated.
  • Scene Building Tools
    • Eliminates the need for multiple artists to work on the same file by allowing artists to build unique files with shared resources.

A PTS adds accountability and power to a studio because it automates some of the more tedious aspects of the VFX/Animation pipeline. A pipeline that revolves around a well-designed PTS allows artists to focus the majority of their time on art, rather than addressing technical complications that arise from keeping scene files updated. In addition, it gives supervisors and producers the real-time information that allows them to track the progress of work and make better choices which maximize the project’s profit.

Why is a PTS not as Common in Smaller Studios?

If a PTS is so wonderful, why is everyone not using one? There are four simple answers to this question:

  1. Smaller studios don’t usually have the resources to employ full-time programers. So, developing and integrating a PTS into their pipeline is not cost-effective.
  2. The culture of many smaller studios means that there are no uniform standards and practices about how scene files are created and shared. Therefore, their database (the “back-end” of a PTS) mirrors this complexity and quickly outlives its usefulness.
  3. Popular expensive commercial solutions (e.g., Shotgun/Tank, FileMaker Pro, SharePoint) are a framework for a database but, they don’t offer uniform standards and practices. This leads to the previously described problem for studios who do not have strong standards and practices. Moreover, many of these commercial solutions don’t offer third-party integrated applications leaving studios to write their own.
  4. These expensive commercial options still require the additional cost of Technical Directors to update, maintain, populate, and further develop these systems; sometimes greatly increasing the cost of integrating such a system.

While smaller studios have a very large incentive to invest in a pipeline that revolves around a well-designed PTS, they often don’t. The expense in time and money for an inadequate product is too much of a risk.

What is Mango?

Mango is an economical plug-and-play solution that is designed around how people actually work in VFX/Animation studios. It recognizes that many studios do not have set standards and practices which are a predictable and repeatable way of creating quality work (Modular Asset Pipeline Flow). Mango not only provides a uniform way of accomplishing this work, but it is a ready-to-use PTS that is modeled around a uniform set of standards and practices. In addition, Mango includes tools that will run on multiple applications (e.g., Maya, 3ds Max, Nuke, Houdini) to help enforce the uniform standards and practices without limiting artists creative ability.

Mango eliminates the need to have multiple programmers to mold the system to work in your studio. It greatly simplifies the nature of the database that you will use to track this work. Mango minimizes the footprint that these kind of systems can have in a studio pipeline. It fundamentally changes the way the studio works. In other words, Mango helps to create and monitor a more efficient studio work system by providing a full end-to-end pipeline.

When will Mango be Complete?

Mango is an on-going personal project on which I am working full-time from home. It is the result of 10 years of experience working in a range of studios in the VFX/Animation industry. The base for the PTS and several applications will be complete by the end of July. The development cycle is going to be rapid this is why I am researching tying together multiple open-source libraries and technologies (e.g., Python, postgreSQL, SQLAlchemy). Not only will this make my development cycle more efficient, but it also makes it more accessible to other programmers.

Anyway stay tuned, I will add more posts related to my findings about database programing for the VFX industry.

Cheers!


Apr 26 2013

Modular Asset Pipeline Flow (Standards And Practices)

One of the main interests in my career has been developing a way in which I could optimize the process of creating and revising animated content in 3d through uniform standards and practices. My interest in this topic is rooted in my experience as a Character Technical Director (TD). A Character TD collaborates with many different departments. For example, he is the one that makes sure that models are technically sound for rigging. He also has to collaborate with animators to ensure that the animation set-ups are simple yet powerful enough for the animator to be able to achieve the desired performance. A Character TD interacts with lighting and effects to make sure that the animated performance transfers from animation department to the lighting department without breaking. He is usually in charge of adding more animated detailed to assets via simulations like hair and cloth. These are just a few of the responsibilities of a Character TD,basically, he has his hands in everything. Owing to their work responsibilities, most Character TDs frequently assume some of the responsibilities of pipeline development.

While I’ve been fortunate enough to work at studios that have had well-designed asset-based pipelines, I have worked at others that have failed to develop the standards and practices necessary to implement such a pipeline. I have drawn on these professional experiences in both kinds of studios to develop a specialization in writing 3D pipelines and developing this, often missing, set of standards and practices. The link below is an image of an up-to-date concept map of how assets should flow and can be developed through a pipeline. There are many benefits to implementing this kind of pipeline. A few of the most notable include:

  • Modeling, rigging, shading, lighting, effects, and animation can evolve parallel to each other rather than being linearly dependent. This monumentally increases the speed with which people can accomplish work by eliminating a known bottleneck.
  • It facilitates the tracking of different versions of a resource that form an asset and even allow roll-back. This ensures that artists always have the correct versions of resources on which their work depends.
  • It eliminates the need of transitioning from previs to postvis work. This avoids a common redundant step in many small studio pipelines.

This standardized asset flow allows for a very simple database model which is able to track and manage the work greatly simplifying the development of a PTS system (mango pts).

Hopefully, I will be able to blog in more detail about this soon.

Until next time!

 

Modular Asset Pipeline Flow

 


Apr 16 2013

XML Parssing in maxscript

A friend at work asked me for a quick example of how to parse an xml file in maxscript…
to my knowledge the only simple way to do this is by tapping into .net
.net has a nice, easy to use xml parser to explore the contents of an xml file..

his a snippet to get you started..
cheers!

/*
in this example we are looking at a maya point cache file which is loaded via an xml file..
we are looking to pull the cache type (single file, or file per frame )
we also want to get the number of frames..
*/
 xmlFile = @"C:\_cache\temp\XML_Test\Sphere001.xml" --your xml file

 dotnet.LoadAssembly "system.xml.dll" --source the xml parser into .net
 xmlDoc = dotNetObject "System.Xml.XmlDocument" --create your xml parser object

 xmlDoc.Load xmlFile --load the xml onto the parser object

 header =  xmlDoc.item["Autodesk_Cache_File"] --this is how you pull an element section by name

--elments can have children elements.. in this case we are quarying the value of the attribute "Type" inside the "cacheType" element which is of the "Autodesk_Cache_File"..
cacheType = (header.item["cacheType"].GetAttribute("Type"))
timePerFrame = (header.item["cacheTimePerFrame"].GetAttribute("TimePerFrame"))

print cacheType
print timePerFrame

look into using the show , and showmethods function in maxscript to exploer other functions and attributes available to the element objects.
this will allow you to do more complex parsing..
until next time!


Apr 16 2013

max script and regualr expressions…(the duber way)

cuse if you don’t know?? then now you know!!!
great post i found to day about using a .net class in maxscript to handle regular expression..
neat-O..
http://blog.duber.cz/3ds-max/the-power-of-regular-expressions


Apr 12 2013

Deploying Blur Python and QT for 3ds max in your studio..