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:

CaKiwi

Verified Members
  • Posts

    63
  • Joined

  • Last visited

Posts posted by CaKiwi

  1. It does not work for me. All I need is a function with the one line declaring TpList. It gets the following error in a pop up window when it exits the function:

     

    Run Time Check Failure #2 - Stack around the variable 'TpList' was corrupted.

     

    I tried compiling with and without debug and running with and without a part loaded. I am running the latest SDK with X4.

     

    If I don't declare and assign TpList but instead just use TpMainGrpMgr.GetMainGrpList() directly it work fine.

     

    The code gremlins must be really chuckling over this. I don't get a failure when I do something that should fail and do get a failure when I do something that should work.

  2. @Sigmawave

    Here's how I now handle traversing operation groups for versions X through X4. I have a separate VS project for each and define the appropriate compile time variable VER_Xn in each project.

    code:

    #if defined(VER_X) || defined(VER_X2)

    #define GROUP_LIST group_list

    #endif

    #if defined(VER_X3) || defined(VER_X4)

    #define GROUP_LIST op_group

    #endif

     

    GROUP_LIST *getNextGroup(GROUP_LIST *pGroup, int ix)

    {

    #if defined(VER_X) || defined(VER_X2)

    if (ix == 0)

    {

    return group_list_ptr;

    }

    if (pGroup != NULL)

    {

    return pGroup->next_ptr;

    }

    #endif

    #ifdef VER_X3

    if (ix < TpMainGrpMgr.m_MainGrpList.GetSize())

    {

    return TpMainGrpMgr.m_MainGrpList.GetAt(ix);

    }

    #endif

    #ifdef VER_X4

    if (ix < TpMainGrpMgr.GetMainGrpList().GetSize())

    {

    return TpMainGrpMgr.GetMainGrpList().GetAt(ix);

    }

    #endif

    return NULL;

    }

     

    // Calling the function

    GROUP_LIST *p1;

    p1 = getNextGroup(NULL, 0); // First group

    p1 = getNextGroup(p1, ix); // Subsequent groups

    I also use the compile time variables for other changes for each release.

     

    I use VS 2003 for X, VS 2005 for X2 and X3 and VS 2008 for X4. I agree with Roger that you will not be able to use VS 2008 for them all.

     

    @Roger

    Sorry, I somehow missed the Whats New doc and it does seem to tell me all I needed to know. That said, yes, change happens but we work with a number of CAD/CAM systems and the others all do a better job of isolating users of their API from internal changes.

     

    But I greatly appreciate your assistance with this problem.

     

    Do you have any thoughts on the memory corruption I mentioned in my previous post?

     

    Thanks again.

  3. The code worked fine for me. When I called

     

    pGroup = TpMainGrpMgr.GetMainGrpList().GetAt(ix1++);

     

    after processing the last group, pGroup was set to NULL without any error. But I will change my loop to check for the number of groups. The reason I did it that way was that the code needs to work for X, X2, X3 and X4. For X and X2 I use the following code in the same loop within compile time variables

     

    group_list *pGroup;

    group_list pGroup = group_list_ptr;

     

    while (pGroup)

    {

    /* ... */

    pGroup2 = pGroup2->next_ptr;

    }

     

    I will need to change this code to get a count of the number of groups. Is there a way to get the number of groups in X and X2 without traversing the list and counting them?

     

    What didn't work for me was creating a function which declared and assigned a tpGrpList even without any other code e.g.

     

    void func()

    {

    tpGrpList TpList = TpMainGrpMgr.GetMainGrpList();

    }

     

    This fails with an error exiting func saying that the stack has been corrupted around TpList.

     

    It is a nuisance for us when the code is changed for every release of MasterCAM without any warning or documentation that I know of. I hope that the nethook interface will be more stable for future releases.

     

    Thanks again for the help.

  4. Thanks for the reply, Roger.

     

    I used code similar to this

    code:

    op_group *pGroup = TpMainGrpMgr.GetMainGrpList().RetrieveFirstOperationGroup();

     

    ix1 = 1;

    while (pGroup)

    {

    /* ... */

    pGroup = TpMainGrpMgr.GetMainGrpList().GetAt(ix1++);

    }

    But I found that I get memory corruption problems

    if I declare and intiialize a group list as follows:

    code:

    tpGrpList TpList = TpMainGrpMgr.GetMainGrpList();

    op_group *pGroup = TpList.RetrieveFirstOperationGroup();

     

    ix1 = 1;

    while (pGroup)

    {

    /* ... */

    pGroup = TpList.GetAt(ix1++);

    }

    It is of only academic interest as I have it working but I wonder if you have any thoughts on why this is.

  5. In X2 I used the following code to get tool numbers from the slot field of binaryNCI.u.m20004. In X3, the slot field no longer exists. There is a new field tlno but it sometimes contains the correct numbers and somtimes contains different numbers. Any help greatly appreciated.

     

    code:

      

    nci_manager(operIdent, NCIMGR_RD_SOS, &binaryNCI, &filePosit, &goodSoFar);

    while (goodSoFar)

    {

    nci_manager(operIdent, NCIMGR_RD, &binaryNCI, &filePosit, &goodSoFar);

    if (goodSoFar)

    {

    codeValue = binaryNCI.gcode;

    switch (codeValue)

    {

    ....

    case NCI_TOOL_INFO:

    slot20004 = binaryNCI.u.m20004.slot;

    break;

    ....

    }

    }

    }

     

    [ 10-14-2008, 05:24 PM: Message edited by: CaKiwi ]

  6. Thanks for the response Takashi. I'm sorry I haven't got back to you sooner but I have been working on other problems.

     

    I have experimented with using named_view_manager and found the using VWMGR_SELECT for the mode argument allows the user to select a view. However, the view structure returned has an m field which gives the X, Y and Z rotation of the view but does not contain the origin of the view. Is there a way to get this information?

     

    Thanks

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

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

  9. This is how I did it in C

    code:

     

    ent entity;

    MC_BOOL chkvis;

    MC_BOOL succf;

    char *cptr, *cptr2;

    DB_LIST_ENT_PTR ptr, found_ptr;

    ushort sel_mask;

    ulong ent_mask;

     

    chkvis = false;

    sel_mask = 0;

    ent_mask = N_ID;

    ptr = db_start;

     

    while (1)

    {

    get_raw_ent (chkvis, &ptr, &found_ptr, &entity, sel_mask, ent_mask, &succf);

    if (!succf)

    break;

    cptr = (char *) mTableFindData (entity.u.n.mtid);

    if (strncmp(cptr, "xxx", 3) == 0)

    {

    ...

    break;

    }

    }

  10. The following code to store a note works fine in X SP2 but X2 crashes shortly after the routine is exited

     

    code:

    {

    ent entity;

    int len;

    int lev;

    char txt[256];

    char *cptr;

    ulong mtid;

    DB_LIST_ENT_PTR ptr;

    attributes new_attrib;

    MC_BOOL succf;

     

    lev = 3987;

    strcpy(txt, "Test Note");

    len = strlen(txt) + 1;

     

    InitNOTE(&entity);

     

    cptr = (char *) mTableAlloc(len, &mtid); /* allocate table item */

    entity.u.n.mtid = mtid; /* assign memory table */

    strcpy(cptr, txt); /* copy string */

     

    /* Create new note */

    new_attrib.width = 0;

    new_attrib.style = 0;

    new_attrib.pen = 0;

    new_attrib.pstyle = 0;

    new_attrib.filler = 0;

     

    store_ent (&entity, &ptr, 0, 0, lev, new_attrib, &succf);

    }

    A message window pops up with the error

     

    "Mastercam X2 has encountered a problem and needs to close"

     

    The Net Hook is written in C# and it calls this routine in a dll written in C. It was compiled in X and is being run under X2.

     

    Any help greatly appreciated.

  11. Here's what I'm doing to get the NC program filename

     

    1) Looping through the operation list and extracting the base file name from the nci file in the op.cmn.nci_name field.

     

    2) Calling NCFile() and extracting the directory from the filename returned.

     

    3) Creating the full file name by concatenating the directory obtained in step 2, the file name obtained in step 1 and the nc_suffix variable.

     

    If anyone has a simpler way, I would be happy to hear from them.

  12. Thank for the response, Roger.

     

    I ran Zip2Go and the toolpath filenames listed in the report are the ones I want. They are the default filenames used when the operations are post processed. For example,

     

    C:mcamxMILLNCMACHINE_GROUP_1_1.NC

    C:mcamxMILLNCMACHINE_GROUP_1_2.NC

    C:mcamxMILLNCMACHINE_GROUP_2_1.NC

    C:mcamxMILLNCMACHINE_GROUP_2_2.NC

    C:mcamxMILLNCMACHINE_GROUP_2_3.NC

     

    in the following snippet from the Zip2Go file.

     

    It seems like I can get the file base name from the NCI file and the extension from a global variable (I forget which one at the moment, but I have used it before). My only questions are how do I get the directory and is this really the easiest way to do this?

     

    OP1

    Circle Mill

    C:mcamxMILLNCMACHINE_GROUP_1_1.NC

     

    OP1

    Pocket (Standard)

    C:mcamxMILLNCMACHINE_GROUP_1_2.NC

     

    OP2 Flip Part

    Manual Entry (M00 (FLIP PART - USE HOLES TO HOLD PART )

    C:mcamxMILLNCMACHINE_GROUP_2_1.NC

     

    OP2 Flip Part

    Pocket (Standard) - Pocket on Bottom

    C:mcamxMILLNCMACHINE_GROUP_2_2.NC

     

    OP2 Flip Part

    Contour (2D) - Profile on Bottom

    C:mcamxMILLNCMACHINE_GROUP_2_3.NC

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