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:

How add feature(hole) to mastercam use only chook?


Recommended Posts

Hello,

What functions I must use for create feature in mastercam?

I need create hole described by arc and depth.

Is it possible for not solid model?

 

Probably I must use operation_manager() and store_ent_assoc() but I don't know right sequence.

 

Pro

Link to comment
Share on other sites

pro,

 

For chains see this thread. PDG posted some helpful code for chains.

http://www.emastercam.com/cgi-bin/ultimate...t=008781#000001

 

For adding arcs or points to a drill operation here is some old code from when I was figuring out adding points and arcs to drill ops. It's probably not 100% correct but it gets the job done. I hope it can get you pointed in the right direction.

 

The code assumes there is already drill operations in the operation manager and arcs created on screen. The main function is init_tp_ent to connect your entities and operation. Also look up the documentation for select_ents since everything it needs isn't in this bit of code.

 

 

code:

 

short tp_id = TP_PT_PT; /* I: toolpath point type (points only) GRID, BOLT, etc */

char entry_method = 'C'; /* I: point entry method used */

p_3d pt; /* I: point value selected (points only) */

real tval[] = {0}; /* I: point t value used */

ent tp; /* O: ptr to toolpath ent to initialize */

 

boolean succf, tpsuccf, opsuccf;

 

ent ent_arc;

db_ptr_type entity_ptr, ptr, tp_prt, eptr;

 

op_list *op_head, *opl;

int count = 0;

 

//select an arc

select_ents(TXT_HDR, 100, SELECT_BIT, A_ID, &succf);

if (!succf) {

return;

}

 

list_manager (OP_ID, "", LSTMGR_GET, &op_head);

if (op_head == NULL) return;

 

/* FOR LOOPING */

opl = op_head;

while (opl != NULL) /* start looping through operations */

{

/* ONLY SELECTED OPERATIONS */

if (opl->op.db.select_flag == FALSE)

{

/* next operation */

opl = opl->next_ptr;

continue;

}

 

/* ONLY DRILL OPERATIONS */

if (opl->op.opcode != TP_DRILL)

{

/* next operation */

opl = opl->next_ptr;

continue;

}

 

 

ptr= db_start;

get_ent( &ptr, &entity_ptr, &ent_arc, SELECT_BIT, A_ID, &succf);

while (succf){

 

init_tp_ent (

&ent_arc,

P_ID,

tp_id,

entry_method,

ent_arc.u.ar.c,

tval,

&opl->op,

&tp );

 

store_ent_assoc ( &tp, &tp_prt, TP_ID, &tpsuccf);

if (!tpsuccf) {

cleartextall();

mprintf ("tp not stored");

wait_for_space();

}

 

opl->op.db.ent_count++; /* increment # of holes */

opl->op.db.disp_count++; /* increment # of holes */

 

/* get next entity */

get_ent( &ptr, &entity_ptr, &ent_arc, SELECT_BIT, A_ID, &succf);

} /* end while succf loop */

 

/* mark operation as dirty */

opl->op.db.nci_flag = TRUE;

/* save operation */

operation_manager( &opl->op, OPMGR_REWRITE, &eptr, &opsuccf);

//you can call operation manager again if you want to regen see documentation

if (!opsuccf){

cleartextall();

mprintf ("op not stored");

wait_for_space();

}

 

/* next operation */

opl = opl->next_ptr;

 

}//end while (opl != NULL)

 

/* free the list of operations */

list_manager (OP_ID, "", LSTMGR_FREE, &op_head);


Bryan smile.gif

Link to comment
Share on other sites
  • 2 weeks later...

Thanks for help,

Now I can create arc and connect this arc with drill operation.

drill depth defined in operation op.cmn.depth

drill diameter defined in operation op.tl.dia

drill direction defined in operation op.tpln.m

But when I select mainmenu->toolpath->operation [RegenPath] occur error "Unable to calculate toolpath. Tool assigned to operation does not exist".

Where can I set tool use c-hook?

Link to comment
Share on other sites

With out seeing your code I can only guess.

 

you need to set the op.tl.slot so the operation knows what tool slot the tool is in.

 

If the tool exists us list_manager with TL_ID to find it.

 

If the tool doesn't exist you have to create one first. Use the tp_tool struct, tool_manager with TLMGR_ADD

 

Bryan smile.gif

Link to comment
Share on other sites

When I use existing tool from tool_library, tool also not defined but in operation parametrs icon with drill present.

There simple version of code:

list_manager list_manager (TL_ID , tool_library, LSTMGR_GET, (void**)&tl_head);

tool_manager (&tl_head->tl, TLMGR_ADD, &ptr_tool, &ok);

op.tl.slot = ptr_tool;

  • Like 1
Link to comment
Share on other sites

Thanks for examples it help. cheers.gif

The existing tool from tool_library don't connected correctlu with my operation because of

tl_list tl->tl.op.dia was not equal operation op.tl.dia

Now all ok and operation regerated from chook use nci_manager(, NCIMGR_REGEN_ALL,);

 

There was one problem how to perform set drill direction easier, now I use modification of matrix in operation op.tpln.m.

Link to comment
Share on other sites

Matrixes (what's the plural for matrix?) are fun. biggrin.gif (Math geek in me coming out.) I usually sidestep the issue and pull directly from the current t/c plane. I believe I left some of that code in the file I sent you.

 

The M_math.h file has some useful functions for matrix manipulation. Specifically mul_matrix_33. Also get_view_matrix and find_view_m among others. named_view_manager in m_assoc.h if you want to make you own named views.

 

Bryan smile.gif

Link to comment
Share on other sites
  • 3 years later...

Hey guys. I found this searching for tool_manager help. I understand that I can use the first argument to setup a tool parameters myself. However, I'd like to use the tools found in C:mcamxmilltoolsMILL_INCH.TOOLS.

 

I have my operation important with a generic tool. But want to change to a different tool. I'd like to select a tool from the tool file I mentioned. I don't really understand what the third argument *eptr is used for. I'm guessing I'm not lucky enough for that to be a tool database am I? How else could I select a tool from MILL_INCH.TOOLS and use it in my operation?

 

As mentioned above I can change the diameter (op.tl.dia) and even the tool # (op.tl.tlno) but that doesn't match what the tool manager wants to use. Any help is appreciated.

Link to comment
Share on other sites

I also looked into using list_manager. I thought according to what I need above, that I could do something like this:

 

list_manager(TL_ID, NULL, LSTMGR_GET, list_ptr);

 

but I don't understand what I am getting back from list_ptr. It would be nice if I could get a certain tool from MILL_INCH.TOOLS and give it to tool_manager. Any help is appreciated.

Link to comment
Share on other sites

Alex,

2nd argument is the tool library name.

 

char toollib[MAX_PATH]="c:.....MILL_INCH.TOOLS";

list_manager(TL_ID, toollib, LSTMGR_GET, list_ptr);

 

 

code:

 

tl_list *tl_head, *tl_move;

list_manager (TL_ID, "", LSTMGR_GET, (void **)&tl_head);//current tool library

tl_move = tl_head;

while (tl_move != NULL)

{

//do something, (tool_manager etc..

tl_move = tl_move->next_ptr;

}

list_manager (TL_ID, "", LSTMGR_FREE, (void **)&tl_head);

Link to comment
Share on other sites

Thanks for the code Takashi. I added some functions to it, but do not see any changes to my operation's tool. Is there something I'm doing wrong here:

 

_________________________________________________

char toollib[MAX_PATH]="C:mcamxmilltoolsMILL_INCH.TOOLS";

tl_list *tl_head, *tl_move;

MC_BOOL succf_tl;

list_manager (TL_ID, toollib, LSTMGR_GET, (void **)&tl_head);//current tool library

tl_move = tl_head;

tl_move = tl_move->head_ptr;

while (tl_move != NULL)

{

if (tl_move->tl.pilot_dia == feat_rough_tool) //feat_rough_tool is the tool diameter I want

{

operation_manager (&op, OPMGR_GET, &eptr, &succf_tl);

tool_manager (&tl_move->tl, TLMGR_ADD, &eptr, &succf_tl);

operation_manager (&op, OPMGR_REWRITE, &eptr, &succf_tl);

break;

}

tl_move = tl_move->next_ptr;

}

list_manager (TL_ID, toollib, LSTMGR_FREE, (void **)&tl_head);

_________________________________________________

Link to comment
Share on other sites

You have to change operation's tool parameters.

cool.gif

code:

 	group_list *machine=OMgetActiveMachineGroup();

while (tl_move != NULL)

{

if (tl_move->tl.op.type==END_MILL&&1.0<=tl_move->tl.op.dia)

{

if(machine)tl_move->tl.op.machine_grp_idn=machine->grp_idn;

op.tl.slot = tl_move->tl.op.slot = newslotnum;

op.tl.tlno = tl_move->tl.op.tlno = newtoolnum;

op.tl.type = tl_move->tl.op.type;

op.tl.dia = tl_move->tl.op.dia = 1.0;

tool_manager (&tl_move->tl, TLMGR_ADD, &eptr, &succf);

break;

}

tl_move = tl_move->next_ptr;

}

Link to comment
Share on other sites

Thank you very much for the help Takashi. I was able to find the tool I was looking for and put it in my Toolpath operation. However, the surface_manager and chain_manager functions now don't work. Here is a layout of my functions:

 

----

 

import_operations(...);

operation_manager (&op, OPMGR_GET, &eptr, &succf);

tool_manager (&tl_move->tl, TLMGR_DELETE, &eptr, &succf_tl); //delete old tool

tool_manager (&tl_move->tl, TLMGR_ADD, &eptr, &succf_tl);

surface_manager(...);

chain_manager(...);

operation_manager (&op, OPMGR_REWRITE, &eptr, &succf);

-----

 

The correct tool shows up in my group list. However, the operations that I had working that selected the chain and surfaces, do not work.

 

Is there any other reason the surface and chain managers might stop working after adding the code you suggested? I only have one operation in my group and refer to this op in surface manager as the first argument: op.op_idn and again in chain_manager_info. Any suggestions?

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