<?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 I want to create a hotkey to toggle between Weighted Tangent and Non-Weighted Tangent. in Maya Forum</title>
    <link>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12006216#M3893</link>
    <description>&lt;P&gt;Hi! everyone&lt;/P&gt;&lt;P&gt;I am currently writing code to toggle between Weighted Tangent and Non-Weighted Tangent for the Graph Editor keys. To assign it to a hotkey. I found that this command can be used to toggle between Weighted Tangent and Non-Weighted Tangent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

cmds.keyTangent(wt = True)

import maya.cmds as cmds

cmds.keyTangent(wt = False)&lt;/LI-CODE&gt;&lt;P&gt;I want to switch using the if, but I can't do it. Why is it not working? What part of the program can I fix to have it work?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

cmds.keyTangent(wt = True)

if cmds.keyTangent(wt = True):
    cmds.keyTangent(wt = False)

else: cmds.keyTangent(wt = True)&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=__CommandsPython_index_html" target="_blank"&gt;https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=__CommandsPython_index_html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Note: switching a curve from weightedTangents true to false and back to true again will not preserve fixed tangents properly.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I agree with this.&amp;nbsp;Any advice you can give me would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2023 04:53:41 GMT</pubDate>
    <dc:creator>amaterasu-qbb</dc:creator>
    <dc:date>2023-06-02T04:53:41Z</dc:date>
    <item>
      <title>I want to create a hotkey to toggle between Weighted Tangent and Non-Weighted Tangent.</title>
      <link>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12006216#M3893</link>
      <description>&lt;P&gt;Hi! everyone&lt;/P&gt;&lt;P&gt;I am currently writing code to toggle between Weighted Tangent and Non-Weighted Tangent for the Graph Editor keys. To assign it to a hotkey. I found that this command can be used to toggle between Weighted Tangent and Non-Weighted Tangent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

cmds.keyTangent(wt = True)

import maya.cmds as cmds

cmds.keyTangent(wt = False)&lt;/LI-CODE&gt;&lt;P&gt;I want to switch using the if, but I can't do it. Why is it not working? What part of the program can I fix to have it work?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

cmds.keyTangent(wt = True)

if cmds.keyTangent(wt = True):
    cmds.keyTangent(wt = False)

else: cmds.keyTangent(wt = True)&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=__CommandsPython_index_html" target="_blank"&gt;https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=__CommandsPython_index_html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Note: switching a curve from weightedTangents true to false and back to true again will not preserve fixed tangents properly.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I agree with this.&amp;nbsp;Any advice you can give me would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 04:53:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12006216#M3893</guid>
      <dc:creator>amaterasu-qbb</dc:creator>
      <dc:date>2023-06-02T04:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: I want to create a hotkey to toggle between Weighted Tangent and Non-Weighted Tangent.</title>
      <link>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12038067#M3894</link>
      <description>&lt;P&gt;Sorry for the late reply, @Anonymous on Twitter gave me the code: &lt;A href="https://forums.autodesk.com/t5/maya-programming/python-using-if-and-else-to-toggle-between-a-weighted-tangent/td-p/1201111" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/maya-programming/python-using-if-and-else-to-toggle-between-a-weighted-tangent/td-p/1201111&lt;/A&gt;&lt;BR /&gt;The following code is based on the code he gave me. I hope it is useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

# Toggle Weighted Tangent, Non-Weighted Tangents.
cmds.keyTangent(e = True, wt = not(cmds.keyTangent(q = True, wt = True)[0]))&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

# Toggle Weighted Tangent, Non-Weighted Tangents by selected Anim Curves.
selectedCurves = cmds.keyframe(q=True,name = True,selected = True) or []
for selectedCurve in selectedCurves:
    cmds.keyTangent(selectedCurve,e = True,wt = not(cmds.keyTangent(selectedCurve,q = True, wt = True)[0]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Also, &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11712848"&gt;@Kahylan&lt;/a&gt; gave me a modified version of the code I posted in my Maya forum question. I think this will be useful as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

# set to Non-Weighted Tangents, False.
if cmds.keyTangent(q = True, wt = True) == [True]:
    cmds.keyTangent(e = True, wt = False)

# toggle Weighted Tangents.
else:
    cmds.keyTangent(e = True, wt = True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I Accept Solution to this answer but this is not by me, it was helped by @Anonymous and &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11712848"&gt;@Kahylan&lt;/a&gt;. But I accept the solution because it helps the community.&lt;BR /&gt;I would like to take this opportunity to thank @Anonymous and &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11712848"&gt;@Kahylan&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 05:11:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12038067#M3894</guid>
      <dc:creator>amaterasu-qbb</dc:creator>
      <dc:date>2023-06-16T05:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: I want to create a hotkey to toggle between Weighted Tangent and Non-Weighted Tangent.</title>
      <link>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12084068#M3895</link>
      <description>&lt;P&gt;Thanks to @Anonymous and &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11712848"&gt;@Kahylan&lt;/a&gt;'s help, I was able to create a code to toggle between Lock Tangent Length and Free Tangent Length, so I will post it here as well.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import maya.cmds as cmds

# Toggle Lock Tangent Length or Free Tangent Length.
cmds.keyTangent(e = True, wl = not(cmds.keyTangent(q = True, wl = True)[0]))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Jul 2023 15:24:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-forum/i-want-to-create-a-hotkey-to-toggle-between-weighted-tangent-and/m-p/12084068#M3895</guid>
      <dc:creator>amaterasu-qbb</dc:creator>
      <dc:date>2023-07-06T15:24:54Z</dc:date>
    </item>
  </channel>
</rss>

