Macro for saving boundary to temp folder

Macro for saving boundary to temp folder

Anonymous
Not applicable
1,388 Views
19 Replies
Message 1 of 20

Macro for saving boundary to temp folder

Anonymous
Not applicable
Hi guys,
I would really appreciate if you could help with me the following macro question:
How can i save whats in boundary folder such as supportpins type *pic into an external temp folder with the same type *pic
0 Likes
Accepted solutions (1)
1,389 Views
19 Replies
Replies (19)
Message 2 of 20

rafael.sansao
Advisor
Advisor
STRING $TEMP_FOLDER = "C:\Temp" //Change this
FOREACH $Boun IN FOLDER('BOUNDARY') {
	STRING $FILE_SAVE = $TEMP_FOLDER + "\" + $Boun.Name + ".pic"
	KEEP BOUNDARY $Boun.Name $FILE_SAVE YES
}

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 3 of 20

rafael.sansao
Advisor
Advisor

With some additional checks ...

STRING $TEMP_FOLDER = "C:\Temp" //Change this
FOREACH $Boun IN FOLDER('BOUNDARY') {
	IF $Boun.Computed == true AND segments($Boun) > 0 {
		STRING $FILE_SAVE = $TEMP_FOLDER + "\" + $Boun.Name + ".pic"
		KEEP BOUNDARY $Boun.Name $FILE_SAVE YES
	}
}

 

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

Message 4 of 20

Anonymous
Not applicable

Thank you Rafael. I deeply appreciate it, but when I run the macro Powermill gives me an error saying, "Unsupported Powermill command and Feature: STRING


@rafael.sansao wrote:
STRING $TEMP_FOLDER = "C:\Temp" //Change this
FOREACH $Boun IN FOLDER('BOUNDARY') {
	STRING $FILE_SAVE = $TEMP_FOLDER + "\" + $Boun.Name + ".pic"
	KEEP BOUNDARY $Boun.Name $FILE_SAVE YES
}


$TEMP_FOLDER = "C:\Temp" 

0 Likes
Message 5 of 20

rafael.sansao
Advisor
Advisor

Save the attached macro and run it. If the Powermill returns an error, take a print and send it here.

 

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 6 of 20

Anonymous
Not applicable

I am currently using PowerMill 2010 and this is the error I'm getting below: 

 

macError.JPG

0 Likes
Message 7 of 20

Anonymous
Not applicable

This is the error given by PowerMill. 

 

Capture.JPG

0 Likes
Message 8 of 20

rafael.sansao
Advisor
Advisor

Most macro commands do not work in version 10.
If you want to take advantage of the macros, you'll need to migrate to a newer Powermill version (2016 or later)

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 9 of 20

Anonymous
Not applicable

Oh, okay, I had a feeling it might be due to my version of PowerMill 2010. Thank you again so much for your help. I deeply appreciate it. 

0 Likes
Message 10 of 20

Anonymous
Not applicable

@Anonymous

 

Have you tried removing the "$" from the line:

 

STRING $TEMP_FOLDER = "C:\temp"

 

Generally, when you first declare (create) a STRING VARIABLE....you don't need the $ in front of the name of the variable.

In this case, the variable is called: TEMP_FOLDER

However, anytime after this initial variable declaration, when you need to use or modify the variable's content...you must have the "$" in front of it's name.

Anyway, worth a try...but as @rafael.sansao mentioned...perhaps it's just not possible in Pmill 2010

 

Good luck,

 

Glen

 

 

0 Likes
Message 11 of 20

lloyd.patton
Alumni
Alumni

Try removing the trailing //comment

0 Likes
Message 12 of 20

Anonymous
Not applicable

Yes I tried it without the $ and it gave me the same error. 

0 Likes
Message 13 of 20

Anonymous
Not applicable

Also I removed the //comment and it still gave me the same error. However, this code below works for Supportpin_0_1 boundary but then gives me the same error. I need it to run for all the supportpin boundaries.  How can I run the macro once so it goes thru each of the boundaries and saves it in the temp folder? 

 

EXPLORER SELECT Boundary 'SUPPORTPIN_0_1' NEW

KEEP BOUNDARY 'SUPPORTPIN_0_1' FILESAVE

c:\TEMP\SUPPORTPIN_0_1.PIC

EXPLORER SELECT Boundary 'SUPPORTPIN_0_1' NEW

KEEP BOUNDARY 'SUPPORTPIN_0_1' FILESAVE

c:\TEMP\SUPPORTPIN_0_1.PIC

 

EXPLORER SELECT Boundary 'SUPPORTPIN_0_2' NEW

KEEP BOUNDARY 'SUPPORTPIN_0_2' FILESAVE

c:\TEMP\SUPPORTPIN_0_2.PIC

EXPLORER SELECT Boundary 'SUPPORTPIN_0_2' NEW

KEEP BOUNDARY 'SUPPORTPIN_0_2' FILESAVE

c:\TEMP\SUPPORTPIN_0_2.PIC

 

EXPLORER SELECT Boundary 'SUPPORTPIN_0_3' NEW

KEEP BOUNDARY 'SUPPORTPIN_0_3' FILESAVE

c:\TEMP\SUPPORTPIN_0_3.PIC

EXPLORER SELECT Boundary 'SUPPORTPIN_0_3' NEW

KEEP BOUNDARY 'SUPPORTPIN_0_3' FILESAVE

c:\TEMP\SUPPORTPIN_0_3.PIC

0 Likes
Message 14 of 20

rafael.sansao
Advisor
Advisor

That's not possible. The logic programming language was inserted into the Powermill in the 2012 R2 version.

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 15 of 20

Anonymous
Not applicable

Referring to Powermill 2010 question: I guess I have to sign up with Scribd to access the entire guideline. 

0 Likes
Message 16 of 20

Anonymous
Not applicable

I know there is a way of saving the boundaries in PowerMill 2010 because there are other macros that I run that function perfectly. 

0 Likes
Message 17 of 20

Anonymous
Not applicable

I know this code below works for saving supportpin into the temp folder, but for some reason it doesn't overwrite the old supportpin.pic files. How can I delete the old SUPPORTPIN.PIC files, so the new SUPPORTPIN.PIC files saves into the temp folder.  

 

EXPLORER SELECT Boundary "Boundary\SUPPORTPIN_0_1" NEW

ACTIVATE Boundary "SUPPORTPIN_0_1"
EXPLORER SELECT Boundary "Boundary\SUPPORTPIN_0_1" NEW

KEEP Boundary "SUPPORTPIN_0_1" FILESAVE

"C:\temp\SUPPORTPIN_0_1.PIC" 

 

EXPLORER SELECT Boundary "Boundary\SUPPORTPIN_0_2" NEW

ACTIVATE Boundary "SUPPORTPIN_0_2"
EXPLORER SELECT Boundary "Boundary\SUPPORTPIN_0_2" NEW

KEEP Boundary "SUPPORTPIN_0_2" FILESAVE

"C:\temp\SUPPORTPIN_0_2.PIC"                    //and so on for the rest of supportpin 3, 4, 5 ,6...

0 Likes
Message 18 of 20

urizenYHS3W
Advocate
Advocate
Accepted solution

You don't need the EXPLORER SELECT commands, you don't need the FILESAVE, and you don't need to activate the boundary each time. You specify YES to the potential OVERWRITE query.

 

KEEP Boundary "SUPPORTPIN_0_1" "C:\temp\SUPPORTPIN_0_1.PIC" YES
KEEP Boundary "SUPPORTPIN_0_2" "C:\temp\SUPPORTPIN_0_2.PIC"  YES

 You can delete files and directories with

 

DELETE FILE <filepath>
DELETE DIRECTORY <dirpath>

 

0 Likes
Message 19 of 20

Anonymous
Not applicable

Thank you so much. It worked. 

0 Likes
Message 20 of 20

Anonymous
Not applicable

Hi guys,

I wanted to know is there a way I can delete curves within a boundary and then save that boundary to an external temp folder using PowerMill? 

0 Likes