<?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: How to remove duplicate tools in a list for a Notepad file in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11876762#M4234</link>
    <description>&lt;P&gt;I see your query has been answered, but thought I would share my tool list creation macro.&lt;/P&gt;&lt;P&gt;It allows you to pick the relevant tools, it save them along with some other tool details that i like to check prior to closing project to an XML file, i then have it open in Excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Macro to offer user a list of Tools in project, user selects those used for export ot Excel file for use in set up sheet - KJH 20/01/2023&lt;BR /&gt;//Variables&lt;BR /&gt;string user = user_id()&lt;BR /&gt;string msg = ""&lt;BR /&gt;string $Proj_path = project_pathname(0) + "\Tool_List"&lt;BR /&gt;MKDIR $proj_path&lt;BR /&gt;String logfile = "\Tool-list.csv"&lt;BR /&gt;String Log = $proj_path + $logfile&lt;BR /&gt;Message info "Tool list will be saved to -" +crlf+ $log +crlf+ "Then opened in Excel"&lt;BR /&gt;int toolnumber = ""&lt;BR /&gt;string Toolname = ""&lt;BR /&gt;string Toolid = ""&lt;BR /&gt;real tooloverhang = ""&lt;BR /&gt;string toolholder = ""&lt;BR /&gt;string pitch = ""&lt;BR /&gt;real tap_pitch = ""&lt;BR /&gt;string s = ","&lt;BR /&gt;string log_entry = ""&lt;BR /&gt;string type = ""&lt;BR /&gt;string log_space = ""&lt;BR /&gt;//create a list of tools in project&lt;BR /&gt;$msg = "select Tools for Output to list"&lt;BR /&gt;ENTITY LIST Tool = INPUT ENTITY MULTIPLE Tool $msg&lt;/P&gt;&lt;P&gt;//creates log file&lt;BR /&gt;FILE OPEN $log FOR WRITE AS log_file&lt;BR /&gt;$log_entry = "Tool_number, Tool_name, Tool_Overhang, Tool_Holder, Tap-Pitch,"&lt;BR /&gt;FILE WRITE $log_entry TO log_file&lt;BR /&gt;FILE CLOSE log_file&lt;/P&gt;&lt;P&gt;//loop through selected tools in list&lt;BR /&gt;FOREACH tl IN Tool {&lt;BR /&gt;Activate TOOL $tl.name&lt;BR /&gt;$toolnumber = $tl.Number.Value&lt;BR /&gt;$Toolname = $tl.Name&lt;BR /&gt;$toolid = $tl.Identifier&lt;BR /&gt;$tooloverhang = $tl.Overhang&lt;BR /&gt;$toolholder = $tl.HolderName&lt;BR /&gt;IF entity('tool','').type == 'tap' {&lt;BR /&gt;FORM TOOL ;&lt;BR /&gt;$tap_pitch = $widget("pmlTappingTool.Shell.TPGeom.Geometry.Pitch").value&lt;BR /&gt;$pitch = $tap_pitch&lt;BR /&gt;TOOL ACCEPT&lt;BR /&gt;} Else {&lt;BR /&gt;$pitch = ""&lt;BR /&gt;}&lt;BR /&gt;//write data to file&lt;BR /&gt;FILE OPEN $log FOR APPEND AS log_file&lt;BR /&gt;$log_entry = $toolnumber + "," + $Toolname + "," + $tooloverhang + "," + $toolholder + "," + $pitch&lt;BR /&gt;FILE WRITE $log_entry TO log_file&lt;/P&gt;&lt;P&gt;FILE CLOSE log_file&lt;BR /&gt;}&lt;BR /&gt;OLE FILEACTION 'OPEN' $log&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2023 06:09:08 GMT</pubDate>
    <dc:creator>kevin.hammond3WX4X</dc:creator>
    <dc:date>2023-04-06T06:09:08Z</dc:date>
    <item>
      <title>How to remove duplicate tools in a list for a Notepad file</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11875329#M4232</link>
      <description>&lt;P&gt;I have a macro that posts all my tools used in a toolpath for setups into a Notepad file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is if I have toolpaths that use the same tool they will show up in the list which I don't want and have to remove them manually.&amp;nbsp;See video.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to remove these duplicate tools from appearing in the Notepad list?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;//This macro oders toolpaths by their setup

    MKDIR "C:\Temp\Lineup"

    STRING dir = "C:\Temp\Lineup" + "/" + project.Name + ".txt"

    IF ($powermill.Status.MultipleSelection.First) OR ($powermill.Status.MultipleSelection.Total == 0) {

        DELETE FILE $dir

    }

   

     	STRING TOOLName=''
        

	STRING LIST SetupList = {}

	FOREACH SetupTP IN folder('setup') {
	  FOREACH TP IN components(SetupTP) {
	   int $Count = add_last(SetupList, TP.name)
	  }
	}



ENTITY LIST $Selected_Toolpath = INPUT ENTITY MULTIPLE TOOLPATH "Select Toolpaths For List Of Tools" "" $SetupList
FOREACH $tp IN $Selected_Toolpath {


    
     ACTIVATE TOOLPATH $tp
    ENTITY Tool = ENTITY('Tool', '')



	STRING LIST msgList = {}




    // Check that the toolpath is computed and that it has at least 1 segment.
    IF (NOT ENTITY('toolpath','').computed) OR (SEGMENTS(toolpath) == 0) {
        
        RETURN
    }

    INT toolDia = ROUND(($Tool.Diameter * 25.4), 1)

    IF (POSITION($Tool.Name, "MM") &amp;gt; -1) {

        IF $Tool.Diameter == "0.059" { 

            STRING msg = "T" + $tool.Number.Value + " " + ROUND(($Tool.Diameter * 25.4), 1) + " " + "MM " + $Tool.Description +  " " + ROUND($Tool.Overhang, 3) + " LONG"   

            INT $Ok = add_last($msgList, $msg)

        } ELSEIF $Tool.Diameter != "0.059" {

            STRING msg = "T" + $tool.Number.Value + " " + $toolDia + " " + "MM " + $Tool.Description + " " + ROUND($Tool.Overhang, 3) + " LONG"   

            INT $Ok = add_last($msgList, $msg)

        }
            

        } ELSE {

            STRING msg = "T" + $tool.Number.Value + " " + $Tool.Diameter + " " + $Tool.Description + " " + ROUND($Tool.Overhang, 3) + " LONG"  

            INT $Ok = add_last($msgList, $msg)

        }


    FOREACH item IN msgList {
        

        FILE OPEN $dir FOR APPEND AS "out"
        FILE WRITE $item TO "out"
        FILE CLOSE "out"

            }
            
}
        IF (size($Selected_Toolpath) != 0)  {


        OLE FILEACTION 'open' $dir

    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 17:09:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11875329#M4232</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2023-04-05T17:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate tools in a list for a Notepad file</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11876353#M4233</link>
      <description>&lt;LI-CODE lang="csharp"&gt;//This macro oders toolpaths by their setup

MKDIR "C:\Temp\Lineup"
STRING dir = "C:\Temp\Lineup" + "/" + project.Name + ".txt"

IF ($powermill.Status.MultipleSelection.First) OR ($powermill.Status.MultipleSelection.Total == 0) {
	DELETE FILE $dir
}

STRING TOOLName=''
STRING LIST SetupList = {}
FOREACH SetupTP IN folder('setup') {
	FOREACH TP IN components(SetupTP) {
		int $Count = add_last(SetupList, TP.name)
	}
}

ENTITY LIST $Selected_Toolpath = INPUT ENTITY MULTIPLE TOOLPATH "Select Toolpaths For List Of Tools" "" $SetupList
STRING LIST msgList = {}
FOREACH $tp IN $Selected_Toolpath {
	//ACTIVATE TOOLPATH $tp
	//ENTITY Tool = ENTITY('Tool', '')

	// Check that the toolpath is computed and that it has at least 1 segment.
	IF (NOT $tp.computed) OR (SEGMENTS($tp) == 0) {
		RETURN
	}

	ENTITY Tool = $tp.Tool
	INT toolDia = ROUND(($Tool.Diameter * 25.4), 1)
	IF (POSITION($Tool.Name, "MM") &amp;gt; -1) {
		IF $Tool.Diameter == "0.059" { 
			STRING msg = "T" + $tool.Number.Value + " " + ROUND(($Tool.Diameter * 25.4), 1) + " " + "MM " + $Tool.Description +  " " + ROUND($Tool.Overhang, 3) + " LONG"   
			IF NOT MEMBER($msgList, $msg) {
				INT $Ok = add_last($msgList, $msg)
			}
		} ELSEIF $Tool.Diameter != "0.059" {
			STRING msg = "T" + $tool.Number.Value + " " + $toolDia + " " + "MM " + $Tool.Description + " " + ROUND($Tool.Overhang, 3) + " LONG"   
			IF NOT MEMBER($msgList, $msg) {
				INT $Ok = add_last($msgList, $msg)
			}
		}
	} ELSE {
		STRING msg = "T" + $tool.Number.Value + " " + $Tool.Diameter + " " + $Tool.Description + " " + ROUND($Tool.Overhang, 3) + " LONG"  
		IF NOT MEMBER($msgList, $msg) {
			INT $Ok = add_last($msgList, $msg)
		}
	}
}
IF (size($Selected_Toolpath) &amp;gt; 0)  {
	FILE OPEN $dir FOR APPEND AS "out"
	FOREACH item IN msgList {
		FILE WRITE $item TO "out"
	}
	FILE CLOSE "out"
	OLE FILEACTION 'open' $dir
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Apr 2023 00:13:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11876353#M4233</guid>
      <dc:creator>rafael.sansao</dc:creator>
      <dc:date>2023-04-06T00:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate tools in a list for a Notepad file</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11876762#M4234</link>
      <description>&lt;P&gt;I see your query has been answered, but thought I would share my tool list creation macro.&lt;/P&gt;&lt;P&gt;It allows you to pick the relevant tools, it save them along with some other tool details that i like to check prior to closing project to an XML file, i then have it open in Excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Macro to offer user a list of Tools in project, user selects those used for export ot Excel file for use in set up sheet - KJH 20/01/2023&lt;BR /&gt;//Variables&lt;BR /&gt;string user = user_id()&lt;BR /&gt;string msg = ""&lt;BR /&gt;string $Proj_path = project_pathname(0) + "\Tool_List"&lt;BR /&gt;MKDIR $proj_path&lt;BR /&gt;String logfile = "\Tool-list.csv"&lt;BR /&gt;String Log = $proj_path + $logfile&lt;BR /&gt;Message info "Tool list will be saved to -" +crlf+ $log +crlf+ "Then opened in Excel"&lt;BR /&gt;int toolnumber = ""&lt;BR /&gt;string Toolname = ""&lt;BR /&gt;string Toolid = ""&lt;BR /&gt;real tooloverhang = ""&lt;BR /&gt;string toolholder = ""&lt;BR /&gt;string pitch = ""&lt;BR /&gt;real tap_pitch = ""&lt;BR /&gt;string s = ","&lt;BR /&gt;string log_entry = ""&lt;BR /&gt;string type = ""&lt;BR /&gt;string log_space = ""&lt;BR /&gt;//create a list of tools in project&lt;BR /&gt;$msg = "select Tools for Output to list"&lt;BR /&gt;ENTITY LIST Tool = INPUT ENTITY MULTIPLE Tool $msg&lt;/P&gt;&lt;P&gt;//creates log file&lt;BR /&gt;FILE OPEN $log FOR WRITE AS log_file&lt;BR /&gt;$log_entry = "Tool_number, Tool_name, Tool_Overhang, Tool_Holder, Tap-Pitch,"&lt;BR /&gt;FILE WRITE $log_entry TO log_file&lt;BR /&gt;FILE CLOSE log_file&lt;/P&gt;&lt;P&gt;//loop through selected tools in list&lt;BR /&gt;FOREACH tl IN Tool {&lt;BR /&gt;Activate TOOL $tl.name&lt;BR /&gt;$toolnumber = $tl.Number.Value&lt;BR /&gt;$Toolname = $tl.Name&lt;BR /&gt;$toolid = $tl.Identifier&lt;BR /&gt;$tooloverhang = $tl.Overhang&lt;BR /&gt;$toolholder = $tl.HolderName&lt;BR /&gt;IF entity('tool','').type == 'tap' {&lt;BR /&gt;FORM TOOL ;&lt;BR /&gt;$tap_pitch = $widget("pmlTappingTool.Shell.TPGeom.Geometry.Pitch").value&lt;BR /&gt;$pitch = $tap_pitch&lt;BR /&gt;TOOL ACCEPT&lt;BR /&gt;} Else {&lt;BR /&gt;$pitch = ""&lt;BR /&gt;}&lt;BR /&gt;//write data to file&lt;BR /&gt;FILE OPEN $log FOR APPEND AS log_file&lt;BR /&gt;$log_entry = $toolnumber + "," + $Toolname + "," + $tooloverhang + "," + $toolholder + "," + $pitch&lt;BR /&gt;FILE WRITE $log_entry TO log_file&lt;/P&gt;&lt;P&gt;FILE CLOSE log_file&lt;BR /&gt;}&lt;BR /&gt;OLE FILEACTION 'OPEN' $log&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 06:09:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/how-to-remove-duplicate-tools-in-a-list-for-a-notepad-file/m-p/11876762#M4234</guid>
      <dc:creator>kevin.hammond3WX4X</dc:creator>
      <dc:date>2023-04-06T06:09:08Z</dc:date>
    </item>
  </channel>
</rss>

