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:

Upgrading to X3


Recommended Posts

I am trying to upgrade my X2 nethook to X3 and I am getting some syntax errors. The first is that group_list_pointer is no longer defined. It was previously defined in the include file groups_ch.h. Is there now a different way of traversing through the goups?

 

Also, is there any documentation on how to upgrade to X3

 

Thanks.

Link to comment
Share on other sites

CaKiwi,

 

If you're using .h files, it's a CHook, not a NETHook.

 

Anyway...

There have been changes in these 'lists', but I though that the 'old' way would still work, you'd just be warned that those 'old' methods are depreciated.

 

Are you sure that you have the latest (X3 release) version of the CHook SDK?

 

Also, check out the Mastercam X3 API - What's New.doc in your SDK folder.

Link to comment
Share on other sites

Sorry, I meant CHook. I'm sure I have the latest X3 SDK, I just downloaded it this morning.

 

I looked briefly at the doc you mentioned and it looks like it will require a considerable amount of work for me to do the conversion, as I maintain pointers to items in the list. If there is any way to use the old method in the mean time it would be very helpful.

 

Edit: Also do you have any code examples using the new methods?

Link to comment
Share on other sites

An update...

 

I was incorrect in stating that the old list pointers were still available in X3, but "depreciated". They are gone!

You need to change over to the replacement methods of manipulating/traversing these "lists".

In the root folder of your SDK installation, you should have Mastercam X3 API - Whats New.doc (See Chapter 4)

 

I’ve only updated one project that used these “list pointers” and it was not a big task.

Link to comment
Share on other sites

Thanks for the responses

 

Takashi, I tried your code in a test case and it worked fine, thanks. Now I have to make the changes in my application.

 

Roger, now that I understand the changes required a bit better, it won't be as bad as I first thought although not trivial because of the design of my application.

 

One more question. The field in the nci_mill_20004 structure formerly known as slot now seems to be named tlno. Is this the same field and are there any more similar changes?

 

Thanks again.

Link to comment
Share on other sites

I also have a question.

I made a chook with STRINGTABLE ID=5092’TEST STRING',

and made a .ft file for it.

 

When I was playing with solid and clicked undo button, Messagebox of ’TEST STRING' poped up.

 

MCCoreRes.dll

STRINGTABLE

5092, "Geometry is used in a solid. Are you sure?"

 

Is it better not to use STRINGTABLE ID=5092?

test.jpg

Link to comment
Share on other sites

Takashi,

 

From Page#5 in the -> C:McamX3sdkMastercam X3 API - Whats New.doc

Remove all AFX_MANAGE_STATE macros. If your app gets resources from a different DLL, please use the ChangeResCL class (found in INTERFACESCoreChangeResCL_CH.h). This class expects an HINSTANCE to a DLL containing the desired resources.

The “If your app gets resources from a different DLL…” may not be quite clear enough.

 

MFC Extension DLLs are different than “regular” MFC DLLs. I know… You’re thinking – “That’s obvious!”

 

Basically, since there are no AFX_MANAGE_STATE(s) in an Extension DLL, the way that MFC searches for resources happens differently with an Extension DLL.

 

When you ask for a resource ->

CString msg, title;

title.LoadString(IDS_WARNING);

MFC Searches the the “main” Resources first for the IDS_WARNING and if not found it continues the search, which includes your Chook DLL.

 

So… Sometimes the Resource(string in this case) returned will be “yours”, but if there is an overlap in Resource IDs, that ID# may be found in the main Resources (Mastercam!). Obviously trying to avoid the Resource#’s used by Mastercam would be an un-workable solution.

That is where the use of the ChangeResCL class comes in.

 

Note the example code on Page#5 in the -> C:McamX3sdkMastercam X3 API - Whats New.doc

Where the “local” (Your Chook DLL) HINSTANCE is being saved off for later use ->

 

// This saves the DLL instance handle for later use with

// ChangeResCl. If you use a separate resource DLL you

// should load it here using AfxLoadLibrary and save that

// handle here and in the extension module structure.

resHandle = hInstance;

// resHandle = AfxLoadLibrary(YourCHookNameRES.DLL);

// YourCHookName.hResource = hInstance;

 

Now when you need one of the Resources from your DLL, you use the ChangeResCL class to “redirect” the Resource search to your DLL.

 

ChangeResCl res(resHandle);

CString msg, title;

title.LoadString(IDS_WARNING);

 

You do want to use the ChangeResCL class to do this "redirect" Resources!

As when ‘resHandle’ goes out of scope, the destructor in the ChangeResCL class will automatically redirect the Resource search back to Mastercam.

This is important!

 

[ 08-29-2008, 09:36 AM: Message edited by: Roger Martin from CNC Software ]

Link to comment
Share on other sites

What Takashi is saying, is that the problem is not in his dll, but in Mastercam. Mastercam is loading his string instead of the one in mcres.dll.

 

I guess that that ChangeResCL isn't used everywhere inside X itself...

 

I just also had to change a resourcenumber in our product, because X was loading our bitmap.

Link to comment
Share on other sites

nostromo & Takashi,

 

Can I get examples of this behavior?

 

I'm unable to replicate this, even using Takashi Chook. I assume that I am not doing the correct thing in Mastercam to bring up the specific dialog her is referring to.

Takashi - could you please give me a screen shot of the dialog with the incorrect prompt.

 

In Takashi's CHook you can trace ChangeResCL 'capturing' the current Resource handle, then setting it to the Chooks' HINSTANCE and at the end of the CHook when ~ChangeResCL is called it restores to the handle back to what was 'captured' when the CHaneRsCL class was constructed. So (at first look) it appears that everything is going as it should.

 

nostromo,

Is your add-on interacting with Mastercam or just doing something and immediately exiting?

If the first, try using the changeBack() function (method in ChangeResCL) before control goes back to Mastercam, to see if that makes a difference.

Link to comment
Share on other sites

It took me less than 5 minutes to reproduce takashi's problem. As said before, problem is in mastercam, not in his code.

 

I added a string with resource id 5092 in one of our c-hooks/dlls, started mastercam, created 2 solids, preformed a boolean operation (remove) on them and then hit the undo btn.

 

result: I got my string in the mastercam dialog...

 

Please note: I didn't do anything in my code with that string!

I just added a string with the same resource id.

Link to comment
Share on other sites

The one I saw today was in the level manager, right click menu, contrast rows. The bitmap used for the check mark has resource id 7008, which was also in use for one of our bitmaps. The easy solution for us is to simply change our resource id.

 

And that has nothing to do with us actually using that resource or not. If the resource handle isn't set correctly in that Mastercam function, windows/mfc will use the resource with the requested id from the last (shared resource) dll loaded. And since the c-hooks are loaded after all other dll's....

 

[ 09-02-2008, 06:27 PM: Message edited by: nostromo ]

Link to comment
Share on other sites

"As said before, problem is in mastercam, not in his code."

 

Correct, Takashi's code looked correct to me, as that is the was I would have done it!

I am certainly not the expert on this, but just trying to gather information to pass along to the programmers.

 

And with your assistance (I knew I wasn't doing something to be able to reproduce Takashi's issue) I was able to get "TEST STRING" to appear on the "Deleting a referenced entity" system dialog.

 

With this information/example, I'll be able to inquire to the programmers, to find out was it going on here.

Link to comment
Share on other sites

Takashi & nostromo,

 

An update on the "why is Mastercam using MY (X3) CHook resources" question.

 

Investigation revealed that there is an issue with the resource handle being set (internal to Mastercam) in the Undo Solids functions. This is now on the programmers 'to-do' list.

 

Note! that you can eliminate all of these CHook - Mastercam resource clashing issues by simply removing this line from the DllMain of your (Extension DLL style) CHook ->

 

new CDynLinkLibrary(TESTCHOOKDLL);

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