your first instinct here gave me an idea of how to make this more
user-friendly. i've reworked it so that simply importing a module
with an
AETemplate subclass will register it. from the new docs:
----------------
To create an Attribute Editor template using python, do the
following:
1. create a subclass of `uitypes.AETemplate`
2. set its ``_nodeType`` class attribute to the name of the desired
node
type, or name the class using the convention ``AE<nodeType>Template``
3. import the module
AETemplates which do not meet one of the two requirements listed in
step 2
will be ignored. To ensure that your Template's node type is being
detected
correctly, use the ``AETemplate.nodeType()`` class method::
import AETemplates
AETemplates.AEmib_amb_occlusionTemplate.nodeType()
As a convenience, when pymel is imported it will automatically
import the
module ``AETemplates``, if it exists, thereby triggering any
AETemplates
within it or its sub-modules to be registered. Be sure to import
pymel or
modules containing your ``AETemplate`` classes before opening the
Atrribute
Editor for the node types in question.
To check which templates are loaded using python::
from pymel.core.uitypes import AELoader
print AELoader.loadedTemplates()
----------------------
things are wonky at work right now so i can't commit it to github
at the
moment, but i'll put it up tomorrow morning.
-chad
On Thu, Mar 18, 2010 at 11:05 AM, thirstydevil <[email protected]
>
wrote:
Hi Chad,
I've got the latest from Git. I've checked the code against the Git
Hub commits section. On the 17th of last month you committed fix's
for AE. I have those in my git clone, plus recent commits. Just to
be sure I have the latest I've deleted my copy and cloned it once
more.
I've copied the AETemplates example directly into our module folder.
It's not being picked up by pymel and the mib_amb_occlusion node
isn't
showing the edited label. I've also removed the previous package
method and only have this AETemplates module on the sys.path
I tried to manually call the template via
import AETemplates
AETemplates.AEmetaNodeTemplate("metaNode")
# Error: Maya command error
# Traceback (most recent call last):
# File "<maya console>", line 2, in <module>
# File "G:/Maya/Maya_Modules/Modules/CoreLibs/PyLib
\AETemplates.py",
line 73, in __init__
# self.beginScrollLayout()
# File "C:/ArtPipelines/App/Maya2010-x86/pymel/LumaPictures-
pymel-4a6076b\pymel\core\uitypes.py", line 676, in beginScrollLayout
# cmds.editorTemplate(beginScrollLayout=True)
# File "C:/ArtPipelines/App/Maya2010-x86/pymel/LumaPictures-
pymel-4a6076b\pymel\internal\pmcmds.py", line 98, in wrappedCmd
# res = new_cmd(*new_args, **new_kwargs)
# RuntimeError: Maya command error #
Any Ideas?
-Dave
On Mar 18, 4:53 pm, Chad Dombrova <[email protected]> wrote:
there was a bug with this in rc1 so you should check out from
github.
if
that's a problem, i can get a new release up over the weekend.
-chad
On Thu, Mar 18, 2010 at 9:28 AM, David Moulder
<[email protected]>wrote:
Hi Chad,
I've tried to get this working but it's not happening for me.
I'm trying to set it up as a package, <<Package,Module,Class>>
I have :-
AETemplates.AEmetaNodeTemplate.AEmetaNodeTemplate
My AEmetaNodeTemplate module looks like this, just to test.
import pymel.core as pCore
class AEmetaNodeTemplate(pCore.ui.AETemplate):
def __init__(self, nodeName):
self.buildBody(nodeName)
def buildBody(self, nodeName):
print "building", nodeName
self.beginLayout("kParams",collapse=0)
self.addControl("bright", label="kBright",
changeCommand=self.colorChanged)
self.addControl("dark", label="kDark",
changeCommand=self.colorChanged)
self.addControl("spread", label="kSpread",
preventOverride=True)
self.addControl("max_distance", label="kMaxDistance")
self.addControl("reflective", label="kReflective")
self.addControl("output_mode", label="kOutputMode")
self.addControl("occlusion_in_alpha",
label="kOcclusionInAlpha")
self.addControl("falloff", label="kFalloff")
self.addControl("id_inclexcl", label="If You See This It
Worked")
self.endLayout()
self.suppress("id_nonself")
self.dimControl(nodeName, "spread", True)
I'd like to understand how Pymel is intercepting the AETemplate
creation, Does it matter when pymel is loaded to find this
AETemplate?
Pymel is up early in our systems but this module path isn't until
later in the maya boot sequence.
Cheers
-Dave
On Thu, Mar 18, 2010 at 3:43 PM, thirstydevil
<[email protected]>
wrote:
Cool, Thanks Chad.
-Dave
PS, I've got pymel with git via TortoiseGit.
On Mar 18, 3:13 pm, Chad Dombrova <[email protected]> wrote:
pymel 1.0 has support for python AETemplates using specially
implemented
classes. there's an example included with pymel showing how to
do this
using
subclassing techniques. you could easily write a function that
created an
AETemplate subclass for every one of your metanodes. you may
even be
able to
do something funky like have your MetaData classes double as
AETemplates.
be sure to grab pymel from github, as there's been some work
done on
this
very recently.
-chad
On Mar 18, 2010, at 8:07 AM, thirstydevil wrote:
Based on the Bungee paper we've implemented a MetaData python
class
that utilises a simple MPxNode as a singleton to store the
MetaData
attributes. MetaData structures are connected together and
Maya
Nodes
are tagged to the MetaData via message links.
for example:
class MetaData(obejct):
def __init__(self, node=None, **kw):
self,metaClass = self.__class__.__name__
# create the MPxNode and set the attr attaching it to
Node
Each MetaData subclass has different methods associated with
them.
While I have a simple AETemplate for my MPxNode. It's become
obvious
that I could have a totally different template based on the
metaClass
attribute on the node. With buttons calling methods in the
class
that
operate on the MetaData structure.
The only hacky way I have got this working is by reloading the
AETemplate via a script job if the MetaData node is different
to
the
last cached MetaData selection. This works, is slow-ish, not
stable
because the UI doesn't seem to be thread safe.
So, I guess I have to create a different MPxNode for every
subclass
that requires a different template. Even though my MPxNode is
effectively a blank node?
Anyone? You're experience with templates would be welcome.
I've
just
started to investigate them.
-Dave
--
http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya
To unsubscribe from this group, send email to
python_inside_maya+unsubscribegooglegroups.com or reply to this
email with
the words "REMOVE ME" as the subject.