I have 56 objects in my node repromesh.
I have listed all the attributes of this node, but can't figure how to delete one (or all) the object in order to replace them with another.
There are some attribute like : instancedGroup.instancedMesh but no value/type I can find to access it.
Quite complex one : (EDIT : solution for delete all in the bottom)
if you go to this python file (i found this module by turning on echo all, while removing item) :
print(mash_repro_aetemplate.__file__)
You will find the mash script and the pieces where they call the UI.
import maya.OpenMayaUI as mui
from shiboken2 import wrapInstance
usingPyside2 = False
try:
import PySide2
usingPyside2 = True
except:
pass
from flux.imports import *
from flux.core import pix
import flux.core as fx
import mash_repro_utils
from mash_repro_icons import MASH_REPRO_ICONS
from functools import partial
import MASH.undo as undo
def get_maya_window():
ptr = mui.MQtUtil.mainWindow()
if ptr is not None:
return wrapInstance(long(ptr), qt.QMainWindow)
def refresh_all_aetemplates(force=False):
""" Refresh all the repro aetemplates"""
widgets = get_maya_window().findChildren(AEMASH_ReproTemplate) or []
for widget in widgets:
global SCENE_OPENED
SCENE_OPENED = True
widget.update_data(widget.node, force=force)
SCENE_OPENED = False
here is a way to find the repro node :
widgets = get_maya_window().findChildren(qt.QWidget, 'AEMASH_ReproTemplate') or []
myRepro = widgets[0]
'myRepro' is now the class of the mash repro node.
The Qtreewidget representing your nodes is :
myRepro.objs_widget
you can use from this other class derived from qtree :
# work only on selection, if you want to modify this command, maybe create your own add_sel_bjects(self, objs=[])
myRepro.objs_widget.add_objects()
# work only on the selection in the qtree widget
myRepro.objs_widget.delete_item()
# you can use qtree functions instead :
# myRepro.objs_widget.clear()
items_count = myRepro.objs_widget.topLevelItemCount()
In the delete_item methods, there is this
mash_repro_utils.remove_mesh_group(myRepro.objs_widget.node, id)
mash_repro_utils.remove_proxy_group(self.node, self.instance_index, id)
I didn't had time to investigate but from there, you find :
print(mash_repro_utils.__file__)
# Result: 'maya_path/plug-ins/MASH/scripts/mash_repro_utils.py' #
Go there and there is all the maya python mash functions :
def remove_proxy_group(mash_repro_node, instance_index, index):
"""
Remove a proxy object from the Repro node
:param mash_repro_node: MASH Repro node
:param instance_index: Object index
:param index: Proxy index
:return: None
"""
with ReproUpdating(mash_repro_node):
data = get_data_layout(mash_repro_node)
indices = data[instance_index]['proxies'].keys()
indices.sort()
if index in indices:
position = indices.index(index)
for i in range(position, len(indices)):
clean_proxy_index(mash_repro_node, instance_index, indices[i])
for i in range(position + 1, len(indices)):
if 'group' in data[instance_index]['proxies'][indices[i]]:
new_index = connect_proxy_group(mash_repro_node, data[instance_index]['proxies'][indices[i]]['group'], instance_index)
maya.cmds.setAttr("%s.instancedGroup[%d].proxyGroup[%d].proxyLod" % (mash_repro_node, instance_index, new_index), data[instance_index]['proxies'][indices[i]]['proxyLod'])
hasMASHFlag = maya.cmds.objExists('%s.mashOutFilter' % (data[instance_index]['proxies'][indices[i]]['group']))
if hasMASHFlag:
maya.cmds.deleteAttr( data[instance_index]['proxies'][indices[i]]['group'], at='mashOutFilter' )
You should be able to investigate from there.
You could just make your own delete_all, like this also:
items_count = myRepro.objs_widget.topLevelItemCount()
for id in sorted(range(items_count), reverse=True):
mash_repro_utils.remove_mesh_group(myRepro.objs_widget.node, id)
myRepro.objs_widget.obj_dropped.emit(None)