Tool Tree Set-Up Sheet

Tool Tree Set-Up Sheet

Anonymous
Not applicable
8,350 Views
58 Replies
Message 1 of 59

Tool Tree Set-Up Sheet

Anonymous
Not applicable

I am looking for help to make a macro that will take all of my tools on the tool tree, organize them in numerical order and then export them into a format that is printable.  This would be beneficial when I have a multi-program Powermill file, so that the operator only has to look at one tooling list when setting up the machine for all the programs.

 

 

This info into printable form:

 

2017-07-06 15_19_23-PowerMill Explorer.png

 

Thanks for any help.

0 Likes
8,351 Views
58 Replies
Replies (58)
Message 2 of 59

Scoobyvroom
Advocate
Advocate

Wouldn't it be easier to just screen shot it and print it out?

 

 

Smiley Very Happy

 

P.S. get back to work....

 

P.S.S. I've been lurking the forums for awhile.

0 Likes
Message 3 of 59

iamcdn79
Mentor
Mentor

Try this

 

FOREACH tl IN (sort(folder('tool'),'diameter')) {
ORDERSESSION Tool $tl.name FIRST
}

For exporting to a format that is printable I am not sure about that


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

Message 4 of 59

LasseFred
Collaborator
Collaborator

If you want to print something to a txt file use this:

 

STRING $PRINTNAME_PATH = "C:\printname.txt"
STRING $RMDIR = // what do you want to print
FILE OPEN $PRINTNAME_PATH FOR WRITE AS PRINTNAME
FILE WRITE $RMDIR TO PRINTNAME
FILE CLOSE PRINTNAME

______________________
Lasse F.
Message 5 of 59

5axes
Advisor
Advisor

You can Export via a macro the list as an Html file and customize this HTML file accroding to your needs. Herewith a sample macro.  The Tool Icone is in this case a preview of the tool assembly.

 

After the HTML generation the file is open in your favourite browser so you can directly print the result.

 

Print preview :

export_outil.jpg

 

 

You can also make the same, but just with the tool used in the Toolpaths or in an NC program.

 

Message 6 of 59

Scoobyvroom
Advocate
Advocate

I work with the original poster. Your macro works very nicely. Only problem is I don't speak French? I was able to modify it to be readable. I have one issue though when it creates the tool image that it's not creating the images in the folder inside the project. All I end up with is a .html file, with no pictures. Have you seen this before? Tried it before editing, so even the original did this.

 

Thanks for all your time!

0 Likes
Message 7 of 59

5axes
Advisor
Advisor

Yes I think I know the origin of your issue: You certainly have some space in the path of your Project.

 

You will find herewith a modified version to manage this problem.  In the same time I have also made a small modification on the definition of the Image size. I'm using Chrome but with IE the Size definition is not correct. So in the Macro, you will have in the Comment the code for Chrome ( Firefox ?) And IE.

 

For the French ... Google Translate.Google.com  will be your friend .. There is not so many sentence and comment to translate.Smiley Happy

Message 8 of 59

LasseFred
Collaborator
Collaborator

is there a quick way to make that HTML tool-list macro to work with the tools of the NC-Programs?

______________________
Lasse F.
0 Likes
Message 9 of 59

rafael.sansao
Advisor
Advisor

Hello,

Attached

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

Message 10 of 59

5axes
Advisor
Advisor

Could be much more simple Smiley Wink.. Just  three lines to modify if it's just for one NCProgram

 

Replace :

FOREACH tp IN folder('Tool') {

by

FOREACH Tl IN list_nctools(entity('ncprogram', Selected_NCP)) {
ENTITY $Tp=entity('Tool',$Tl)

 

Where Selected_NCP  is the selected NCProgram. You have the choice to select this variable via :

FUNCTION Main(STRING $Selected_NCP) {  

If you want to launch the macro via the ncprogram.xml user menu .. Or Something like  :

STRING Selected_NCP = entity('ncprogram','').name

If you want to generate the list for the active NCProgram.

Message 11 of 59

rafael.sansao
Advisor
Advisor

Only for NC Program selected. Smiley Wink

I understand that he wants to get a complete list of tools used in the project

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

Message 12 of 59

LasseFred
Collaborator
Collaborator

It was a complete list of the NC-Programs i asked for. 😉 

 

But thanks 🙂 

______________________
Lasse F.
0 Likes
Message 13 of 59

rui_rita
Advocate
Advocate

@LasseFred

 

you can use the summary_project

 

to export all or the selected nc programs, and you can setup your template to export what you relay need ( if it is only the tools)



Os melhores cumprimentos | Best regards
Rui Rita
________________________________
NEWCAM, Lda.
0 Likes
Message 14 of 59

LasseFred
Collaborator
Collaborator

@rui_rita 

 

I use the summary_project for another thing. 

but yes it can definitely be used to that purpose....

______________________
Lasse F.
0 Likes
Message 15 of 59

Scoobyvroom
Advocate
Advocate

Thanks for the help! I've got it 95% what I want. I was trying to get an argument to check tool number, and if it's zero skip that tool. I am missing something because it ends up stuck in some sort of loop.

 

FOREACH tl IN reverse(sort(folder('tool'),'number')) {
	IF Tool.Number=0{
	// Check tool number. If 0 skip
		CONTINUE
}
ORDERSESSION Tool $tl.name FIRST
}
0 Likes
Message 16 of 59

Anonymous
Not applicable

To test if a value is equal  to something you must use '==' if the value is different '!='

 

// Check tool number. If 0
IF $tl.Number.Value == 0 {

} ELSE {

}

In your case you can also just test  if the tool have a number.

 

IF $tl.Number.UserDefined {

} ELSE {

}

 

Message 17 of 59

Scoobyvroom
Advocate
Advocate

Ah! Thank you sir. Alright I got it to do everything I need... Almost...

 

The only issue I have is that some of our tool names have a "/" forward slash in them. We have some tools that have fraction endmill descriptions(1/4 Endmill). So we have some tool names with a forward slash in them. Or like our threadmills, are made for both a 8/10-32 thread pitch. 

 

These forward slashes mess with the Toollist. I think it has to do with the creation of the .jpg file. It populates the data in the table but the link to the picture is broken. In the folder there is no picture. I am not sure how to proceed with fixing this problem. 

 

//-------------------------------------------------------------------------------------
// Ouvre un fichier pour écrire le tableau outil (Type HTML)
// Liste tous les outils
//
// Modif 06/06/2016 : Export via ecriture fichier
// Modif 06/07/2017 : Gestion des espaces dans les noms des projets
//					: Format pour Chrome ou IE
// Modify: 7/20/2017: Added code to organize tools in correct order. All changes marked V1 CBJ
// Modify: 7/26/2017: Added continue code $tp must be a french thing? All changes marked V2 CBJ
//--------------------------------------------------------------------------------------

DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT

//Check the name of the project and if it have been already save
STRING $projectName = project_pathname(1)

STRING Msg = ""
STRING Cmd = ""

IF $projectName == "" {
$Msg = "Unable to create documents for export, you must first save the project!"
MESSAGE ERROR $Msg
MACRO ABORT 
}

// Création d'un répertoire Export_ExportTool dans le Projet en cours
// Répertoire Export ExportTool
STRING $ExportToolTempDir = project_pathname(0) + "/Tool_List"
MKDIR $ExportToolTempDir
STRING $ExportToolImg = ''  
STRING $ToolName = ''
STRING $ModiToolName = ''

// Definition Fichier Html  
STRING $Ligne=''
STRING $Fichier=$ExportToolTempDir+'/Tool_List.html'

//Ouverture fichier
FILE OPEN $Fichier FOR WRITE AS filename

$Ligne = "<html>"
FILE WRITE $Ligne TO filename
$Ligne = "<head>"
FILE WRITE $Ligne TO filename
$Ligne = "<title>Tool List</title>"
FILE WRITE $Ligne TO filename
$Ligne = "</head>"
FILE WRITE $Ligne TO filename
$Ligne = "<body lang=FR>"
FILE WRITE $Ligne TO filename
$Ligne = "<H1>"+$projectName + "</H1>"
FILE WRITE $Ligne TO filename
// Reorders Tools By Tool Number
FOREACH tl IN reverse(sort(folder('tool'),'number')) {
// Orders tools in project, added reverse to change order V1	
ORDERSESSION Tool $tl.name FIRST
}

$Ligne = "<table border=1 cellspacing=1 cellpadding=1>"
FILE WRITE $Ligne TO filename


// Première ligne
$Ligne = "<TR>"
FILE WRITE $Ligne TO filename
$Ligne = "<TD><H3>Image</H3></TD><TD><H3>Name</H3></TD><TD><H3>Number</H3></TD><TD><H3>Diameter</H3></TD><TD><H3>Type</H3></TD><TD><H3>Corner Radius</H3></TD><TD><H3>Flute Length</H3></TD><TD><H3>Stick Out Length</H3></TD><TD><H3>Tool Overall Length</H3></TD><TD><H3>Holder</H3></TD>"
FILE WRITE $Ligne TO filename
$Ligne = "</TR>"
FILE WRITE $Ligne TO filename

/// Liste tous les outils
FOREACH tp IN folder('Tool') {
	
		IF $tp.Number.value == 0 {
			CONTINUE
			//Checks tool number, if zero skips V2
			}
	
	// Depuis les Outils
$Ligne = "<TR>"
FILE WRITE $Ligne TO filename
        // Image
        
        $Ligne = "<TD>"
        FILE WRITE $Ligne TO filename
        $Ligne = '<div align="' + 'center"' + '>'
        FILE WRITE $Ligne TO filename
        
        // CREATION IMAGE
        $ToolName = $tp.name
		$ModiToolName=REPLACE($ToolName," ","_")
        $ExportToolImg = $ModiToolName + ".jpg" 
		
        $ExportToolImg = REPLACE($ExportToolImg," ","_")
		$ExportToolImg = $ExportToolTempDir + "/" + $ExportToolImg
	    $Cmd='FORM RAISE TOOLASSPREVIEWFORM "' + $ToolName + '"'
        DOCOMMAND $Cmd
     
        /// WAIT FORM Indispensable car sinon la Macro plante 
        //  Il faut attendre la forme pour executer la suite
        /// MACRO PAUSE "Outil $ToolName : $ExportToolImg"
        WAIT FORM
        
        // Generation Tool Preview
	    $Cmd='EXPORT TOOLASSEMBLYPREVIEW FILE "' + $ExportToolImg  +'"'
        DOCOMMAND $Cmd
        
        YES
        
        FORM CANCEL TOOLASSPREVIEWFORM
        
        // DEFINITION IMAGE
		// Pour Chrome
        $Ligne = '<img src="./' + $ModiToolName + ".jpg" + '" alt="' + $ToolName + '"' + ' height="' + '10%"' +' />'
		// Pour IE
		//$Ligne = '<img src="./' + $ModiToolName + ".jpg" + '" alt="' + $ToolName + '"' + ' height="' + '100p"' +' />'
        FILE WRITE $Ligne TO filename
        
	$Ligne = "</div>"
	FILE WRITE $Ligne TO filename
        $Ligne = "</TD>"
        FILE WRITE $Ligne TO filename
        	
        // Infos Outils
	$Ligne = "<TD>"+$tp.name + "</TD><TD>" +$tp.Number.Value + "</TD><TD>" + round($tp.Diameter,3) + "</TD><TD>" + $tp.Type+ "</TD><TD>" + round($tp.TipRadius,3) + "</TD><TD>" + round($tp.Length,3) + "</TD><TD>" + round($tp.Overhang,3) + "</TD><TD>" + round(gauge_length($tp),3)+ "</TD><TD>" + $tp.HolderName  + "</TD>"
	FILE WRITE $Ligne TO filename
$Ligne = "</TR>"
FILE WRITE $Ligne TO filename

	
}

$Ligne = "</table>"
FILE WRITE $Ligne TO filename
$Ligne = "</body>"
FILE WRITE $Ligne TO filename
$Ligne = "</html>"
FILE WRITE $Ligne TO filename

FILE CLOSE filename

MESSAGE INFO "Export Finished: $Fichier"
// Ouverture fichier avec application associée
ole fileaction 'open' $Fichier
0 Likes
Message 18 of 59

Anonymous
Not applicable

Hello,

 

It's a minor problem, I think you just have in your code to add after the ligne : $ModiToolName=REPLACE($ToolName," ","_"), the same type of correction with the code :  $ModiToolName=REPLACE($ModiToolName,"/","-") to create a correct path for your picture file.

Add also the line $ModiToolName=REPLACE($ModiToolName,"\","-")  to anticipate also the problem with the backslash character.

 

Message 19 of 59

Scoobyvroom
Advocate
Advocate

Sweet, thank you again. Got it working like we want. you guys are awesome!

0 Likes
Message 20 of 59

5axes
Advisor
Advisor

Hello,

 

I'm also currently working on a new version of this macro, if someone is interest, Modifications :
• Exports also the preview for turning Tool ( I'm using PMILL 2017) this problem is perhaps solved in 2018 ?
• Exports turning tool and milling tool in realistic mode
• Exports the Milling tool in a horizontal orientation
• Exports Folder Information

 

Herefater a preview of the resultListe_Tool.jpg