Macro NEED HELP!

nlegareLUZKA
Participant

Macro NEED HELP!

nlegareLUZKA
Participant
Participant
HELLO EVERYONE
I WOULD LIKE TO ADD A CONDITION TO MY MACRO 'CHECK_COLLISION'(SEE ATTACHMENT)
AND I DON'T KNOW HOW TO DO IT SO I WILL NEED YOUR HELP.
HERE IS THE CONDITION.
I WOULD LIKE, IF A COLLISION IS DETECTED, THAT THE PROBLEMATIC TOOLPATH BE RENAMMED
'TOOLPATH NAME + _COLLISION' WITHOUT THE MACRO BEING STOPPED.

THANK YOU FOR YOUR HELP AND TIME. IT IS REALLY APPRECIATED!

 

0 Likes
Reply
647 Views
10 Replies
Replies (10)

icse
Collaborator
Collaborator

try this:

FOREACH tp IN folder('Toolpath') {

	IF NOT tp.Computed {

		ACTIVATE TOOLPATH $tp.Name

		EDIT TOOLPATH $tp.Name CALCULATE
	}

}



FOREACH tp IN folder('Toolpath') {

	ACTIVATE TOOLPATH $tp.Name

	ACTIVATE StockModel "P#01 - STM_Blank milling_1"

	EDIT COLLISION TYPE COLLISION

	EDIT COLLISION STOCKMODEL_CHECK Y

	EDIT COLLISION STOCKMODEL  "P#01 - STM_Blank milling"

	EDIT COLLISION SCOPE ALL

	EDIT COLLISION SPLIT_TOOLPATH N

	EDIT COLLISION MISS_OUTPUT N

	EDIT PAR 'Verification.UseVerificationThickness' 0

	EDIT COLLISION HEAD_CLEARANCE "600.0"

	EDIT COLLISION HOLDER_CLEARANCE "1.0"

	EDIT COLLISION SHANK_CLEARANCE "0.3"

	EDIT COLLISION DEPTH Y

	EDIT COLLISION ADJUST_TOOL N

	UNDRAW COLLISION

	EDIT COLLISION APPLY

	EDIT STOCKMODEL ; INSERT_INPUT TOOLPATH $tp.Name LAST

	EDIT STOCKMODEL "P#01 - STM_Blank milling_1" CALCULATE
	
	if Safety.Holder.Cutting.Status == 'collides' or Safety.Holder.Leads.Status == 'collides' or Safety.Holder.Links.Status == 'collides' or Safety.Tool.Cutting.Status == 'collides' or Safety.Tool.Leads.Status == 'collides' or Safety.Tool.Links.Status == 'collides' {
		
		string $newName = $tp.Name + "_COLLISION"
		if entity_exists('toolpath',$newName) {
			$newName = new_entity_name('toolpath',$newName)
		}
		RENAME Toolpath ; ${newName}
	}

}	



DIALOGS MESSAGE ON

DIALOGS ERROR ON

GRAPHICS UNLOCK

 

did not tested it...

0 Likes

nlegareLUZKA
Participant
Participant
Unfortunately, it doesn't work. The toolpath is not renamed.

thanks for the help
0 Likes

icse
Collaborator
Collaborator

Sorry i'm not at my pc ill check it tomorrow. 

0 Likes

icse
Collaborator
Collaborator

this should work

FOREACH tp IN folder('Toolpath') {

	IF NOT tp.Computed {

		ACTIVATE TOOLPATH $tp.Name

		EDIT TOOLPATH $tp.Name CALCULATE
	}

}



FOREACH tp IN folder('Toolpath') {

	ACTIVATE TOOLPATH $tp.Name

	ACTIVATE StockModel "P#01 - STM_Blank milling_1"

	EDIT COLLISION TYPE COLLISION

	EDIT COLLISION STOCKMODEL_CHECK Y

	EDIT COLLISION STOCKMODEL  "P#01 - STM_Blank milling"

	EDIT COLLISION SCOPE ALL

	EDIT COLLISION SPLIT_TOOLPATH N

	EDIT COLLISION MISS_OUTPUT N

	EDIT PAR 'Verification.UseVerificationThickness' 0

	EDIT COLLISION HEAD_CLEARANCE "600.0"

	EDIT COLLISION HOLDER_CLEARANCE "1.0"

	EDIT COLLISION SHANK_CLEARANCE "0.3"

	EDIT COLLISION DEPTH Y

	EDIT COLLISION ADJUST_TOOL N

	UNDRAW COLLISION

	EDIT COLLISION APPLY

	EDIT STOCKMODEL ; INSERT_INPUT TOOLPATH $tp.Name LAST

	EDIT STOCKMODEL "P#01 - STM_Blank milling_1" CALCULATE
	
	if $tp.Safety.Holder.Cutting.Status == 'collides' or $tp.Safety.Holder.Leads.Status == 'collides' or $tp.Safety.Holder.Links.Status == 'collides' or $tp.Safety.Tool.Cutting.Status == 'collides' or $tp.Safety.Tool.Leads.Status == 'collides' or $tp.Safety.Tool.Links.Status == 'collides' {
		
		string $newName = $tp.Name + "_COLLISION"
		if entity_exists('toolpath',$newName) {
			$newName = new_entity_name('toolpath',$newName)
		}
		RENAME Toolpath ${tp.Name} ${newName}
	}

}	



DIALOGS MESSAGE ON

DIALOGS ERROR ON

GRAPHICS UNLOCK
0 Likes

nlegareLUZKA
Participant
Participant
It still does not work...
0 Likes

icse
Collaborator
Collaborator

Can you explain the problem a bit more. 

 

Does the macro stop at a certain point?

 

I just tested the renaming part ive added.

0 Likes

nlegareLUZKA
Participant
Participant
the macro does not stop but the problematic toolpath is not renamed.
0 Likes

icse
Collaborator
Collaborator

For me the code of my last post works fine...

 

here with all collision checking removed:

foreach $tp in filter(folder('toolpath'),'this.RootType == "toolpath"') {
	if $tp.Safety.Holder.Cutting.Status == 'collides' or $tp.Safety.Holder.Leads.Status == 'collides' or $tp.Safety.Holder.Links.Status == 'collides' or $tp.Safety.Tool.Cutting.Status == 'collides' or $tp.Safety.Tool.Leads.Status == 'collides' or $tp.Safety.Tool.Links.Status == 'collides' {
		
		string $newName = $tp.Name + "_COLLISION"
		if entity_exists('toolpath',$newName) {
			$newName = new_entity_name('toolpath',$newName)
		}
		RENAME Toolpath ${tp.Name} ${newName}
	}
}

 

 

 

 

0 Likes

nlegareLUZKA
Participant
Participant
Here is the macro rewritten as I think I understood it.
Did I make a mistake? Am I forgetting something?
It's still the same result. It is read to the end without problem,
but the toolpath which is in collision is still not renamed. Thanks again for your help. It is more than appreciated.
0 Likes

icse
Collaborator
Collaborator

try running only this:

 

foreach $tp in filter(folder('toolpath'),'this.RootType == "toolpath"') {
	if $tp.Safety.Holder.Cutting.Status == 'collides' or $tp.Safety.Holder.Leads.Status == 'collides' or $tp.Safety.Holder.Links.Status == 'collides' or $tp.Safety.Tool.Cutting.Status == 'collides' or $tp.Safety.Tool.Leads.Status == 'collides' or $tp.Safety.Tool.Links.Status == 'collides' {
		
		string $newName = $tp.Name + "_COLLISION"
		if entity_exists('toolpath',$newName) {
			$newName = new_entity_name('toolpath',$newName)
		}
		RENAME Toolpath ${tp.Name} ${newName}
	}
}

 

i just added my code at the end of your macro

 

 

if this works heres the complere macro:

 

DIALOGS MESSAGE OFF

DIALOGS ERROR OFF

GRAPHICS LOCK

	

		

		FOREACH tp IN folder('Toolpath') {

		IF NOT tp.Computed {

		ACTIVATE TOOLPATH $tp.Name

		EDIT TOOLPATH $tp.Name CALCULATE

		}

}



		FOREACH tp IN folder('Toolpath') {

		ACTIVATE TOOLPATH $tp.Name

		ACTIVATE StockModel "P#01 - STM_Blank milling_1"

		EDIT COLLISION TYPE COLLISION

		EDIT COLLISION STOCKMODEL_CHECK Y

		EDIT COLLISION STOCKMODEL  "P#01 - STM_Blank milling"

		EDIT COLLISION SCOPE ALL

		EDIT COLLISION SPLIT_TOOLPATH N

		EDIT COLLISION MISS_OUTPUT N

		EDIT PAR 'Verification.UseVerificationThickness' 0

		EDIT COLLISION HEAD_CLEARANCE "600.0"

		EDIT COLLISION HOLDER_CLEARANCE "1.0"

		EDIT COLLISION SHANK_CLEARANCE "0.3"

		EDIT COLLISION DEPTH Y

		EDIT COLLISION ADJUST_TOOL N

		UNDRAW COLLISION

		EDIT COLLISION APPLY

		EDIT STOCKMODEL ; INSERT_INPUT TOOLPATH $tp.Name LAST

		EDIT STOCKMODEL "P#01 - STM_Blank milling_1" CALCULATE

}	

foreach $tp in filter(folder('toolpath'),'this.RootType == "toolpath"') {
	if $tp.Safety.Holder.Cutting.Status == 'collides' or $tp.Safety.Holder.Leads.Status == 'collides' or $tp.Safety.Holder.Links.Status == 'collides' or $tp.Safety.Tool.Cutting.Status == 'collides' or $tp.Safety.Tool.Leads.Status == 'collides' or $tp.Safety.Tool.Links.Status == 'collides' {
		
		string $newName = $tp.Name + "_COLLISION"
		if entity_exists('toolpath',$newName) {
			$newName = new_entity_name('toolpath',$newName)
		}
		RENAME Toolpath ${tp.Name} ${newName}
	}
}

DIALOGS MESSAGE ON

DIALOGS ERROR ON

GRAPHICS UNLOCK

 

0 Likes