示例#1
0
def get_attr_info(attribute):
    """
    Get all data of a passed attribute.
    The data that it returns depends on the type of attribute.
    :param attribute: Attribute Object.
    :return: dictionary with the necessary data to recreate the attribute.
    """
    attribute_type = str(attribute.type())

    d_data = dict()
    d_data['longName'] = str(pm.attributeName(attribute, long=True))
    d_data['niceName'] = str(pm.attributeName(attribute, nice=True))
    d_data['shortName'] = str(pm.attributeName(attribute, short=True))
    d_data['hidden'] = attribute.isHidden()
    d_data['keyable'] = attribute.isKeyable()

    if attribute_type in ['string']:
        d_data['dataType'] = attribute_type
    else:
        d_data['attributeType'] = attribute_type

    if attribute_type in ['long', 'double', 'bool']:
        d_data['defaultValue'] = attribute.get(default=True)
        if attribute.getMax():
            d_data['maxValue'] = attribute.getMax()
        if attribute.getMin():
            d_data['minValue'] = attribute.getMin()

    if attribute_type in ['enum']:
        d_data['enumName'] = attribute.getEnums()

    if attribute.parent():
        d_data['parent'] = attribute.parent().attrName()

    return d_data
示例#2
0
def get_rendersettings_dict():
    """Parse the vray rendersettings node and return dict with information"""

    #log_progress
    log_progress = False

    #vray_settings_node
    vray_settings_node = vrayRenderSettingsNode()
    #empty
    if not (vray_settings_node):
        print('No vray rendersettings node in the scene.')
        return {}

    #rendersettings_details_dict
    rendersettings_details_dict = {}

    #iterate attrs
    for attr in vray_settings_node.listAttr():
        try:
            if (vray_settings_node.fileNamePrefix.name() != attr.name()):
                rendersettings_details_dict[pm.attributeName(
                    attr)] = attr.get()
        except:
            #log
            if (log_process):
                print(
                    "Error getting value from attr. {0} from vray settings node {1}"
                    .format(pm.attributeName(attr), vray_settings_node.name()))

    return rendersettings_details_dict
示例#3
0
def get_rendersettings_dict():
	"""Parse the vray rendersettings node and return dict with information"""

	#log_progress
	log_progress = False

	#vray_settings_node
	vray_settings_node = vrayRenderSettingsNode()
	#empty
	if not(vray_settings_node):
		print('No vray rendersettings node in the scene.')
		return {}

	#rendersettings_details_dict
	rendersettings_details_dict = {}

	#iterate attrs
	for attr in vray_settings_node.listAttr():
		try:
			if(vray_settings_node.fileNamePrefix.name() != attr.name()):
				rendersettings_details_dict[pm.attributeName(attr)] = attr.get()
		except:
			#log
			if(log_process):
				print("Error getting value from attr. {0} from vray settings node {1}".format(pm.attributeName(attr), vray_settings_node.name()))


	return rendersettings_details_dict
示例#4
0
    def _setup_attribute(self, node, **kwargs):
        """Set or connect given output into input attributes.

        @param node <pyNode> PyNode object to set and get attributes
        @param kwargs <dict> Data storing the keyword argument information
        """
        for key, val in kwargs.items():
            key = pm.attributeName('%s.%s' % (node, key), l=True)
            if key not in self._nodes[self._nodename].keys():
                attrs = [n for n in self._nodes[self._nodename].keys()
                         if n != '__ABBREVIATION__']
                msg = ("Parameter %s does not exist in node_info.json!"
                       " Valid flags are %s" % (key, attrs))
                raise AttributeError(msg)
            # end if raise attribute error
            if self._nodes[self._nodename][key] == 'TdataCompound':
                for i, v in enumerate(val):
                    if pm.objExists(str(v)):
                        v.connect(node.attr('%s[%s]' % (key, i)))
                    # end for iterate dataCompound
                # end for iterate dataCompound
            # end if key is dataCompound
            if pm.objExists(str(val)):
                val.connect(node.attr(key))
            else:
                if self._nodes[self._nodename][key] == 'TdataCompound':
                    for i, v in enumerate(val):
                        if not node.attr('%s[%s]' % (key, i)).isConnected():
                            node.setAttr('%s[%s]' % (key, i), v)
                        # end if node is not connected
                    # end for iterate dataCompound
                else:
                    node.setAttr(key, val)
示例#5
0
def holdAttr(attr):
    data = {
        'node': attr.node(),
        'longName': attr.longName(),
        'shortName': attr.shortName(),
        'niceName': pymel.attributeName(attr),
        'inputs': attr.inputs(plugs=True),
        'outputs': attr.outputs(plugs=True),
        'isMulti': attr.isMulti(),
        'type': attr.type(),
        'locked': attr.isLocked(),
        'keyable': attr.isKeyable(),
        'hidden': attr.isHidden()
    }

    pymel.deleteAttr(attr)
    return data
示例#6
0
文件: libAttr.py 项目: Leopardob/omtk
def holdAttr(attr):
    data = {
        'node':attr.node(),
        'longName':attr.longName(),
        'shortName':attr.shortName(),
        'niceName': pymel.attributeName(attr),
        'inputs':attr.inputs(plugs=True),
        'outputs':attr.outputs(plugs=True),
        'isMulti': attr.isMulti(),
        'type': attr.type(),
        'locked': attr.isLocked(),
        'keyable': attr.isKeyable(),
        'hidden': attr.isHidden()
    }

    pymel.deleteAttr(attr)
    return data
示例#7
0
文件: utils.py 项目: jonntd/Public
 def _setup_attribute(self, node, **kwargs):
     """Set or connect given output into input attributes
     @param node <pyNode> PyNode object to set and get attributes
     @param kwargs <dict> Data storing the keyword argument information
     """
     for key, val in kwargs.items():
         key = pm.attributeName('%s.%s' % (node, key), l=True)
         if key not in self._nodes[self._nodename].keys():
             attrs = [n for n in self._nodes[self._nodename].keys()
                      if n != '__ABBREVIATION__']
             msg = ("Parameter %s does not exist in node_info.json!"
                    " Valid flags are %s" % (key, attrs))
             raise AttributeError(msg)
         # end if raise attribute error
         if pm.objExists(str(val)):
             val.connect(node.attr(key))
         else:
             node.setAttr(key, val)