[Macro] Getting the SetupSheet's Project Summary's filename into a variable

[Macro] Getting the SetupSheet's Project Summary's filename into a variable

Anonymous
Not applicable
1,082 Views
4 Replies
Message 1 of 5

[Macro] Getting the SetupSheet's Project Summary's filename into a variable

Anonymous
Not applicable

Hello all,

 

I'm trying to make a macro in PowerMill that will make the printing of the report file much easier.

 

A little information to keep you up to speed: For my work I have several Project Summary files for several different details. For easier understanding imagine 5 different details each with a different Project Summary report file. They all need a SetupSheets Snapshot image saved in a specific location(the location is the same for all of the report files). The last thing is printing the report.

 

So, I found a code that makes a Snapshot image and saves it then in the desired location. Heres the code for that:

 

KEEP SNAPSHOT PROJECT CURRENT
TEXTINFO ACCEPT
KEEP BITMAP FILESAVE "\\192.168........\MARKIRANE\ProjectSnapshot.png"

In another macro(this one is used at the start of a project) I change the name of the Project Summary file(and many other thins) to a desired one that will work on this specific detail/model. But in our work there are sometimes situations where we have to close the current project, check something and then continue the first work. I think that we all know that If we clear all data and refresh all forms in the Power Mill we will lose the name of the Project Summary file.

 

So now the question:

 

Is there a way to get the SetupSheet's Project Summary's filename and assign it to a variable?

 

If I can do that I can check if there is a change in the name and if needed I will change it again with a simple pick form a list(like a said I change this Project Summary name in a separate macro).

 

After that all that is needed from me is to start the printing of the report:

 

PRINT SETUPSHEETS NCPROGRAM ALL

Every help will be appreciated.

 

With best regards.

Miroslav Penev

0 Likes
1,083 Views
4 Replies
Replies (4)
Message 2 of 5

bradley.hollandsworth
Alumni
Alumni

I do not think the Setup Sheet names are in a parameter to capture. You could store the Template name in a project variable and look at that the next time the macro is run. You might need one project variable per style of Template and then have to sort the one to change.

 

 

Another way of looking at this is just changing the path for the setup sheets.

All the template names could use the default names as each style of sheet would be in its own folder. 

 

Then the macro needs to delete any Setupsheet paths in PowerMILL, and place the path you want to use in the control. You could store the path selected with the macro in a project variable and check it to find the current path when the macro is run again.

 

 

// Delete all the SETUP SHEET DIRECTORY paths used
	PATHSELECTOR PATHLISTS LISTCHANGE SETUPSHEETSTEMPLTS
	PATHSELECTOR PATHLISTS SELECT  "H:\Sheet1\"
	PATHSELECTOR PATHLISTS DEL	
	PATHSELECTOR PATHLISTS SELECT  "H:\Sheet2\"
	PATHSELECTOR PATHLISTS DEL


	SWITCH $PickMenu {
	   CASE 1
	      PATHSELECTOR PATHLISTS ADDTOP PROJSELECTOR
	      "H:\Sheet1\"
	      BREAK
	   CASE 2
	      PATHSELECTOR PATHLISTS ADDTOP PROJSELECTOR
	      "H:\Sheet2\"
	      BREAK
	}

 

Not sure if this will help you but this is what I have used in the past to create a user selection for multiple types of Setupsheets.

 

 

Brad Hollandsworth



Brad Hollandsworth

Senior Applications Engineer

0 Likes
Message 3 of 5

Anonymous
Not applicable

Well I didn't find any way to get the name of the SetupSheet file too so I think that you might be right - it is impossible.

 

I never thought of using something like a global variable that I can always check in a future time.

 

What I think now is if I have a global variable I can change it to the name of the setupsheet used for that specific project and after that I can check this variable and if it is not in it's default value than everything will be ok.

 

Ok. Thanks for this Idea! But there's a problem here ... 🙂 ... how can I make or use a global variable or some other variable that will stay active after the execution of the macro ? Never done this before 🙂

 

Thanks again.

Miroslav Penev

0 Likes
Message 4 of 5

kukelyk
Advisor
Advisor

Try this:

STRING setupsheet_dir = replace(project_pathname(0),"/","\") + "\Setup_Sheets"
//or directory something like this
STRING $filespec = ".htm"
STRING LIST $htm_files = list_files( "files", $setupsheet_dir, $filespec)
$filespec = ".html"
STRING LIST $html_files = list_files( "files", $setupsheet_dir, $filespec)
$htm_files = set_union($htm_files, $html_files)
STRING LIST filename_only = {}
FOREACH f IN $htm_files {
	INT k = add_last($filename_only, basename(replace($f, "/","\")))
}

STRING setupsheet_to_open = ''
IF size($htm_files) == 0 {
	STRING msg = "There are no files in the " + CRLF + $setupsheet_dir + CRLF + "directory"
	MESSAGE INFO $msg
	MACRO ABORT
} ELSEIF size($htm_files) == 1 {
	$setupsheet_to_open = $htm_files[0]
} ELSEIF size($htm_files) > 1 {
	STRING msg = "Select one of these setupsheets:"
	INT C = 0 
	$C = INPUT CHOICE $filename_only $msg
	$setupsheet_to_open = $htm_files[$C]
}
OLE FILEACTION 'open' $setupsheet_to_open

We do not use setup sheets, so I did not test it..

Message 5 of 5

Ye。xg
Advocate
Advocate

I want to quickly locate the location of PowerMill files through macros?
I should do this.
Thank you!