<?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 Attribute filtering. in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12151671#M882</link>
    <description>&lt;P&gt;Attribute filtering.&lt;/P&gt;&lt;P&gt;Here I show you some code I'm doing to filter only the selected from the channelbox to the graph editor, turns out I can't stop the filtering after running kill scriptjob etc.&lt;/P&gt;&lt;P&gt;I can't get the filtering to stop with the tests I'm doing, so I post as far as I can, it filters the attribute but I can't get it to stop filtering when the user wants it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if there is someone who can find another way to do this, I'm sure many animators would appreciate it!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filter.gif" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1249655i6356CBDB5E05A203/image-size/large?v=v2&amp;amp;px=999" role="button" title="filter.gif" alt="filter.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// Function to apply filtering in the Graph Editor
global proc applyGraphEditorFilter(string $filterName) {
    string $filterEditor = "graphEditor1OutlineEd";
    filterUIChangeFilter $filterEditor $filterName;
    filterUICommit $filterEditor;
}

// Function to clear filtering in the Graph Editor
global proc clearGraphEditorFilter() {
    string $filterEditor = "graphEditor1OutlineEd";
    filterUIClearFilter $filterEditor;
}

// Function to clear the attribute filter and remove the scriptJob
global proc clearFilterAndRemoveScriptJob() {
    // Clear the attribute filter in the Graph Editor
    clearGraphEditorFilter();

    // Remove the scriptJob that synchronizes the selection
    global int $gSyncChannelBoxFcurveEdScriptJob;
    if (`scriptJob -ex $gSyncChannelBoxFcurveEdScriptJob`) {
        scriptJob -kill $gSyncChannelBoxFcurveEdScriptJob;
        // Set the scriptJob value to -1 to prevent it from being reactivated
        $gSyncChannelBoxFcurveEdScriptJob = -1;
    }
}

// Function to synchronize the Channel Box selection with the Graph Editor
global proc syncChannelBoxFcurveEd() {
    global string $gChannelBoxName;

    string $selAttrs[] = `selectedChannelBoxPlugs`;
    selectionConnection -e -clear graphEditor1FromOutliner;
    if (size($selAttrs) &amp;gt; 0) {
        for ($attr in $selAttrs) {
            selectionConnection -e -select $attr graphEditor1FromOutliner;
        }
        filterUIFilterSelection graphEditor1OutlineEd "";
    } else if (size($selAttrs) == 0) {
        string $objects[] = `channelBoxObjects`;
        for ($obj in $objects) {
            selectionConnection -e -select $obj graphEditor1FromOutliner;
        }
        clearGraphEditorFilter();
    }
}

// Function to synchronize the Channel Box selection with the Graph Editor
global proc syncChannelBoxFcurveEdCallback() {
    // Execute the synchronization function
    syncChannelBoxFcurveEd();
}

// Register the scriptJob to detect changes in the Channel Box selection
global int $gSyncChannelBoxFcurveEdScriptJob;
$gSyncChannelBoxFcurveEdScriptJob = `scriptJob -e "ChannelBoxLabelSelected" "syncChannelBoxFcurveEdCallback"`;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Aug 2023 23:23:47 GMT</pubDate>
    <dc:creator>dg3duy</dc:creator>
    <dc:date>2023-08-05T23:23:47Z</dc:date>
    <item>
      <title>Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12151671#M882</link>
      <description>&lt;P&gt;Attribute filtering.&lt;/P&gt;&lt;P&gt;Here I show you some code I'm doing to filter only the selected from the channelbox to the graph editor, turns out I can't stop the filtering after running kill scriptjob etc.&lt;/P&gt;&lt;P&gt;I can't get the filtering to stop with the tests I'm doing, so I post as far as I can, it filters the attribute but I can't get it to stop filtering when the user wants it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if there is someone who can find another way to do this, I'm sure many animators would appreciate it!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filter.gif" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1249655i6356CBDB5E05A203/image-size/large?v=v2&amp;amp;px=999" role="button" title="filter.gif" alt="filter.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// Function to apply filtering in the Graph Editor
global proc applyGraphEditorFilter(string $filterName) {
    string $filterEditor = "graphEditor1OutlineEd";
    filterUIChangeFilter $filterEditor $filterName;
    filterUICommit $filterEditor;
}

// Function to clear filtering in the Graph Editor
global proc clearGraphEditorFilter() {
    string $filterEditor = "graphEditor1OutlineEd";
    filterUIClearFilter $filterEditor;
}

// Function to clear the attribute filter and remove the scriptJob
global proc clearFilterAndRemoveScriptJob() {
    // Clear the attribute filter in the Graph Editor
    clearGraphEditorFilter();

    // Remove the scriptJob that synchronizes the selection
    global int $gSyncChannelBoxFcurveEdScriptJob;
    if (`scriptJob -ex $gSyncChannelBoxFcurveEdScriptJob`) {
        scriptJob -kill $gSyncChannelBoxFcurveEdScriptJob;
        // Set the scriptJob value to -1 to prevent it from being reactivated
        $gSyncChannelBoxFcurveEdScriptJob = -1;
    }
}

// Function to synchronize the Channel Box selection with the Graph Editor
global proc syncChannelBoxFcurveEd() {
    global string $gChannelBoxName;

    string $selAttrs[] = `selectedChannelBoxPlugs`;
    selectionConnection -e -clear graphEditor1FromOutliner;
    if (size($selAttrs) &amp;gt; 0) {
        for ($attr in $selAttrs) {
            selectionConnection -e -select $attr graphEditor1FromOutliner;
        }
        filterUIFilterSelection graphEditor1OutlineEd "";
    } else if (size($selAttrs) == 0) {
        string $objects[] = `channelBoxObjects`;
        for ($obj in $objects) {
            selectionConnection -e -select $obj graphEditor1FromOutliner;
        }
        clearGraphEditorFilter();
    }
}

// Function to synchronize the Channel Box selection with the Graph Editor
global proc syncChannelBoxFcurveEdCallback() {
    // Execute the synchronization function
    syncChannelBoxFcurveEd();
}

// Register the scriptJob to detect changes in the Channel Box selection
global int $gSyncChannelBoxFcurveEdScriptJob;
$gSyncChannelBoxFcurveEdScriptJob = `scriptJob -e "ChannelBoxLabelSelected" "syncChannelBoxFcurveEdCallback"`;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 23:23:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12151671#M882</guid>
      <dc:creator>dg3duy</dc:creator>
      <dc:date>2023-08-05T23:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12153729#M883</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your script works fine, it just has one simple problem, it allows you to register multiple scriptjobs that run your script. if your run:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;scriptJob -lj;&lt;/LI-CODE&gt;&lt;P&gt;You'll probably see that multiple jobs are calling "-e" "ChannelBoxLabelSelected" "syncChannelBoxFcurveEdCallback"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;since you override your global variable when you create a new scriptjob, those older scriptjobs won't be deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sultion to this problem is quite simple, you simply register your scriptjob inside an if statement that only runs when your variable "$gSyncChannelBoxFcurveEdScriptJob" is set to 0 (the default value of a int when it is registered) and you reset the variable to 0 when you delete your scriptjob.&lt;/P&gt;&lt;P&gt;This way you only have one scriptjob when you already registered one that does what you want.&lt;/P&gt;&lt;P&gt;Also for good measure you only run the deletion of the scriptjob if your global variable isn't 0 so you don't accidentally delete other registered scriptjobs, eventhough scriptjob 0 is always permanent so it doesn't really matter if you do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the script to activate filtering:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;global int $gSyncChannelBoxFcurveEdScriptJob;
// Function to apply filtering in the Graph Editor
global proc applyGraphEditorFilter(string $filterName) {
    string $filterEditor = "graphEditor1OutlineEd";
    filterUIChangeFilter $filterEditor $filterName;
    filterUICommit $filterEditor;
}

// Function to clear filtering in the Graph Editor
global proc clearGraphEditorFilter() {
    string $filterEditor = "graphEditor1OutlineEd";
    filterUIClearFilter $filterEditor;
}

// Function to clear the attribute filter and remove the scriptJob
global proc clearFilterAndRemoveScriptJob() {
    // Clear the attribute filter in the Graph Editor
    clearGraphEditorFilter();

    // Remove the scriptJob that synchronizes the selection
    global int $gSyncChannelBoxFcurveEdScriptJob;
    if ($gSyncChannelBoxFcurveEdScriptJob != 0){
    if (`scriptJob -ex $gSyncChannelBoxFcurveEdScriptJob`) {
        scriptJob -kill $gSyncChannelBoxFcurveEdScriptJob;
        // Set the scriptJob value to 0, to allow manual reactivation
        $gSyncChannelBoxFcurveEdScriptJob = 0;
    }
    }
}

// Function to synchronize the Channel Box selection with the Graph Editor
global proc syncChannelBoxFcurveEd() {
    global string $gChannelBoxName;

    string $selAttrs[] = `selectedChannelBoxPlugs`;
    selectionConnection -e -clear graphEditor1FromOutliner;
    if (size($selAttrs) &amp;gt; 0) {
        for ($attr in $selAttrs) {
            selectionConnection -e -select $attr graphEditor1FromOutliner;
        }
        filterUIFilterSelection graphEditor1OutlineEd "";
    } else if (size($selAttrs) == 0) {
        string $objects[] = `channelBoxObjects`;
        for ($obj in $objects) {
            selectionConnection -e -select $obj graphEditor1FromOutliner;
        }
        clearGraphEditorFilter();
    }
}

// Function to synchronize the Channel Box selection with the Graph Editor
global proc syncChannelBoxFcurveEdCallback() {
    // Execute the synchronization function
    syncChannelBoxFcurveEd();
}

// Register the scriptJob to detect changes in the Channel Box selection

global proc registerFilterScriptJob(){
global int $gSyncChannelBoxFcurveEdScriptJob;
if ($gSyncChannelBoxFcurveEdScriptJob == 0){
$gSyncChannelBoxFcurveEdScriptJob = `scriptJob -e "ChannelBoxLabelSelected" "syncChannelBoxFcurveEdCallback"`;
}
}
registerFilterScriptJob();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this command should now delete the scriptjob:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;clearFilterAndRemoveScriptJob();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 10:01:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12153729#M883</guid>
      <dc:creator>Kahylan</dc:creator>
      <dc:date>2023-08-07T10:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12154728#M884</link>
      <description>can you try and tell me if the filtering of the attributes stops with your suggestion, it does not stop completely when executing the line clearFilterAndRemoveScriptJob(); if we select next any attribute in the channelbox the filtering of the attribute works again.</description>
      <pubDate>Mon, 07 Aug 2023 16:39:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12154728#M884</guid>
      <dc:creator>dg3duy</dc:creator>
      <dc:date>2023-08-07T16:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12155624#M885</link>
      <description>&lt;P&gt;It stops completely for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you sure that you have deleted all the other scriptJobs that might are still there from previous attempts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can do so by using:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;scriptJob -ka;&lt;/LI-CODE&gt;&lt;P&gt;or by simply restarting Maya.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 00:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12155624#M885</guid>
      <dc:creator>Kahylan</dc:creator>
      <dc:date>2023-08-08T00:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12155693#M886</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11712848"&gt;@Kahylan&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;what I mean is that filtering is always present, and removing all scrptJob seems not to be an option because it breaks the natural connection between channelbox and graph editor, the default option stops working. I'm not sure what can be done anymore, I'm quite puzzled with not being able to turn off the graph editor filtering.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="scriptjob.gif" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1250403iAD3ABC3EE356E8A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="scriptjob.gif" alt="scriptjob.gif" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 01:44:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12155693#M886</guid>
      <dc:creator>dg3duy</dc:creator>
      <dc:date>2023-08-08T01:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12156294#M887</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A restart of Maya should fix the problem with the lost connection, sorry I didn't realise that this wasn't a protected scriptJob...&lt;BR /&gt;&lt;BR /&gt;But with the new script, once you restarted maya it should work without using "scriptJob -ka;" since multiregistering of the scriptJob doesn't happen again. Have you tried that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason why it stopped filtering when you used "scriptJob -ka;" is because it also deleted other scriptJobs that were filtering that you created when running the previous script multiple times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this doesn't work, there is a way to kill all specific scriptJobs that call your global procedure every time you turn it off, but that involves tokenizing and it is a lot slower than just making sure that your scriptJob doesn't get duplicated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 09:34:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12156294#M887</guid>
      <dc:creator>Kahylan</dc:creator>
      <dc:date>2023-08-08T09:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute filtering.</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12161116#M888</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11712848"&gt;@Kahylan&lt;/a&gt;&amp;nbsp;I already gave up the research, I will go a manual way 2 options on and off 2 buttons in a menu. Then it stops being interactive and goes to something more manual but it works fine.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 01:27:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/attribute-filtering/m-p/12161116#M888</guid>
      <dc:creator>dg3duy</dc:creator>
      <dc:date>2023-08-10T01:27:49Z</dc:date>
    </item>
  </channel>
</rss>

