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
Solved! Go to Solution.
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
Solved! Go to Solution.
Solved by barr.jarryd. Go to Solution.
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
}
}
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
}
}
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()
}
}
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.