Announcement

Collapse
No announcement yet.

how can I copy extra vray attrs from one shape to another

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how can I copy extra vray attrs from one shape to another

    Ran into a snag on our animation/lighting pipeline. When importing geo caches to the lighting scene, the original shape node is hidden and replaced with a deformed shape node. Fine, but our lighters have added and adjusted vray attributes to the shape nodes, which I need to copy up to the deformed shape node.

    I have a python function for detecting which vray attr groups have been added, and adding them to to deformed shape node, but now I want to copy the attribute values from the original shape to the deformed shape node, and I'm running into issues.

    copyAttr doesn't work because it doesn't work with shape nodes. making a dictionary of attributes and their values doesn't seem to work because I need the types when using setAttr. I can get the type and add that to the dictionary, but the types I get from getAttr don't match the type I need to set the attribute.

    Suggestions?

    Thank you.

    -ctj
    http://www.a52.com

  • #2
    Originally posted by ALFRED_ST_MEDIA View Post
    Ran into a snag on our animation/lighting pipeline. When importing geo caches to the lighting scene, the original shape node is hidden and replaced with a deformed shape node.
    Chaos support can answer best how to add custom attributes with a script (I wish they posted all the commands in the manual). But what I can tell you is that we had the same issue. We resolved it by doing the following:
    instead of applying the cache node to the geometry in the lighting file, instead you apply the cache node to geometry in the model file (when model is published) and when its referenced into the lighting scene the cache is simply input into the cache node which comes with the model.
    Dmitry Vinnik
    Silhouette Images Inc.
    ShowReel:
    https://www.youtube.com/watch?v=qxSJlvSwAhA
    https://www.linkedin.com/in/dmitry-v...-identity-name

    Comment


    • #3
      Dmitry,

      An excellent idea, and I fought for that initially, and I may add a function to the model publish that does this. For the immediate future, I did the following (not elegant, in fact very ugly but works):

      Code:
      ## transfer vray shape attributes from one shape to another.
      ## this was create to transfer any existing vray attributes on the 
      ##  model shape node to the deformed shape node generated by applying
      ## the geo cache to the original shape node
      def transVrayAttr(shapeNodeList):
        """
        transfer vray tributes from one shape node to another
        """
        # this dictionary has the vray attributes used to test what attribute groups to add
        vrayAttrDict = {'vraySubdivEnable':'vray_subdivision','vrayOverrideGlobalSubQual':'vray_subquality','vrayDisplacementNone':'vray_displacement','vrayRoundEdges':'vray_roundedges','vrayUserAttributes':'vray_user_attributes','vrayObjectID':'vray_objectID','vrayFogFadeOut':'vray_fogFadeOut','vrayPhoenixObjVoxels':'vray_phoenix_object'}
      
        # now to cycle through all the vray attrs in the original shape node and transfer them to the new one
        for curVrayAttr in cmds.listAttr(shapeNodeList[0],string='vray*'):
          if curVrayAttr in vrayAttrDict.keys():
              mel.eval('vray addAttributesFromGroup ' + shapeNodeList[1]+ ' ' + vrayAttrDict[curVrayAttr] + ' 1;')  # if the current attr is in the dictionary, add that vray attr group to the new shape node
        
          numValues = cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr,type=True)[-1]    # get the last charcter of the attr type to test how many values this attr requires
        
          if(numValues == '2'):
              cmds.setAttr(shapeNodeList[1]+'.'+curVrayAttr,cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr)[0][0],cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr)[0][1])
          if(numValues == '3'):
              cmds.setAttr(shapeNodeList[1]+'.'+curVrayAttr,cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr)[0][0],cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr)[0][1],cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr)[0][2])
          else:
              if cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr,type=True) == 'string':  #  for some reason, the string value of userCustom required a type definition
                cmds.setAttr(shapeNodeList[1]+'.'+curVrayAttr,cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr),type='string')
              else:
                cmds.setAttr(shapeNodeList[1]+'.'+curVrayAttr,cmds.getAttr(shapeNodeList[0]+'.'+curVrayAttr))
      http://www.a52.com

      Comment

      Working...
      X