Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro NEED HELP!

10 REPLIES 10
Reply
Message 1 of 11
nlegareLUZKA
488 Views, 10 Replies

Macro NEED HELP!

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!

 

10 REPLIES 10
Message 2 of 11
icse
in reply to: nlegareLUZKA

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...

Message 3 of 11
nlegareLUZKA
in reply to: icse

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

thanks for the help
Message 4 of 11
icse
in reply to: nlegareLUZKA

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

Message 5 of 11
icse
in reply to: nlegareLUZKA

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
Message 6 of 11
nlegareLUZKA
in reply to: icse

It still does not work...
Message 7 of 11
icse
in reply to: nlegareLUZKA

Can you explain the problem a bit more. 

 

Does the macro stop at a certain point?

 

I just tested the renaming part ive added.

Message 8 of 11
nlegareLUZKA
in reply to: icse

the macro does not stop but the problematic toolpath is not renamed.
Message 9 of 11
icse
in reply to: nlegareLUZKA

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}
	}
}

 

 

 

 

Message 10 of 11
nlegareLUZKA
in reply to: icse

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.
Message 11 of 11
icse
in reply to: nlegareLUZKA

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report