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 Help. Looping through the feature set folder.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
barr.jarryd
793 Views, 2 Replies

Macro Help. Looping through the feature set folder.

barr.jarryd
Advocate
Advocate

Hey folks,

 

I'm trying to build a macro that will loop through feature set main folder, activate the feature and call a function based of the diameter of the feature.

 

Note that the feature sets have already been sorted and renamed based upon their respective diameters in a REAL format.

 

I know I'm supposed to use the FOREACH method loop but the syntax is wrong and I can't quite figure out my next step.

 

Here is the skeleton version of what I think I have to do.

 

FOREACH $hole IN FOLDER('featureset') {

//grab name of feature set and convert to REAL

//run a FUNCTION based on the number if it is lower or higher than a set value (IF ELSE Statement)

}

 

Any and all help would be appreciated.

 

Thank you

0 Likes

Macro Help. Looping through the feature set folder.

Hey folks,

 

I'm trying to build a macro that will loop through feature set main folder, activate the feature and call a function based of the diameter of the feature.

 

Note that the feature sets have already been sorted and renamed based upon their respective diameters in a REAL format.

 

I know I'm supposed to use the FOREACH method loop but the syntax is wrong and I can't quite figure out my next step.

 

Here is the skeleton version of what I think I have to do.

 

FOREACH $hole IN FOLDER('featureset') {

//grab name of feature set and convert to REAL

//run a FUNCTION based on the number if it is lower or higher than a set value (IF ELSE Statement)

}

 

Any and all help would be appreciated.

 

Thank you

2 REPLIES 2
Message 2 of 3
cfastNJWK6
in reply to: barr.jarryd

cfastNJWK6
Advisor
Advisor

 

Something like this?

FOREACH $hole IN FOLDER('featureset') {

//grab name of feature set and convert to REAL
REAL $FeatureName = real($hole.Name) //this will fail if the feature name has any non-numeric characters



//run a FUNCTION based on the number if it is lower or higher than a set value (IF ELSE Statement)

IF $FeatureName > setvalue and $FeatureName < otherSetValue {
Call FunctionName
} ELSEIF $FeatureName > otherSetValue and $FeatureName < DifferentSetValue {
Call DifferentFunction
}
}
0 Likes

 

Something like this?

FOREACH $hole IN FOLDER('featureset') {

//grab name of feature set and convert to REAL
REAL $FeatureName = real($hole.Name) //this will fail if the feature name has any non-numeric characters



//run a FUNCTION based on the number if it is lower or higher than a set value (IF ELSE Statement)

IF $FeatureName > setvalue and $FeatureName < otherSetValue {
Call FunctionName
} ELSEIF $FeatureName > otherSetValue and $FeatureName < DifferentSetValue {
Call DifferentFunction
}
}
Message 3 of 3
barr.jarryd
in reply to: cfastNJWK6

barr.jarryd
Advocate
Advocate
Accepted solution

I ended up going a different route. Set it so that the user can select which featuresets they want to calculate off. Similar to the format you gave me, jsut different execution.

 

Here is what I ended up with.

 

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 "Drilling/Drilling.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 ".05"
			EDIT TPPAGE SWToolRapidMv
			EDIT TOOLPATH SAFEAREA CALCULATE_DIMENSIONS
			EDIT TOOLPATH SAFEAREA PLUNGE_SIZE  "0"
			EDIT TPPAGE SWFeedSpeed
			EDIT RPM ${191/$diameter}
		
			IF $diameter >= .75 {
			EDIT FRATE "1.0"
			EDIT PRATE "1.0"

			}	ELSE {

			EDIT FRATE "1.4"
			EDIT PRATE "1.4"

			}	
			EDIT COOLANT ON
			EDIT TPPAGE SWDrilling
			
		STRING $toolpathName = $diameter + "_Drill"
		
		RENAME Toolpath ; $toolpathName
		
		EDIT TOOLPATH ; CALCULATE
	
	} ELSEIF $d > 1.0 {
		STRING $dName2 = "" + $d + ""
		ACTIVATE FEATURESET $dName2
		CALL LargeHoles()
	} ELSEIF $d == 0.9449 {
		STRING $dName3 = "" + $d + ""
		ACTIVATE FEATURESET $dName3
		CALL FcsDrill()
	} ELSEIF $d == 0.8661 {
		STRING $dName4 = "" + $d + ""
		ACTIVATE FEATURESET $dName4
		CALL FcsDrill()
	}
}
0 Likes

I ended up going a different route. Set it so that the user can select which featuresets they want to calculate off. Similar to the format you gave me, jsut different execution.

 

Here is what I ended up with.

 

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 "Drilling/Drilling.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 ".05"
			EDIT TPPAGE SWToolRapidMv
			EDIT TOOLPATH SAFEAREA CALCULATE_DIMENSIONS
			EDIT TOOLPATH SAFEAREA PLUNGE_SIZE  "0"
			EDIT TPPAGE SWFeedSpeed
			EDIT RPM ${191/$diameter}
		
			IF $diameter >= .75 {
			EDIT FRATE "1.0"
			EDIT PRATE "1.0"

			}	ELSE {

			EDIT FRATE "1.4"
			EDIT PRATE "1.4"

			}	
			EDIT COOLANT ON
			EDIT TPPAGE SWDrilling
			
		STRING $toolpathName = $diameter + "_Drill"
		
		RENAME Toolpath ; $toolpathName
		
		EDIT TOOLPATH ; CALCULATE
	
	} ELSEIF $d > 1.0 {
		STRING $dName2 = "" + $d + ""
		ACTIVATE FEATURESET $dName2
		CALL LargeHoles()
	} ELSEIF $d == 0.9449 {
		STRING $dName3 = "" + $d + ""
		ACTIVATE FEATURESET $dName3
		CALL FcsDrill()
	} ELSEIF $d == 0.8661 {
		STRING $dName4 = "" + $d + ""
		ACTIVATE FEATURESET $dName4
		CALL FcsDrill()
	}
}

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

Post to forums  

Autodesk Design & Make Report