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 to get points from a drilloperation with a c-hook?


Recommended Posts

Hello to all,

 

I try to get geometry from operations with a c-hook in X6 , in contour and pocket all is fine, I get the entities.

 

But in drilloperations the chain_manager get no chains because there are points in the geometry and no chains I think.

 

Can someone tell me how I can solve this?

 

I use the following code, thank you for help, Karsten

 

void OPDatenLesen()
{
CHAIN_ENT *chain_elem;
CHAIN *act_chain;
ent entity;
chain_manager_info cmi;
memset(&cmi,0,sizeof(chain_manager_info));
MC_BOOL succf;
DB_LIST_ENT_PTR eptr;
operation op;
for (int i=1; i<5; i++)
{
op.op_idn = i;
operation_manager(&op, OPMGR_GET, &eptr, &succf);
if (succf)
{
if (op.db.select_flag == TRUE)
{
if (op.opcode == TP_DRILL)
{
 cmi.op_idn = op.op_idn;
 cmi.mode = CHNMGR_GET;
 chain_manager(&cmi,0,&succf); // <- does not work in drill operations
 if (succf)
 {
 act_chain = cmi.chns;
 do
 {
 chain_elem=act_chain->start;
 do
 {
 get_ent_from_eptr(chain_elem->e_ptr,&entity);
 switch (entity.id)
 {
	 case P_ID:
	 {
	 AfxMessageBox(_T("point"));
	 break;
	 }
	 case A_ID:
	 {
	 AfxMessageBox(_T("arc"));
	 break;
	 }
	 default:
	 break;
 }
 chain_elem=(chain_elem->next);
 }
 while(chain_elem!=NULL);
 act_chain=(act_chain->next);
 }
 while(act_chain!=NULL);
 free_chains(&act_chain);
 }
}
else if (op.opcode == TP_CONTOUR || op.opcode == TP_POCKET)
{
 cmi.op_idn = op.op_idn;
 cmi.mode = CHNMGR_GET;
 chain_manager(&cmi,0,&succf);
 if (succf)
 {
 act_chain = cmi.chns;
 do
 {
 chain_elem=act_chain->start;
 do
 {
 get_ent_from_eptr(chain_elem->e_ptr,&entity);
 switch (entity.id)
 {
	 case A_ID:
	 {
	 AfxMessageBox(_T("arc"));
	 break;
	 }
	 case L_ID:
	 {
	 AfxMessageBox(_T("line"));
	 break;
	 }
	 case NB_ID:
	 {
	 AfxMessageBox(_T("spline"));
	 break;
	 }
	 default:
	 break;
 }
 chain_elem=(chain_elem->next);
 }
 while(chain_elem!=NULL);
 act_chain=(act_chain->next);
 }
 while(act_chain!=NULL);
 free_chains(&act_chain);
 }
}
}
}
}
}

Link to comment
Share on other sites

Points in a "point-based' operation ->

 

 

/// <summary> Reports on the Points found in the Drill operations. </summary>
///
/// <remarks> This assumes that it was passed a 'point-based' type operation! </remarks>
///
/// <returns> The number of Points that were found in the supplied Operation. </returns>
int GetOpPoints(operation *op)
{
int drillPtsCount = 0;

ent op_ent;
ent_tp *tp_ents = NULL;
_long n_tp_ents;
MC_BOOL succf;
// "tp_get_all" is declared in Assoc_CH.h
tp_get_all (op->op_idn, &op_ent, &tp_ents, &n_tp_ents, &succf, FALSE);
if (succf && tp_ents != NULL)
{
for (int i = 0; i < n_tp_ents; i++)
{
if (tp_ents[i].u.tp.tp_id == TP_PT_PT) // Is it a Point record?
{
drillPtsCount++;
tp_point tp_pt = tp_ents[i].u.tp.u.pt; // The toolpath point

CString msg;
msg.Format("\n[OpID#:%i] %s ->\n%s = [X%.4f, Y%.4f, Z%.4f]",
 op->op_idn, op->comment, tp_pt.name, tp_pt.pt[X], tp_pt.pt[Y], tp_pt.pt[Z]);
::MessageBox(NULL, msg, (LPCTSTR)"Point Data", MB_OK);
TRACE(msg); // DEBUG
}
}
}
if (tp_ents != NULL)
{ free (tp_ents); } // MUST free the memory that was allocated by 'tp_get_all'!
return drillPtsCount;
}
/// <summary> Scans for drill type operations. </summary>
///
/// <returns> The number of Drill Ops that were found during the scan. </returns>
int ScanOperations()
{
int pointCount = 0;
INT_PTR opListSize = TpMainOpMgr.GetMainOpList().GetSize();
if (opListSize > 0)
{
operation *op = NULL;
// Loop through the operations
for (INT_PTR opCount = 0; opCount < opListSize; ++opCount)
{
op = TpMainOpMgr.GetMainOpList()[opCount];
if (op == NULL)
{ continue; }
// Do something different if it is a Drill Operation?
if (op->opcode == TP_DRILL) // (op_is_drill(op->opcode))
{
pointCount++;
GetOpPoints(op);
}
// Circle Mill / Thread Mill / Helix Bore
else if (op_is_point(op->opcode))
{
pointCount++;
GetOpPoints(op);
}
}
}
return pointCount;
}

 

 

What's up with the messed up CODE formatting on emastercam.com ?!? ;-(

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