-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add node to instance in Maya #82
Comments
I can't tell exactly why this is happening, but as a temporary workaround you could store the names of your nodes rather than the PyMEL objects. |
I'm working around it for now, by just storing the PyMEL object in a data member 😄 |
Seems like this might be a deeper rooted problem.
|
Here is a small test that I'm working with to try and solve this; import pyblish.api
import pyblish_lite
class Collect(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder
def process(self, context):
context.create_instance(name="A")
pyblish.api.register_plugin(Collect)
def toggle_instance(instance, new_value, old_value):
print type(instance)
pyblish.api.register_callback("instanceToggled", toggle_instance)
pyblish_lite.show() This will print the type of the instance, which currently are a list but should be |
It seems between passing the instance object from the model to the window, it gets converted to a list. Continuing the investigation... |
Strangely the same code works with the plugins, and there shouldn't be a difference in fetching the data; import pyblish.api
import pyblish_lite
class Collect(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder
def process(self, context):
context.create_instance(name="A")
pyblish.api.register_plugin(Collect)
class Validate(pyblish.api.ContextPlugin):
order = pyblish.api.ValidatorOrder
optional = True
def process(self, context):
pass
pyblish.api.register_plugin(Validate)
def toggle_instance(instance, new_value, old_value):
print type(instance)
pyblish.api.register_callback("instanceToggled", toggle_instance)
def toggle_plugin(plugin, new_value, old_value):
print type(plugin)
pyblish.api.register_callback("pluginToggled", toggle_plugin)
pyblish_lite.settings.InitialTab = "overview"
pyblish_lite.show() |
Context and Instance are subclassed from Might be related. |
So I've tried narrowing down where the problem is, but I don't understand why.
Is this expected? |
Hm. Maybe try making a textual replication of the problem. Cut the GUI out of the equation. For example, you can trigger a signal via
from pyblish import api
import pyblish_lite.model
item = api.Instance("MyInstance")
model = pyblish_lite.model.Instance()
model.append(item)
index = next(iter(model))
index.data(pyblish_lite.model.Object) You could also emit the signal yourself. from pyblish import api
item = api.Instance("MyInstance")
api.emit(signal="instanceToggled",
kwargs={"new_value": True,
"old_value": False,
"instance": instance)) |
Ok, I stumbled upon this just now. script.py import sys
from Qt import QtWidgets
if __name__ == '__main__':
from pyblish import api
app = QtWidgets.QApplication(sys.argv)
instance = api.Instance("camera")
item = type("MyItem", (QtWidgets.QGraphicsItem,), {})()
item.setData(0, instance)
print(type(instance))
print(type(item.data(0)))
app.exit() Returns: $ python script.py
<class 'pyblish.plugin.Instance'>
<type 'list'> As it turns out, Qt or the Qt binding alters the type from A solution is to simply not use the built-in |
It appears to only affect script2.py import sys
from Qt import QtWidgets
class CustomClass(object):
pass
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
instance = CustomClass()
item = type("MyItem", (QtWidgets.QGraphicsItem,), {})()
item.setData(0, instance)
print(type(instance))
print(type(item.data(0)))
app.exit() Returns: $ python -u script2.py
<class '__main__.CustomClass'>
<class '__main__.CustomClass'> |
Very interesting 😄
Sorry, not entirely sure what you mean? |
Missed this! What I meant was, So what we could do, is instead of subclassing There really is no reason to use the superclass |
This has been addressed on a shallow level with #83. I'll keep this issue open as a reminder to go fix it proper. |
has this been fixed? if any thing more needs doing to adress this i'm happy to pick that up |
Description
Getting an error when adding nodes to an instance and toggling in the UI;
Minimal steps to reproduce
The text was updated successfully, but these errors were encountered: