<?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: Sorting a entity list in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437950#M2679</link>
    <description>&lt;P&gt;This is tricky. It looks like Powermill macros poorly handles (ENUM) types in function for lists. In you macro there are some mistakes, but even after I have corrected them, I was still unable to sort the tools by the 'Type'.&lt;/P&gt;&lt;P&gt;I'm not exactly sure what is your plan but still here is an alternative where the tools are sorted into folders according to its types and then sorted by names inside.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;//Tool folder
string $db = 'Tool\'

FOREACH $tl IN folder($db) {
	IF NOT folder_exists('Tool\'+$tl.Type) {
		CREATE FOLDER "Tool" ${$string($tl.Type)}
	}
	EDIT FOLDER ${'Tool\'+$tl.Type} INSERT $tl LAST
}

FOREACH $fld IN get_folders('Tool') {
	FOREACH $tl IN sort(folder($fld),'Name') {
		EDIT FOLDER $fld ORDER ${$fld + "\" + $tl.Name} LAST
	}
}

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 07:42:03 GMT</pubDate>
    <dc:creator>ondrej.mikulec</dc:creator>
    <dc:date>2023-12-13T07:42:03Z</dc:date>
    <item>
      <title>Sorting a entity list</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437764#M2678</link>
      <description>&lt;P&gt;Hey everyone I'm trying to get my macro to work and it's either not the results I need or errors lol....&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an entity list that I'm looking to sort the tool.type&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have.....&lt;/P&gt;&lt;P&gt;***NOTE: Might have spelling errors but that's not my problem ***&lt;/P&gt;&lt;LI-CODE lang="general"&gt;//Tool folder
string $db = 'Tool\'
//Empty lists
string list $sortedTools = {}
Entity list $myTools = reverse(sort(folder($db),'$tool.type'))
foreach $tool.type IN $myTools {

//MACRO CONTINUES.... 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 05:37:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437764#M2678</guid>
      <dc:creator>jsweatherbie</dc:creator>
      <dc:date>2023-12-13T05:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting a entity list</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437950#M2679</link>
      <description>&lt;P&gt;This is tricky. It looks like Powermill macros poorly handles (ENUM) types in function for lists. In you macro there are some mistakes, but even after I have corrected them, I was still unable to sort the tools by the 'Type'.&lt;/P&gt;&lt;P&gt;I'm not exactly sure what is your plan but still here is an alternative where the tools are sorted into folders according to its types and then sorted by names inside.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;//Tool folder
string $db = 'Tool\'

FOREACH $tl IN folder($db) {
	IF NOT folder_exists('Tool\'+$tl.Type) {
		CREATE FOLDER "Tool" ${$string($tl.Type)}
	}
	EDIT FOLDER ${'Tool\'+$tl.Type} INSERT $tl LAST
}

FOREACH $fld IN get_folders('Tool') {
	FOREACH $tl IN sort(folder($fld),'Name') {
		EDIT FOLDER $fld ORDER ${$fld + "\" + $tl.Name} LAST
	}
}

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 07:42:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437950#M2679</guid>
      <dc:creator>ondrej.mikulec</dc:creator>
      <dc:date>2023-12-13T07:42:03Z</dc:date>
    </item>
    <item>
      <title>Betreff: Sorting a entity list</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437995#M2680</link>
      <description>&lt;P&gt;this should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;entity list $tools = {}
string list $types = sort(apply(extract(folder('tool'),'Type'),'string(this)'))
int $removed = remove_duplicates($types)

foreach $type in $types {
	foreach $t in filter(folder('tool'),'this.Type =="' + $type + '"') {
		int $index = add_last($tools,entity('tool',$t.Name))
	}
}

string $msg = ''
foreach $t in $tools {
	$msg = $msg + $t.Name + "   " + $t.type + CRLF
	
}
message info $msg&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 14:02:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/sorting-a-entity-list/m-p/12437995#M2680</guid>
      <dc:creator>icse</dc:creator>
      <dc:date>2023-12-13T14:02:53Z</dc:date>
    </item>
  </channel>
</rss>

