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

I'm just starting out with chooks. I've downloaded a couple of the example chooks off the mastercam third party developers page, and have gotten those built and working correctly. Now I'm trying to take the Create Drafting Notes example and add in my own code. Without my code the project builds and runs as intended. What I'm aiming to do, with import operations, is automatically pull an operation from another file. I thought this would be a good place to start given my inexperience. I've gotten to a point where the project builds just fine but when I debug it, as soon as it hits the import_operations an exception is thrown as shown.

I placed a break point right before this line to check my values and it seems there may be something in the vector that was not initialized, as shown. However, now my lack of c++ experience is coming into effect because I have no idea if this is the actual problem, and if it is, I have no clue how to fix it. It's also completely possible this has nothing to do with the actual issue, in which case I really have no clue what's causing the problems.

Any help is much appreciated, if more information is needed please let me know. I'm running Mastercam 2022 and Visual Studio 2019. Here is the code:

 

void DemoImportOperations()
{
    LPCTSTR fname = (_T ("C:\\Users\\jakelabrie\\Desktop\\junk.mcam"));

    p_3di pOrigin_pt = { 0.0, 0.0, 0.0 };
    
    std::vector< long > op_ids{ 1 };

    bool just_op = true;
    short get_groups = 0;
    bool calc_fs = false;
    bool assign_views = false;

    DUPTOOL_CHK duptool_chk;
    duptool_chk.mode = 0;

    bool expand_ops = false;
    bool succf = true;
    bool display = false;

    import_operations(
        fname,
        &pOrigin_pt,
        op_ids,
        just_op,
        get_groups,
        calc_fs,
        assign_views,
        duptool_chk,
        expand_ops,
        &succf,
        display);

}

and in the m_main function is this:

DemoImportOperations();

Exception_Error.png

Vector_Error.png

Link to comment
Share on other sites

Thanks for the quick response! I have altered my code as shown below and now I'm getting a completely different error. It looks like one of the pointers that I defined needs to have "aligned allocation". I'm not entirely sure what that means. If I'm understanding this correctly, it seems that sometimes you manually tell pointers where to be stored. The mastercam SDK does not say anything about aligning the allocations for each variable but maybe that's common knowledge that I didn't know about? 

The code seems to be working as expected but I believe something is going wrong with the variables I defined after my code is executed. Again, any help is much appreciated and if more information is needed please let me know.

 

New Code:

void DemoImportAllOperations()
{
    TCHAR* fname = (_T("C:\\Users\\jakelabrie\\Desktop\\junk.mcam-operations"));

    p_3di Origin_pt = { 0.0, 0.0, 0.0 };
    const p_3d* pOrigin_pt = &Origin_pt;

    std::vector< long > op_ids = { 1 };

    bool just_op = true;
    short get_groups = 0;
    bool calc_fs = false;
    bool assign_views = false;

    DUPTOOL_CHK duptool_chk;
    duptool_chk.mode = 0;

    bool expand_ops = false;
    bool display = false;

    bool tempsuccf = true;
    bool* succf = &tempsuccf;

    import_all_operations(fname,
        pOrigin_pt,
        op_ids,
        just_op,
        get_groups,
        calc_fs,
        assign_views,
        duptool_chk,
        expand_ops,
        display,
        succf
    );
}

Assertion_Error.png

Align_Error.png

Link to comment
Share on other sites

Yes, you can import from a .mcam file just like you do when using  .mcam-operations files.
I cannot tell what is causing the issue from just what I can see in the image.
What version of Mastercam are you running?

If you wish, send us your project to SDK[at]Mastercam[dot]com along with your company contact info, and we’ll take a look.

When you ZIP up a Visual Studio project. Do not include the ‘x64’ folder and its subfolders.
Just makes the ZIP huge with files we do not need, as Visual Studio will recreate them when you build the project.


 

Link to comment
Share on other sites

After a few emails back and forth we found the issue. I was building the project in VS as a debug build, then trying to run it in the release version of Mastercam. I've learned if you have a debug build you need to run the debug version of Mastercam. Likewise, to run the chook in the release version of Mastercam, you need to build a realease build of the chook. Thanks to Khary and huge thanks to Roger Martin for their help on this one.

  • Like 1
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...