Need help altering my macro to create a tool from database

Need help altering my macro to create a tool from database

E-Singer89
Contributor Contributor
601 Views
4 Replies
Message 1 of 5

Need help altering my macro to create a tool from database

E-Singer89
Contributor
Contributor

So we have a macro that we run for drilling holes in plates. Currently we use one macro to separate the featureset into multiple featuresets by size then a second macro to drill those featuresets. The macro currently creates a new tool based on the featureset size. Is there an easy way to change this so that it first checks the project to make sure the tool doesnt already exist; and then if it doesnt goes and grabs the correct drill from the database to use in the drilling program?

 

current macro looks like this

STRING msg6 = "Please highlight all numbered feature sets." + CRLF + "Then hit RESUME."
MACRO PAUSE $msg6

FOREACH $f IN explorer_selected_entities() {
	REAL d = $f.Name
	IF $d <= 1.0 {
		STRING $dName = "" + $d + ""
		ACTIVATE FEATURESET $dName
			REAL $diameter = $d
			IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "deep_drill.ptf"
				EDIT TPPAGE TOOL
				CREATE TOOL ; DRILL
				EDIT TOOL ; DIAMETER $diameter
				EDIT TOOL ; NUMBER COMMANDFROMUI 1
				STRING newTool = $diameter + "_Drill"
				RENAME Tool ; $newTool
			EDIT TPPAGE SWDrilling
			EDIT DRILL TYPE DEEP_DRILL
			EDIT DRILL DEPTH HOLE
			EDIT PAR 'AxialDepthOfCut.UserDefined' '1' EDIT DRILL PECK_DEPTH "0.05"
			EDIT TPPAGE SWToolRapidMv
			EDIT TOOLPATH SAFEAREA CALCULATE_DIMENSIONS
			EDIT TOOLPATH SAFEAREA PLUNGE_SIZE  "0"
			EDIT TPPAGE SWFeedSpeed
			EDIT FEEDRATE CUTTING_SPEED "60"
		
			IF $diameter >= .75 {
			EDIT FRATE "2.0"
			EDIT PRATE "2.0"

			}	ELSE {

			EDIT FRATE "3.0"
			EDIT PRATE "3.0"

			}	
			EDIT COOLANT ON
			EDIT TPPAGE SWDrilling

 

0 Likes
Accepted solutions (2)
602 Views
4 Replies
Replies (4)
Message 2 of 5

icse
Collaborator
Collaborator
Accepted solution

try this:

STRING msg6 = "Please highlight all numbered feature sets." + CRLF + "Then hit RESUME."
MACRO PAUSE $msg6

FOREACH $f IN explorer_selected_entities() {
	REAL d = $f.Name
	IF $d <= 1.0 {
		STRING $dName = "" + $d + ""
		ACTIVATE FEATURESET $dName
			REAL $diameter = $d
			IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "deep_drill.ptf"


//////////////////////////////////////////////
//get a list of all drills with given diameter
entity list $tools = filter(folder('tool'),'this.Type == "drill" and this.Diameter == "' + $diameter + '"') 


//if list contains any drill with given diameter Activate that tool
if size($tools) > 0 {
	activate tool ${tools[0].Name}
} else {
	
	//check if theres a drill witth given diameter in the tool database
	FORM TOOLDBSEARCH
	TOOLDB QUERY SET TOOL_TYPE DRILL
	TOOLDB QUERY SET MIN_DIAMETER ${diameter}
	TOOLDB QUERY SET MAX_DIAMETER ${diameter}
	TOOLDB QUERY PRESET
	int $num = list_num_rows('ToolDBToolSearch.TDBResultsList')
	
	//if so activate that tool, if not create a tool...
	if $num > 0 {
		TOOLDB RESULTS_LIST SELECT 0 NEW
		TOOLDB RESULTS_LIST CREATE SELECTED
		TOOLDBSEARCH ACCEPT
	} else {
		TOOLDBSEARCH ACCEPT
		//Your Tool Creation Code goes here
		CREATE TOOL ; DRILL
		EDIT TOOL ; DIAMETER $diameter
		EDIT TOOL ; NUMBER COMMANDFROMUI 1
		STRING newTool = $diameter + "_Drill"
		RENAME Tool ; $newTool
	}

}
//////////////////////////////////////////////////////



			EDIT TPPAGE SWDrilling
			EDIT DRILL TYPE DEEP_DRILL
			EDIT DRILL DEPTH HOLE
			EDIT PAR 'AxialDepthOfCut.UserDefined' '1' EDIT DRILL PECK_DEPTH "0.05"
			EDIT TPPAGE SWToolRapidMv
			EDIT TOOLPATH SAFEAREA CALCULATE_DIMENSIONS
			EDIT TOOLPATH SAFEAREA PLUNGE_SIZE  "0"
			EDIT TPPAGE SWFeedSpeed
			EDIT FEEDRATE CUTTING_SPEED "60"
		
			IF $diameter >= .75 {
			EDIT FRATE "2.0"
			EDIT PRATE "2.0"

			}	ELSE {

			EDIT FRATE "3.0"
			EDIT PRATE "3.0"

			}	
			EDIT COOLANT ON
			EDIT TPPAGE SWDrilling

0 Likes
Message 3 of 5

E-Singer89
Contributor
Contributor

So that worked as intended mostly, thank you! I made sure it didn't try to make new tools once tools were already in the program as well. However, the only odd thing it does that I can't seem to find why is that it's renaming the very first tool it brings in with a name of "1"

Capture.JPG

 

I did have one other question. I tried searching the forum but only found a solution for when using drilling methods and not standard drilling toolpaths; but is there a way to make it so peck depth is set to .1 of the tool diameter instead of the .05 static peck in the macro? I am new to using macros and the guy that used to write them where i work is no longer with us, so im trying to learn as much as i can. 

0 Likes
Message 4 of 5

icse
Collaborator
Collaborator
Accepted solution

1st point, maybe the tool is contained in your template:

IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "deep_drill.ptf"

 

you can add this line to edit the peck depth:

EDIT PAR 'AxialDepthOfCut.UserDefined' '1' EDIT DRILL PECK_DEPTH ${Tool.Diameter / 10}

 

0 Likes
Message 5 of 5

E-Singer89
Contributor
Contributor

Ahhhh yes. My template did have a tool built into it. I thought I had saved it without, thank you. Also, the peck depth works, thank you!

0 Likes