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:

Recommended Posts

Groups_CH.H lists several different group functions list_grp_add_empty being one. Creating regular groups with these fucntions are quite simple. But creating a machine group this way will probably be a pain in the a**.

 

There's probably a hidden "create group" function that you just feed a machine/control name into and it does all the correct initializations. One of the Mastercam guys can probably help with this.

 

Or a way to set the default machine name and call post_FT_command with the function called by menu [mahchine type -> mill -> default]

 

Bryan smile.gif

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

So, any solutions yet on how to programatically create a machine group? I can not add tools and operations without one, and I do not want to ask from my C-Hook users to manually create it if it is going to the same one every time, and I already know which one.

Link to comment
Share on other sites

markov,

 

I don't know if this is the preferred method, but it seems to work! wink.gif

 

Of course all "Group Names" must be unique!

 

code:

#include "DbVars_CH.h"

/*

// 'product' defines from "DbVars_CH.h" ->

#define PRODUCT_MILL (MC_BYTE) 0

#define PRODUCT_LATHE (MC_BYTE) 1

#define PRODUCT_WIRE (MC_BYTE) 2

#define PRODUCT_DESIGN (MC_BYTE) 3

#define PRODUCT_DRAFT (MC_BYTE) 4

#define PRODUCT_ROUTER (MC_BYTE) 5

*/

 

#include "MachineDefFnc_CH.h"

// REQUIRES adding "MCMachineDef.lib" to Linker 'AdditionalDepenencies'

// Import the functions

extern DllImpExp group_list* OMcreateGroup(

char *gname,

MC_BYTE product,

long parent_grp_idn,

MC_BOOL edit_properties,

MC_BOOL use_insert_arrow);

extern DllExport MC_BOOL SetActiveMachine (LPCTSTR name);

 

 

 

// Creates a Machine Group - using the 'default machine' for the specified product.

// Returns: TRUE/FALSE = success/failure

BOOL CreateMachineGroup(MC_BYTE product, char* grpName, LPCTSTR machName)

{

group_list *gpl;

//char *gname = _T("My Machine Group");

//MC_BYTE product = PRODUCT_MILL;

//long parent_grp_idn = NULL;

//MC_BOOL edit_properties = FALSE;

//MC_BOOL use_insert_arrow = FALSE;

 

gpl = OMcreateGroup (grpName, product, NULL, FALSE, FALSE);

if (gpl == NULL) { return FALSE; } // error

 

BOOL bOK = TRUE;

if (machName != "")

{

bOK = SetActiveMachine (machName);

}

return bOK;

 

}

 

// Sample m_main function that calls our ‘create’ function

 

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

{

AFX_MANAGE_STATE(AfxGetStaticModuleState());

 

BOOL bOK = FALSE;

char* grpName = _T("My Machine Group");

LPCTSTR machName = _T("C:McamX-MR2cnc_machinesGENERIC FADAL FORMAT_2 4X MILL.MMD");

bOK = CreateMachineGroup(PRODUCT_MILL, grpName, machName);

return MC_NOERROR;

}

Link to comment
Share on other sites

Roger,

 

There is a problem with your code. If you add a "dbinit" call to the beining of the C-hook, you can not run it twice (there is an error message poping up). It seems that either "dbinit" does not know how to clean the groups properly, or we need a modification to the code.

 

Marko

Link to comment
Share on other sites

I forgot to mention in the above post that you need to create an operation after the first run in order to reproduce the problem.

 

There is no problem if you do "File->New" before the second run, which means it is not equivalent to calling "dbinit" from a C-hook. So what other functions can we use to start fresh?

 

Marko

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