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:

mvukovic

Members
  • Posts

    4
  • Joined

  • Last visited

mvukovic's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks rculver00 but this did not help. 1&2: The c-hook segment comes from the example testassc.c from chdev directory. And as expected, it checks the return code without detecting any errors. Also, there is a call to nci_manager with NCIMGR_WR_EOS argument. 3: This did not work either. Could it be because I am using version 8? Just a stupid question: if there is something in the binary nci file that does not get converted into ascii version, what is the point of having it in the binary file in the first place? Marko
  2. Hi, this is "wannabe" C-hook programmer again. What follows is a part of testassc.c example. Before running c-hook, I created a drill operation (it is expected to exist). The question is: why don't I see any "little teapot" text in the generated .nci file? Thanks, Marko =============== #include "m_vars.h" #include "m_init.h" #include "m_assoc.h" static void error(const char *s) { MessageBox(0, s, "Test", MB_ICONASTERISK); } static void test_nci_mgr (boolean *succf) { operation op; nci_bin n; db_ptr_type e_ptr; long fpos; tl_list *tl; // regenerate ALL operations that require regeneration (op.db.nci_flag == TRUE) nci_manager (0, NCIMGR_REGEN_ALL, &n, &fpos, succf); if (!*succf) { error("NCIMGR_REGEN_ALL"); return; } // post ALL the operations nci_manager (0, NCIMGR_POST_ALL, &n, &fpos, succf); if (!*succf) { error("NCIMGR_POST_ALL"); return; } // set binary nci file ptr to the end of the binary nci file nci_manager (0, NCIMGR_FEND, &n, &fpos, succf); if (!*succf) { error("NCIMGR_FEND"); return; } // make a manual entry operation using the 1st tool found in the database memset (&op, 0, sizeof (operation)); op.opcode = TP_MANUAL_ENTRY; // get a list of tools from the database list_manager (TL_ID, "", LSTMGR_GET, &tl); if (tl != NULL) { op.tl.slot = tl->tl.op.slot; // set the tool # if you want the operation to init the tool list_manager (TL_ID, "", LSTMGR_FREE, &tl); // free the tool list } // add a comment strncpy (op.comment, "I'm a manual entry operation", COMMENT_SIZE-1); // OPMGR_INIT_ADD writes the 'start of section' - // no need to call nci_manager (NCIMGR_WR_SOS) - OPMGR_INIT does not write the sos operation_manager (&op, OPMGR_INIT_ADD, &e_ptr, succf); if (!*succf) { error("OPMGR_INIT_ADD"); return; } // go to the end of the binary nci nci_manager (0, NCIMGR_FEND, &n, &fpos, succf); if (!*succf) { error("NCIMGR_FEND"); return; } // write the start of file - sof, tool info and (if turned on) parameters // set the rapid position to X1 Y2 Z0 for the 1002 line memset (&n, 0, sizeof (nci_bin)); n.gcode = NCI_RAPID; // gcode for sof must be NCI_RAPID or NCI_LINEAR n.op_idn = op.op_idn; // ALWAYS assign the parent operation's id number to all nci lines n.tp_ent_idn = 0; // set this to 0 n.u.m0.ep1[X] = 1.0; // home position X n.u.m0.ep1[Y] = 2.0; // home position Y n.u.m0.ep1[Z] = 0.0; // home position Z nci_manager (op.op_idn, NCIMGR_WR_SOF, &n, &fpos, succf); if (!*succf) { error("NCIMGR_WR_SOF"); return; } // write some comments to the binary nci memset (&n, 0, sizeof (nci_bin)); n.gcode = NCI_COMMENTNO; n.op_idn = op.op_idn; n.tp_ent_idn = 0; strncpy (n.u.m1005.comment, "I'm a little teapot short and stout", COMMENT_SIZE-1); nci_manager (0, NCIMGR_WR, &n, &fpos, succf); if (!*succf) { error("NCIMGR_WR 1"); return; } strncpy (n.u.m1005.comment, "This is my handle", COMMENT_SIZE-1); nci_manager (0, NCIMGR_WR, &n, &fpos, succf); if (!*succf) { error("NCIMGR_WR 2"); return; } strncpy (n.u.m1005.comment, "This is my spout", COMMENT_SIZE-1); nci_manager (0, NCIMGR_WR, &n, &fpos, succf); if (!*succf) { error("NCIMGR_WR 3"); return; } // now write the 'end of section' marker for the new operation memset (&n, 0, sizeof (nci_bin)); nci_manager (op.op_idn, NCIMGR_WR_EOS, &n, &fpos, succf); if (!*succf) { error("NCIMGR_WR_EOS"); return; } // or you could write the end of section with the operation_manager as shown // operation_manager (&op, OPMGR_NCI_ACCEPT, &e_ptr, succf); // let's post the new operation nci_manager (op.op_idn, NCIMGR_POST_ONE, &n, &fpos, succf); if (!*succf) { error("NCIMGR_POST_ONE"); return; } } void CH_ENTRY m_main(long *ptrs) { boolean succf; if (!open_app(ptrs)) return; test_nci_mgr (&succf); close_app(ptrs); }
  3. Bryan, Thank you, thank you, thank you... I have been banging my head for the past few days with this problem. It is a bit difficult to make C-hooks when the only documentation available are header files. I was not aware of the function init_tp_ent. Now let's see how far I shall get without asking for help again...
  4. Before I ask the question, let me first explain that I am not a person who drills holes for living using Mastercam. I am simply a software engineer with a part time job in a shop, so I am sorry if my question is trivial for you. The following C-hook is supposed to create a drill operation. It creates a circle at the coordinate (0,0,0), then prompts for a tool, and creates the operation. Of course, this is not exactly what I want to do, but if I can make this work properly, I can solve the real problem. When I run the C-hook, everything seems OK. I can see the operation in the Operation manager, but if I open the "Parameters" dialog, on the "Simple drill - no peck" tab "Retract" and "Depth" boxes are greyed out - disabled. I would not be to concerned about this, but if I create a drill operation manually using "Toolpaths-Dill" menu, those boxes are enabled. What worries me even more is that if I "Backplot" operation created by my C-hook, the drill goes down, up, and then down AGAIN! With manually created operation it just goes down and up which seems reasonable. So, what am I missing? And finally, here is the code: #include "m_vars.h" #include "m_init.h" #include "m_menu.h" #include "m_assoc.h" #include "m_math.h" #include "m_db.h" void CH_ENTRY m_main(long *ptrs) { boolean ok; ent sel_ent, op_ent; db_ptr_type tool_ptr = 0, point_ptr, p_ptr; tp_tool tl; tl_list *tl_head; if (!open_app(ptrs)) return; memset(&sel_ent, 0, sizeof sel_ent); sel_ent.u.ar.c[X] = sel_ent.u.ar.c[Y] = sel_ent.u.ar.c[Z] = 0.; sel_ent.u.ar.r = 1.; sel_ent.u.ar.sa = 0; sel_ent.u.ar.sw = TWO_PI; sel_ent.id = A_ID; sel_ent.eptr = 0; store_ent(&sel_ent, &point_ptr, ALIVE_BIT, main_color, main_level, main_attrib, &ok); memset(&tl, 0, sizeof tl); tool_manager(&tl, TLMGR_MENU, &tool_ptr, &ok); list_manager(TL_ID, "", LSTMGR_GET, (void**)&tl_head); if (ok && tl_head != 0) { operation op; db_ptr_type o_ptr; tl.op.slot = tl_head->tl.op.slot; tool_manager(&tl, TLMGR_GET, &tool_ptr, &ok); memset(&op, 0, sizeof op); op.opcode = TP_DRILL; operation_manager(&op, OPMGR_INIT, &o_ptr, &ok); op.tl = tl.op; operation_manager(&op, OPMGR_ADD, &o_ptr, &ok); memset(&op_ent, 0, sizeof op_ent); op_ent.id = ASSOC_ID; op_ent.assoc_id = TP_ID; op_ent.u.tp.op_idn = op.op_idn; op_ent.u.tp.ent_idn = sel_ent.ent_idn; op_ent.u.tp.id = P_ID; op_ent.u.tp.sel_id = sel_ent.id; op_ent.u.tp.eptr = sel_ent.eptr; op_ent.u.tp.optr = o_ptr; op_ent.u.tp.tp_id = TP_PT_PT; copy_p_3d(op_ent.u.tp.u.pt.pt, sel_ent.u.pt); op_ent.u.tp.u.pt.pt_method = PEC_CENTER; op_ent.u.tp.u.pt.eptr = op_ent.u.tp.eptr; store_ent_assoc(&op_ent, &p_ptr, TP_ID, &ok); op.db.ent_count++; op.db.disp_count++; operation_manager(&op, OPMGR_REWRITE, &o_ptr, &ok); } close_app(ptrs); }

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