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:

How to call a dll in PST file


Recommended Posts

I have a dll. It is for analysing the NCI file.

 

I just want to call the dll after generating the NCI file.

 

I found a clue in another thread, there are some codes as follow:

 

stringDLL "c:mcamx2-mr2chooksmyCHook.dll" # user string var in PSTstringPARAMS ' "first" "second" "third" ' # user string var in PSTppost$ # A postblock

real_result = dll(stringDLL, stringPARAMS)

 

I created a PST file contains that codes. But it doesn't work.

 

Anybody can give me a example for this.

 

Thanks!

Link to comment
Share on other sites

Sigma,

 

The code that Roger listed was for manipulating the NC file after posting, not the NCI file.

 

To post examples of the code you are trying to use, you should use the "full reply form" and then use the "Code" feature to format your code properly like so:

 

code:

 

 

ppost$

real_result = dll(stringDLL, stringPARAMS)

 


When you say "I created a PST file that contains the codes", did you add that post block to an existing post processor? For Roger's example, you would need to add it to an existing post.

 

Are you trying to launch this dll as part of the posting process? What is your function library supposed to do?

 

In Roger's example, the ppost$ post block is called after the NCI file has been closed and the NC file has already been written. You could potentially launch your dll after these events if you set the switch to "save" the NCI file, but I doubt you want to analyze the NCI after it has already been used to generate the NC file...

 

To be able to access the information in the NCI file, you will need to create, or add code to, a post block that will be executed once the NCI file has been read, but before the post starts building the NC code.

 

This is assuming that your dll file is created to analyze and manipulate the NCI data in some way, before you generate your NC file.

 

I guess we still need to know more about what it is you are trying to accomplish before we can give you the proper advice.

 

For example, you would not want to try and launch your dll from any of the pre-process post blocks, because the NCI file has not been opened yet.

 

Roger or someone else may have a better location in mind, but I would use the pparameter$ post block as the location to call my dll from.

 

What information are you trying to access from the NCI file? The MP Post language has functions available to scan and extract parameter information from both the NCI and OPS files...

 

Again, if you tell us more of what you are trying to accomplish, we can give you more help.

Link to comment
Share on other sites

Thank you for your reply.

 

Sorry if I didn't explain the problem more clearly.

 

Firstly, I just want to create a CHook DLL to analyze NCI and generate NC code. In V9 we have some numbered question type definitions in the PST file we can use to tell MP to use a different DLL for posting. I use this question:

 

code:

91. Name of executable CHook?

But now, this numbered question functions are not supported from Mastercam X.

 

In another word, I am looking for the alternative methods in X2 to do the same job with the numbered questions in the earlier post.

Link to comment
Share on other sites

Interesting...

 

I think you will need to use the dll function like Roger described, but I'm not sure where you need to insert this call.

 

I know you can also set the option inside the Mastercam Configuration menu to use a different dll file for your Post Processor, but this might cause some problems.

 

Can I ask why you would want to use your own Post dll file rather than the MP.dll that Mastercam uses by default? The MP language is really powerful and highly customizable.

Link to comment
Share on other sites

When I made a post chook dll, I just added "PostMain" function..

code:

 

extern "C" __declspec(dllexport) int m_main (int not_used)

{

AFX_MANAGE_STATE(AfxGetStaticModuleState());

 

//process binary nci

//operation_manager (&op, OPMGR_GET_FIRST_LIST, &eptr, &succf);

//nci_manager (op.op_idn, NCIMGR_RD_SOS, &n, &fpos, &succf);

//nci_manager (0, NCIMGR_RD, &n, &fpos, &succf);

 

 

return MC_NOERROR;

}

extern "C" __declspec(dllexport) int PostMain (int prm)

{

 

return m_main(prm);

 

}

 


(it processes NCI with other script languages.)

Link to comment
Share on other sites

Hi,

 

if you want to run your post dll by pressing the post (G1) button.

 

You need "PostMain" function exported in your dll, put it in c:mcamxapps,

and set post excutable dll in the current control definition.

 

sigmawave,

if you just need a nci data as text, postOps function will do it.

http://www.emastercam.com/cgi-bin/ultimate...c;f=13;t=000198

 

or if you process a binary nci data, use nci_manager function.

Link to comment
Share on other sites

That was my thought exactly John. The MP language is really powerful for doing all sorts of functions, especially since there are so many tools that are built right in for manipulating the NCI and the Parameter data from the Ops file. I heard that you were the original developer of the MP language back when Mark and Brian were first creating Mastercam (Megan?)...

Link to comment
Share on other sites

Hi John,

 

That statement is really interesting to me. Can you give me any examples of the other kind of work you do with it? That is really intriguing to me. Are you feeding it another type of data file to read in? Are you launching a project in Mastercam and using a Post to run a routine?

 

The more I learn about computer programming, the more I realize how inadequate my higher math skills are. I did great at Algebra, Geometry, and Trigonometry, but I never went on to Calculus. I'll spend some more time reading the advanced sections of the V9 Post Guide and see if I can decipher more of the functionality in the MP language. Thanks for your time.

 

Best regards,

Link to comment
Share on other sites

Colin, there probably ought to be a math section on the forum. This thread is an odd place to discuss math. I'll e-mail you this reply in case you don't get back here.

There are several examples on the FTP site under MISC....(name is too long). One is CAM.ZIP. Another is VLIB.ZIP. VLIB is a reference file for the vector math functions in MP.

Sometimes I use a linear toolpath string to input a bunch of points, and start the math manipulations in PLIN. Another method is to input data in a buffer file (-.TX1,-.TX2, etc.).

A third way is to generate all data inside the -.PST file, with heavy usage of the buffer files as scratch files or arrays. With the last two methods, you have to start with PQ and a dummy -.NCI file.

Link to comment
Share on other sites

Hi John,

 

Thanks for the response. You've got mail.

 

I'll download the CAM and VLIB files and start looking them over.

 

I really like the idea of a Math section as well. I think it would open a lot of peoples eyes as to how powerful Mastercam and the MP language are. Plus, it would be a ton of fun!

Link to comment
Share on other sites
  • 6 years later...

Is there anywhere I can download this? 

 

This is such a powerful tool of which I"m looking for.

 

 

Please tell me where to download it if I can.

 

Thank you.

 

Read this again and on the FTP it is called Text_&_post_files_&_misc then look for the file.

 

Colin, there probably ought to be a math section on the forum. This thread is an odd place to discuss math. I'll e-mail you this reply in case you don't get back here.

There are several examples on the FTP site under MISC....(name is too long). One is CAM.ZIP. Another is VLIB.ZIP. VLIB is a reference file for the vector math functions in MP.

Sometimes I use a linear toolpath string to input a bunch of points, and start the math manipulations in PLIN. Another method is to input data in a buffer file (-.TX1,-.TX2, etc.).

A third way is to generate all data inside the -.PST file, with heavy usage of the buffer files as scratch files or arrays. With the last two methods, you have to start with PQ and a dummy -.NCI file.

 

Yes I checked and it still there after all the years. You get to learn what we learned all those years ago about some really cool stuff Mastercam has most people have no clue about.

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...