Macro to open location of .NC file

Macro to open location of .NC file

armin.bosnjakN3JE3
Advocate Advocate
2,373 Views
8 Replies
Message 1 of 9

Macro to open location of .NC file

armin.bosnjakN3JE3
Advocate
Advocate

Hi guys,

 

is it possible to integrate opening of windows explorer window using location from NC Settings.

We post NC programs to different locations, and we have to look for folder manually, I was thinking about macro that would automatically open windows explorer and navigate to that folder where NC is posted.

 

I am talking about Output file location.

 

 

0 Likes
Accepted solutions (2)
2,374 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Accepted solution

Hi,

 

I did some testing with the "ole fileaction" macro command but I didn't get it running to open the explorer to a specific path which should look like "c:\windows\EXPLORER.EXE /n, /e, D:\Temp"

So I have written a macro that creates a batch file to open the explorer using the location where the NC file is writen.

 

STRING $path = entity('ncprogram','').FileName
$path = replace($path, "/", "\")
$path = "c:\windows\EXPLORER.EXE /n, /e, " + dirname($path)
	
FILE OPEN "temp.bat" FOR WRITE AS output
FILE WRITE $path TO output
FILE CLOSE output	
ole fileaction 'open' 'temp.bat'

 

I hope this is what you are looking for.

Message 3 of 9

armin.bosnjakN3JE3
Advocate
Advocate

Works amazing, this is something that I was looking for. Thank you very much.

 

I had one macro with "ole fileaction" but didn't make it and coudn't really understand. But your solution is something that I was up to.

 

 

Message 4 of 9

karan30782
Advocate
Advocate

Hi ! @Anonymous 

 

I tried your macro to open the folder where the toolpaths has been posted earlier.

Actually I have posted the program to a network location and now I want to open that folder again for review

And I used your macro , But it closes with an error pop up.

kindly Suggest if I'm wrong somewhere.

 

1.JPG2.JPG

 

 

I used this macro :- 

 

//==================================//

 

STRING $path = entity('ncprogram','').FileName
$path = replace($path, "/", "\")
$path = "c:\windows\EXPLORER.EXE /n, /e, " + dirname($path)

FILE OPEN "temp.bat" FOR WRITE AS output
FILE WRITE $path TO output
FILE CLOSE output
ole fileaction 'open' 'temp.bat'

 

//==========================================//

 

 

Thank you !

 

 

0 Likes
Message 5 of 9

armin.bosnjakN3JE3
Advocate
Advocate

Karan, can you activate one NCProgram, so it is bold. Like this:

 

arminbosnjakN3JE3_0-1635834524029.png

 

Then try and run macro, I think it needs to be activated so it knows which path it is looking for.

0 Likes
Message 6 of 9

karan30782
Advocate
Advocate

hi ! @armin.bosnjakN3JE3 

 

I tried once again, but no luck

 

When first time error poped up, I manually created the temp.bat file with no contains.

Then again when I ran the macro same error poped up.

3.JPG

 

Have a great day !

0 Likes
Message 7 of 9

armin.bosnjakN3JE3
Advocate
Advocate

Interesting, now I have the same error just like you 😁

 

EDIT: I just deleted temp file and rerun macro, and now it is working.

0 Likes
Message 8 of 9

huseyin_sahin
Enthusiast
Enthusiast

Hi,

Could it be because of the local characters or symbols you used in the folder name.

0 Likes
Message 9 of 9

rui_rita
Advocate
Advocate
Accepted solution

hi all,

here is the code for open the folder for the selected nc program

 

 

STRING $ncprog_folder = ""
STRING $msg = ""

ENTITY LIST $Selected = explorer_selected_entities()
if not size($Selected)> 0 {
$msg = "No entity selecetd!" + CRLF + "Please select NCProgram!"
MESSAGE ERROR $msg
} else {
IF $Selected[0].RootType != "ncprogram" {
$msg = "The selected entities are not  NCPrograms!" + CRLF + "Please select NCProgram!"
MESSAGE ERROR $msg
} else {
STRING LIST tkfolder = tokens($Selected[0].filename,"{")
$ncprog_folder = tkfolder[0]
OLE FILEACTION "open" $ncprog_folder
}
}



Os melhores cumprimentos | Best regards
Rui Rita
________________________________
NEWCAM, Lda.