<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Paint Blend Shape Weights Tool via Python/MEL? in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9757468#M5391</link>
    <description>&lt;P&gt;So its certainly possible, although it will depend on how comfortable you are with python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First off, you need to get the components and "weighting" from the soft selection;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ldunham1/maya_utilities/blob/master/ld_soft_cluster.py" target="_blank"&gt;https://github.com/ldunham1/maya_utilities/blob/master/ld_soft_cluster.py&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def _get_soft_selection():
    """
    Return the current soft selection components and normalised influence weights.
    :return: List of components and matching weights.
    :rtype: list(str), list(float)
    """
    # Grab the soft selection
    selection = om.MSelectionList()
    soft_sel = om.MRichSelection()
    om.MGlobal.getRichSelection(soft_sel)
    soft_sel.getSelection(selection)
    dag_path = om.MDagPath()
    component = om.MObject()

    # Filter Defeats the purpose of the else statement
    iter_sel = om.MItSelectionList(selection, om.MFn.kMeshVertComponent)
    elements, weights = [], []
    while not iter_sel.isDone():
        iter_sel.getDagPath(dag_path, component)

        # Grab the parent of the shape node
        dag_path.pop()
        node = dag_path.fullPathName()
        fn_comp = om.MFnSingleIndexedComponent(component)
        vtx_str = node + '.vtx[{}]'

        for i in range(fn_comp.elementCount()):
            elements.append(vtx_str.format(fn_comp.element(i)))
            weights.append(fn_comp.weight(i).influence() if fn_comp.hasWeights() else 1.0)

        iter_sel.next()

    return elements, weights&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, modify the blendshape weights using the component index and soft selection weight - these two posts should help you out there.&lt;/P&gt;&lt;P&gt;&lt;A href="https://yantor3d.wordpress.com/2017/09/16/inside-the-node-blendshape/" target="_blank"&gt;https://yantor3d.wordpress.com/2017/09/16/inside-the-node-blendshape/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://soup-dev.websitetoolbox.com/post/setting-blendshape-weights-through-maya-api-7116714?pid=1284620311" target="_blank"&gt;https://soup-dev.websitetoolbox.com/post/setting-blendshape-weights-through-maya-api-7116714?pid=1284620311&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hint: You're modify this to affect the blendshape base weights, although you can also access target specific weights too;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;blendshape.inputTarget[0].baseWeights&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Sun, 20 Sep 2020 03:14:52 GMT</pubDate>
    <dc:creator>lee.dunham</dc:creator>
    <dc:date>2020-09-20T03:14:52Z</dc:date>
    <item>
      <title>Paint Blend Shape Weights Tool via Python/MEL?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9757447#M5390</link>
      <description>&lt;P&gt;Trying to do some very targeted blendshape painting. What I'd like to be able to do is select a series of vertices with soft selection, and have that selection be my "painted weights". I don't really want to have to go through manually painting weights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there Python commands to help with this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't dig to find out what the Paint Blendshape Weights tool is doing. The Node Graph doesn't show any intermediary that would hold this data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/Maya-CharacterAnimation/files/GUID-E49E9C30-D03A-456D-B7E8-FF99DA8C11E4-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/Maya-CharacterAnimation/files/GUID-E49E9C30-D03A-456D-B7E8-FF99DA8C11E4-htm.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Sep 2020 02:27:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9757447#M5390</guid>
      <dc:creator>jmalaska</dc:creator>
      <dc:date>2020-09-20T02:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Paint Blend Shape Weights Tool via Python/MEL?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9757468#M5391</link>
      <description>&lt;P&gt;So its certainly possible, although it will depend on how comfortable you are with python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First off, you need to get the components and "weighting" from the soft selection;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ldunham1/maya_utilities/blob/master/ld_soft_cluster.py" target="_blank"&gt;https://github.com/ldunham1/maya_utilities/blob/master/ld_soft_cluster.py&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def _get_soft_selection():
    """
    Return the current soft selection components and normalised influence weights.
    :return: List of components and matching weights.
    :rtype: list(str), list(float)
    """
    # Grab the soft selection
    selection = om.MSelectionList()
    soft_sel = om.MRichSelection()
    om.MGlobal.getRichSelection(soft_sel)
    soft_sel.getSelection(selection)
    dag_path = om.MDagPath()
    component = om.MObject()

    # Filter Defeats the purpose of the else statement
    iter_sel = om.MItSelectionList(selection, om.MFn.kMeshVertComponent)
    elements, weights = [], []
    while not iter_sel.isDone():
        iter_sel.getDagPath(dag_path, component)

        # Grab the parent of the shape node
        dag_path.pop()
        node = dag_path.fullPathName()
        fn_comp = om.MFnSingleIndexedComponent(component)
        vtx_str = node + '.vtx[{}]'

        for i in range(fn_comp.elementCount()):
            elements.append(vtx_str.format(fn_comp.element(i)))
            weights.append(fn_comp.weight(i).influence() if fn_comp.hasWeights() else 1.0)

        iter_sel.next()

    return elements, weights&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, modify the blendshape weights using the component index and soft selection weight - these two posts should help you out there.&lt;/P&gt;&lt;P&gt;&lt;A href="https://yantor3d.wordpress.com/2017/09/16/inside-the-node-blendshape/" target="_blank"&gt;https://yantor3d.wordpress.com/2017/09/16/inside-the-node-blendshape/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://soup-dev.websitetoolbox.com/post/setting-blendshape-weights-through-maya-api-7116714?pid=1284620311" target="_blank"&gt;https://soup-dev.websitetoolbox.com/post/setting-blendshape-weights-through-maya-api-7116714?pid=1284620311&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hint: You're modify this to affect the blendshape base weights, although you can also access target specific weights too;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;blendshape.inputTarget[0].baseWeights&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Sun, 20 Sep 2020 03:14:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9757468#M5391</guid>
      <dc:creator>lee.dunham</dc:creator>
      <dc:date>2020-09-20T03:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Paint Blend Shape Weights Tool via Python/MEL?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9916995#M5392</link>
      <description>&lt;P&gt;Lee, this is wicked awesome. Thank you for dropping your knowledge! Exactly what I was looking for. Cheers!&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 04:09:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9916995#M5392</guid>
      <dc:creator>jmalaska</dc:creator>
      <dc:date>2020-12-05T04:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Paint Blend Shape Weights Tool via Python/MEL?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9917016#M5393</link>
      <description>&lt;P&gt;Not a problem, glad it's helpful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 04:22:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/paint-blend-shape-weights-tool-via-python-mel/m-p/9917016#M5393</guid>
      <dc:creator>lee.dunham</dc:creator>
      <dc:date>2020-12-05T04:22:17Z</dc:date>
    </item>
  </channel>
</rss>

