Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Filename and User name in header of Posted file?


Recommended Posts

1) How can I have the file name of where the posted file was generated be automatically added to the header of posted files?

Our current post outputs the File Decsriptor field. Problem it only saves the opening files name, editable yes, but is over written when I merge files.

 

2) How can the current programmers log-in name be added to the header of Posted Files? (Windows XP Pro Network)

 

New to Mastercam but not to programming. Had these features in our last Cam software.

 

Also new to forums....any suggestions apreciated.

 

Thanks

Link to comment
Share on other sites

1) In the pmachineinfo$ post block, you can capture the name of the post like so:

 

pmachineinfo$

if prmcode$ = 17008, sstring_for_the_name_of_the_post = ucase(sparameter$)

 

 

And then you can display the post name where you want.

 

2) You can always ask a question like so:

 

#define a question and capture it in a variable

fq 8 sstring_for_user_name "Hey man, who's the user?"

 

 

Then, make the post ask the question during the posting process. You can ask the question somewhere in the beginning of pheader$

 

pheader$

 

q8 # ask question number 8

 

Now you will be able to display the username in the header.

Link to comment
Share on other sites

Patrick,

 

I could see that your "Filename" question could be misunderstood.

 

Filename of the (post) PST file?

or

Filename of the (posted) NC file?

 

I chose the latter. ;)

 

Very simple as the path & name & extension are all pre-defined PST variables

You just need to format them as needed and then output 'em.

 

Here is an example of dumping out the full path/name of the NC file into the header of the NC file

 

#Declare a string variable to hold the "NC filename"
#Make sure the this line starts in FIRST column! (for a "variable declaration") 
sncfilename : "-unknown-"

pheader$         #Call before start of file                         
     "%", e$
     sav_spc = spaces$
     spaces$ = 0

     # Set our variable to all the components of the 'NC' output path
     sncfilename = spathnc$ + snamenc$ + sextnc$    # path + name + extension
     sncfilename = ucase(sncfilename)  # If you need to be be all UPPERCASE              
     "(", "NC FILE - ", sncfilename, , ")", e$  # Output it!

 

Or look at how it is done in the std. MPFAN.PST (Look at the pheader$ postblock).

Which gives you this ->

 

(DATE=DD-MM-YY - 04-03-11 TIME=HH:MM - 09:07)

(MCX FILE - C:\TEMP\POSTOPS.MCX-5)

(NC FILE - C:\USERS\RJM\DOCUMENTS\MY MCAMX5\MILL\NC\T1.NC)

(MATERIAL - ALUMINUM MM - 2024)

( T211 | 2. FLAT ENDMILL | H211 )

Link to comment
Share on other sites
How can the current programmers log-in name be added to the header of Posted Files? (Windows XP Pro Network)

There is no built-in method in the PST language, but that doesn't mean that it can't be done!

 

A PST can run a VB Script or DLL ("DLL" = A Mastercam AddOn -> CHook or NETHook)

To obtain the logged-in user name the a VBScript is simple,

it only gets a bit more involved because you need to get that data over into the PST so that you can output it in the NC file.

*You would need to have the VB Script write the UserName out to a file and then the PST would open that file and read in the name. Not really that difficult, but you need to be sure to setup both your VB Script and PST to "know" the full path\name of where this "external" file used to pass the data lives on you system.

 

'////////////////////////////////////////////////////////////////////////////////
'//
'//        Author:   CNC Software
'//          Date:   04/03/2011
'//     File Name:   GetUserName.VBS
'//   Description:   Mastercam VB Script
'//      Comments:  Retrieve the "user name" of the current user on the nethwork. 
'//
'////////////////////////////////////////////////////////////////////////////////

' -- Start Script
Call Main()

' ////////////////////
' Sub Declaration
' ////////////////////
Sub Main()
   Dim objNetwork
   Set objNetwork = CreateObject("WScript.Network")
   ShowString (objNetwork.UserName) ' DEBUG - Show what we've got!	
   ' To be useful we need to write the UserName data out to a file and
   ' have have the calling application read that file to retrieve the data.
End Sub

 

*** Depending on what version of Mastercam you're running (at least X5),

there is new functionality for passing data back & forth between a PST and a Mastercam AddOn.

This way we could have the PST call a CHook (or NETHook) AddoOn and get the data back into the PST without the need of writing to and reading from an "external" file.

Link to comment
Share on other sites
  • 1 year later...

I put together a demo CHook & NETHook that shows you how you can use this new (X5) 'Return Value to PST' functionality.

 

Ive been trying this functionality with a NetHook with success. But I have a question: If the user was to post multiple G-Code files,

would each instance of the called .dll be released from memory? (assuming this dll is not referenced already in an .ft file ?)

Link to comment
Share on other sites
...would each instance of the called .dll be released from memory?

It really should not make any difference to you, as you'll not get multiple instances of the same NETHook.

 

Since you are talking NETHook, it's a bit different than with a "native" C++ (CHook) DLL.

The NETHook Assembly is "loaded" and then queried (using Reflection) to locate the existance of the std. NETHook methods.

"Run" which in the only required one.

And if any of these the optional ones exist ->

"Version" - > Called first, so the you can verify if your NETHook is running in the proper Version of X.

"Init" -> Called when the assembly is "loaded". (Really only useful if your NETHook is being "loaded" using a FT file)

-Run-

"Notify" -> Called with Mastercam event IDs, as they happen.

"Close" -> Called when your NETHook "ends".

Link to comment
Share on other sites
  • 7 months later...

I found this searching for something similar.

 

Its been quite a few a years since I messed with the post.

 

where would I put the fq8 for example?

 

I need to have

programmer: (could be hard coded in which i have now)

date : (open for operator input)

customer:

machine:

 

I tried to put that as a group comment but it repeats the customer at every op.

 

Also... Nblocks at only operation.

 

Any help would be appreciated.

 

Thanks

Link to comment
Share on other sites

I found it on another topic.

 

Thanks.

 

I have to find the mpmaster.... right now I butchered a haas 4x post (new name of course)

 

I like the mpmaster.

 

We have sooo many different oddball machines here and each seems to want something different on the code side.

 

we are trying to standardize our headers easiest enough to start with.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...