macro help

macro help

kl1445
Enthusiast Enthusiast
2,028 Views
17 Replies
Message 1 of 18

macro help

kl1445
Enthusiast
Enthusiast

hi all

I have two Macros, one is D4 and the other is D6. I want to use Macro to determine the model height to execute D4 or D6, but I don't know how to write it. Can anyone help me? Thank you

22.PNG58.PNG

0 Likes
Accepted solutions (2)
2,029 Views
17 Replies
Replies (17)
Message 2 of 18

icse
Advisor
Advisor

you could do somehting like this:

 

real $sz = limits(folder('Model')[0])[5] - limits(folder('Model')[0])[4]

if $sz >= 30 {
	macro 'c:\pathtoyourmacro\D6-0Angle-RF.mac'
} else {
	macro 'c:\pathtoyourmacro\D4-0Angle-RF.mac'
}
0 Likes
Message 3 of 18

kl1445
Enthusiast
Enthusiast

hi icse

I think I did something wrong? Because when executing the following macro, POWERMILL has no action but only counts Z. My powermill version is 2014.

589.PNG

 

0 Likes
Message 4 of 18

icse
Advisor
Advisor

it looks like your formatation is off.

 

Does any error shows in command line?

 

0 Likes
Message 5 of 18

kl1445
Enthusiast
Enthusiast

Unfortunately, PowerMill did not show any errors, so I could not figure out what the problem was.

0 Likes
Message 6 of 18

kl1445
Enthusiast
Enthusiast

I found the error but I don't know if it's the problem

 

"No { follows expression"

0 Likes
Message 7 of 18

icse
Advisor
Advisor
Accepted solution

Your format is off, it looks like you have everything in one line. This does not work.

 

you need to make the inside of your file looks like this:

 

real $sz = limits(folder('Model')[0])[5] - limits(folder('Model')[0])[4]

if $sz >= 30 {
	macro 'c:\pathtoyourmacro\D6-0Angle-RF.mac'
} else {
	macro 'c:\pathtoyourmacro\D4-0Angle-RF.mac'
}

 

NOT like this:

real $sz = limits(folder('Model')[0])[5] - limits(folder('Model')[0])[4]

if $sz >= 30 {macro 'c:\pathtoyourmacro\D6-0Angle-RF.mac'} 
else {macro 'c:\pathtoyourmacro\D4-0Angle-RF.mac'}

 

Message 8 of 18

kl1445
Enthusiast
Enthusiast

You are right. After I re-edited it, powermill can be executed. Thank you very much.

0 Likes
Message 9 of 18

kl1445
Enthusiast
Enthusiast

hi icse

I would like to ask you another question. If you want to automatically execute D10-10-0-angle or D10-10-1-angle after determining that the angle is 0 or above 0, how do you edit the macro?

 

7777.PNG

0 Likes
Message 10 of 18

icse
Advisor
Advisor

This is much more komplex...

0 Likes
Message 11 of 18

kl1445
Enthusiast
Enthusiast

Got it, thanks for your reply, have a nice day

0 Likes
Message 12 of 18

kl1445
Enthusiast
Enthusiast

hi icse

I tried to change the macro, but encountered trouble. Now I want to automatically determine the three dimensions of Z <=28, >=48, >=28.01 or <=47.99. However, when executing this macro, the macro executes the two macros D6R0.2 and D8R0.5, which gives me a headache.How do you think such a macro should be edited? Can you help me?

 

 
real $sz = limits(folder('Model')[0])[5] - limits(folder('Model')[0])[4]
 
if $sz <= 28 {
macro 'C:\dcam\pmill4\D6R0.2-poin.mac'
}      
if $sz >= 45 {
macro 'C:\dcam\pmill4\D10R0.5-poin.mac'
       
} else {
macro 'C:\dcam\pmill4\D8R0.5-poin.mac'
}

 

0 Likes
Message 13 of 18

icse
Advisor
Advisor
Accepted solution
real $sz = limits(folder('Model')[0])[5] - limits(folder('Model')[0])[4]

if $sz <= 28 {
	macro 'C:\dcam\pmill4\D6R0.2-poin.mac'
} elseif $sz >= 45 {
	macro 'C:\dcam\pmill4\D10R0.5-poin.mac'
} else {
	macro 'C:\dcam\pmill4\D8R0.5-poin.mac'
}
Message 14 of 18

kl1445
Enthusiast
Enthusiast

Great, it's no problem now, thank you very much

0 Likes
Message 15 of 18

kl1445
Enthusiast
Enthusiast

hi icse

Is it possible to use the surface color to determine which macro to execute? For example, in 3D, if there is red, execute macro A, if there is yellow, execute macro B, if there is blue, execute macro C, and if there is both yellow and red, execute macro D?

 

red.PNGye.PNGbu.PNGry.PNG

 

 

0 Likes
Message 16 of 18

kl1445
Enthusiast
Enthusiast
This is the macro I found, but it is used in the hole. I tried to change it, but failed because my English is not good.




FORM RIBBON BACKSTAGE CLOSE RESET ALL VIEW MODEL ; SHADE RAINBOW EDIT MODEL ALL DESELECT ALL EDIT SELECTION MODEL CLEAR EDIT SELECTION MODEL APPLY EDIT SELECTION MODEL FILTER "255,255,0" INT $OP1_HOLES = 0 FOREACH m in folder('model') { $OP1_HOLES = $OP1_HOLES + number_selected(m.Components) } IF $OP1_HOLES > 0 { EDIT SELECTION SMART NO FORM MODELSELECT EDIT SELECTION MODEL DELETE EDIT SELECTION MODEL FILTER " 255,255,0" EDIT SELECTION MODEL APPLY FORM CANCEL MODELSELECT EDIT FEATURECREATE TYPE HOLE EDIT FEATURECREATE CIRCULAR ON EDIT FEATURECREATE FILTER HOLES EDIT FEATURECREATE TOPDEFINE ABSOLUTE EDIT FEATURECREATE BOTTOMDEFINE ABSOLUTE FORM CANCEL FEATURE FORM CREATEHOLE EDIT FEATURECREATE HOLES FIXED ON EDIT FEATURECREATE HOLES DIRECTION DOWN EDIT FEATURECREATE CREATEHOLES FORM CANCEL CREATEHOLE EDIT MODEL ALL DESELECT ALL RENAME Featureset ; "OP1_HOLES" } IF $OP1_HOLES == 0 { MACRO ABORT } REAL $DIA = 0 REAL $DEPTH = 0 // Print out the diameter of each hole FOREACH f in components(entity('featureset','OP1_HOLES')) { IF f.Type == "hole" { PRINT = f.name + " has a diameter of " + f.Diameter $DIA = ROUND(f.diameter,4) $DEPTH = ROUND(f.depth,4) //COUNTERBORE SECTION IF $DIA LE 1.001 AND $DIA GE .999 AND $DEPTH <= .751 { FOREACH ent IN folder('setup') { FOREACH TP IN components(ent) { IF $tp.name == '750_DRILL_1' { /// need some code to skip over this section and contiune on } } } MACRO"C:\(..path..)\1_000x750_cbore.mac" } IF $DIA LE .876 AND $DIA GE .874 AND $DEPTH <= .626 { FOREACH ent IN folder('setup') { FOREACH TP IN components(ent) { IF $tp.name == '625_DRILL_1' { /// need some code to skip over this section and contiune on } } } MACRO"C:\(..path..)\875x625_cbore.mac" } //BLIND TAP SECTION// IF $DIA LE .657 AND $DIA GE .655 { FOREACH ent IN folder('setup') { FOREACH TP IN components(ent) { IF $tp.name == '656_TAP_DRILL_1' { /// need some code to skip over this section and contiune on } } } MACRO"C:\(..path..)\750-10.mac" } IF $DIA LE .532 AND $DIA GE .530 { FOREACH ent IN folder('setup') { FOREACH TP IN components(ent) { IF $tp.name == '546_TAP_DRILL_1' { /// need some code to skip over this section and contiune on } } } MACRO"C:\(..path..)\625-11.mac" } } }
0 Likes
Message 17 of 18

CxyAce丶
Contributor
Contributor

Is this only applicable to one?

0 Likes
Message 18 of 18

kl1445
Enthusiast
Enthusiast

hi CxyAce

This is similar to a macro, but it does more than just determine the color.

0 Likes