Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Macro for Toolist

Anonymous

Macro for Toolist

Anonymous
Not applicable

Hello out there

Im currently using this macro for creating a toollist

Its a macro i've found on this forum, cant remember who made it. but i've made some small changes and everything is good.

 

But i can't seem to figure out how to get the macro to sort the tools according to the toolnumber, maybe you guys could help me?

 

Kind regards

Marc Willumsen

0 Likes
Reply
Accepted solutions (1)
1,341 Views
8 Replies
Replies (8)

rafael.sansao
Advisor
Advisor

@5axes is the developer of this macro. Maybe he'll help you with your request.

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

5axes
Advisor
Advisor

It's me 🙂

 

 I already change some lines in this macro due to an issue with  FOREACH Tl IN list_nctools(entity('ncprogram', '')) {

because list_nctools returns the ToolId and not the name and if the toolid is diffrent from the tool.name you can have some problems.

 

The new code is :

// build the expression
STRING $expr = "RootType=='nctoolpath'"
// get the list of tool (sorted in the NCProgram order)
STRING LIST $tl_list = extract(filter(components(entity('ncprogram', $Selected_NCP)), $expr), 'tool.name')
INT Nb=remove_duplicates($tl_list)

/// Liste tous les outils
FOREACH ToolName IN $tl_list {

 

It's longer but better . And because it's better I think you can do what you want by adding a sort instruction ... in the $Tl_List definition .. I need to check that ..

0 Likes

5axes
Advisor
Advisor

Yes, simple .. I've just made the test : Add to the previous code a sort instruction 🙂

 

// build the expression
STRING $expr = "RootType=='nctoolpath'"
// get the list of tool (sorted in the NCProgram order)
STRING LIST $tl_list = extract(sort(filter(components(entity('ncprogram', $Selected_NCP)), $expr) ,'tool.number') , 'tool.name')
INT Nb=remove_duplicates($tl_list)
/// Liste tous les outils
FOREACH ToolName IN $tl_list {

 :  

Anonymous
Not applicable

So i've tried replacing the code, but im not quite sure where to put it or what to delete

Am i even close or?

Stops at first ENTITY Smiley Sad

 

And yes i've also experinced the fault with the tool names, mainly because in my country we use "ÆØÅ" and when changed the tool name in the list it still couldnt save the image, but figured it out like 2 weeks ago Smiley Very Happy 

STRING $Fold=''
STRING $CFold=''
STRING $Sz="80p" 

// build the expression
STRING $expr = "RootType=='nctoolpath'"
// get the list of tool (sorted in the NCProgram order)
STRING LIST $tl_list = extract(sort(filter(components(entity('ncprogram', $Selected_NCP)), $expr) ,'tool.number') , 'tool.name')
INT Nb=remove_duplicates($tl_list)
/// Liste tous les outils
FOREACH ToolName IN $tl_list {
ENTITY $tp=entity('Tool',$Tl)
        $ToolName = $tp.name
	ENTITY C_Tool = entity('Tool',$ToolName)
	$Fold=dirname(Pathname($C_Tool))
		
	IF $Fold != $CFold {
		// MESSAGE INFO " $Fold   $CFold " 
		$Ligne = "<TR><TD colspan=10 style='background:#4F81BD'><H3>"+ $Fold + "</H3></TD></TR>"
		FILE WRITE $Ligne TO filename
		$CFold=$Fold	
	}
	
	// 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
	$ModiToolName=REPLACE($ToolName," ","_")
	$ModiToolName=REPLACE($ModiToolName,"/","-") // Corrige les nom outils du type  1/4 Endmill

Kind regards

Marc W

0 Likes

5axes
Advisor
Advisor

try with this code ..

 

And for your issue with your langage .. I Just have the solution to add the different REPLACE instruction :

 

$ModiToolName=REPLACE($ModiToolName,"Æ","AE")

$ModiToolName=REPLACE($ModiToolName,"Ø","O")

$ModiToolName=REPLACE($ModiToolName,"Å","A")

 

Etc ..

 

Anonymous
Not applicable

1.JPGIm getting some errors 😞2.JPG

0 Likes

5axes
Advisor
Advisor
Accepted solution

Oup's   It was the wrong macro Smiley Embarassed     This one is used to create the toollist from a selected NCProgram.

 

Try with this one

 

 

 

Anonymous
Not applicable

Works like a charm, thank you so much Smiley Very Happy

 

Best regards

Marc W

0 Likes