coolsas

Verified Members
  • Content count

    27
  • Joined

  • Last visited

Community Reputation

0 Neutral

About coolsas

  • Rank
    Member

Recent Profile Visitors

519 profile views
  1. Hi Zaffin_D, Yes, your code is working within Mastercam 2019 too. I get the arcs correct. Best wishes Karsten
  2. Hi there, perhaps if somebody is interested, this is how it works for me: extern "C" __declspec(dllexport) int m_main(int not_used) { // Must call this prior to accessing any Resources in the C-Hook DLL ! ChangeResCl res(GetChookResourceHandle()); CHAIN_ENT *ketten_elem; CHAIN *ges_kette, *akt_kette; ent entity; CString str; short succf; int kfaktor; int richtung; alloc_chain(&ges_kette, FALSE); str = _T("select geo"); succf = (chain_it(str, &ges_kette)); if (succf == CHAIN_OK && ges_kette != NULL) { akt_kette = ges_kette; do { ketten_elem = akt_kette->start; do { get_ent_from_eptr(ketten_elem->e_ptr, &entity); switch (entity.id) { case L_ID: { break; } //case L_ID case A_ID: { // factor for c-plane matrix_33 k_mat; get_view_matrix(CONSTR_VIEW_N, k_mat); // z-vector 0 or positive? if (k_mat[2][2] >= 0) kfaktor = 1; else kfaktor = -1; // arcdirection richtung = int(fabs(entity.u.ar.sw) / entity.u.ar.sw); // ep1=starting point if (ketten_elem->ep_n == 0) { if ((-1 * richtung*kfaktor) == 1) { AfxMessageBox(_T("[CW]\n")); } else if ((-1 * richtung*kfaktor) == -1) { AfxMessageBox(_T("[CCW]\n")); } } // ep2=starting point else { if ((richtung*kfaktor) == 1) { AfxMessageBox(_T("[CW]\n")); } else if ((richtung*kfaktor) == -1) { AfxMessageBox(_T("[CCW]\n")); } } break; } //case A_ID case NB_ID: { break; } //case NB_ID default: break; } //Switch entity.id ketten_elem = (ketten_elem->next); } while (ketten_elem != NULL); akt_kette = (akt_kette->next); } while (akt_kette != NULL); } free_chains(&ges_kette); return MC_NOERROR | MC_UNLOADAPP; } Best wishes and Happy Easter Karsten
  3. Hi Peter, That is what I have done in my version of your first proposal: arcdir = ChainDIRECTION(chain, CONSTR_VIEW_N); You can see that in the project testarcs.rar linked in my 2nd pst. Hi Zaffin_D, I changed your function as you posted, same Problems, if the c-plane is not top. But I have found something during testing (rotation of the solid around wks x-axis): My original calculation is correct when the z-vector of the active c-plane points to positive Z (from WKS TOP). When the z-vector of the active c-plane points to negative Z (from WKS TOP) then the arc direction is vice versa. Active c-plane front and back seems to be correct also. I think, thats it. Thank you very much for trying to help me I wish both of you all the best and stay healthy in these days. Best wishes, Karsten
  4. Hi Zaffin_D, I have tried your code, unfortunately I have similar problems, sometimes arc direction is correct, sometimes not. You can check that in my uploaded file Testarc.mcam the link is in my 2nd post. I select c-plane top and start your function, then I select the wireframe contour on top of the solid, I chain it clockwise (then all 4 arcs should be CW) then I get 3 CW and 1 CCW. When I select c-plane bottom, start your function and chain the geometry on bottom of the solid, then I get 2 CW and 2 CCW as message. When I use the mastercam function analyze->contour then I get the correct data, chaining the contour clockwise I get 4 CW arcs, chaining counterclockwise I get 4 CCW arcs. That is what I need. Unfortunatley I am not the mathematician to calculate it from entity data (ep1, ep2, c, r, sa, sw) depending the active c-plane. I thank you Zaffin_D and Peter for trying to help me. Best wishes Karsten
  5. Hi Zaffin_D, thank you for your proposal, I will give it a try. Best wishes, Karsten
  6. Hi Peter, I use from entity arc entity.u.ar.ep1, entity.u.ar.ep1, entity.u.ar.r, entity.u.ar.sw. I determine a factor depending the active c-plane and determine the arc direction // faktor for c-plane matrix_33 k_mat, a_mat; get_view_matrix(CONSTR_VIEW_N,k_mat); get_view_matrix(entity.u.ar.view,a_mat); // compare ob z-vector if(k_mat[2][0] == a_mat[2][0] && k_mat[2][1] == a_mat[2][1] && k_mat[2][2] == a_mat[2][2]) { kfaktor=1; } else { //if not, is diff < 0,001 if( ((k_mat[2][0]*1000) - (a_mat[2][0]*1000) <=1) && ((k_mat[2][1]*1000) - (a_mat[2][1]*1000) <=1) && ((k_mat[2][2]*1000) - (a_mat[2][2]*1000) <=1) ) { kfaktor=1; } else { kfaktor=-1; } } //arc direction richtung=int(fabs(entity.u.ar.sw)/entity.u.ar.sw); then later I check which point is startingpoint EP1 or EP2 and determine my output. // ep1=Startpoint ? if (ketten_elem->ep_n==0) { if ((-1*richtung*kfaktor) == 1) { swprintf_s(tempstr,_T("[CW]\n")); } else if ((-1*richtung*kfaktor) == -1) { swprintf_s(tempstr,_T("[CCW]\n")); } wcscat_s(MMA_chainstring,tempstr); } else { // ep2=Startpoint if ((richtung*kfaktor) == 1) { swprintf_s(tempstr,_T("[CW]\n")); } else if ((richtung*kfaktor) == -1) { swprintf_s(tempstr,_T("[CCW]\n")); } wcscat_s(MMA_chainstring,tempstr); } All that works fine except when the active c-plane is parallel to standard bottom or standard back c-plane. Then my direction-calculation is wrong. If the arc is CW chained my calculation gives me CCW and vice versa. I think I have to check if the active c-plane is parallel to bottom or back c-plane and then change my factor. Thank you and best wishes Karsten
  7. Hi Peter, my chook is for exporting geometry data from mastercam into mazatrol cycles. The user selects in a custom dialog a mazatrol-cycle and then he is asked to select the geometry he wants to export into this mazatrol cycle. The selected geometry (arcs, lines, splines, points) will be chained (via "chain_it") and then the chain is examined, which kind of geometry was selected. To recalcutate the coordinates depending of the active c-plane I need to know, if an arc is cw or ccw. If there is a better way to get the properties of a selected geometry, I will try it. I need something like the mastercam funktion "analyse ->contour". My chook works quite well in the event that the active c-plane is top or front or free in space. But not when the active c-plane is parallel to standard bottom or standard back c-plane. Then my previous direction-calculation is wrong. If the arc is CW chained my calculation gives me CCW and vice versa. Perhaps I should say that my chook is a mfc extension DLL. Thank you and best wishes Karsten
  8. Hi Peter, thank you for your answer. I have tried to use your proposal and changed it a little for my purpose. Unfortunately I get everytime "CCW" as an answer, no matter how I made the chaining. I have uploaded the VS2017 test-Project and the Mastercam 2019 test-file. For the SDK directory in VS2017 I use a systemvariable "SDX_X" and my SDK-path is "C:\Mcam-SDK\sdk-2019". Perhaps you could take a look, what I have done wrong. Thank you and best wishes Karsten testarcs.rar TESTarc.mcam
  9. Hi there, is there a quick and easy way to detect/determine the direction (cw or ccw) of a chained arc, depending of the active cplane with a chook? In this Moment I use Mastercam 2019 an Visual Studio 2017. Thank you for an answer an best wishes Karsten
  10. Thank you Roger for your answer. Then I will live with using quick access toolbar in 2017. Best regards
  11. Hello to all, For the last mastercam Versions I have used png 24px 32bits for large Icons and png 16px 32bits for small Icons. In Mastercam 2017 the small Icon is used when I put my c-hook into quick Access toolbar. When I want to make a custom ribbon tab to use my chook, then the large Icon is used, scaled (to 48px I think) and it looks very bad because of scaling. How to get bigger Icons (avoid scaling) into chook? When I use png 48px then the ribbon tab don't display my programmed Icon. What is the right icon format to use in Mastercam 2017 Ribbon Tab? Thank you
  12. Hi Roger, your code was a great help for me. I have now a mixed code, a part of your version for point op, and my code for contour and pocket op, because I did not get your code working for chain geometry. For now it works. Thank you again. Karsten
  13. Hi Roger, thank you for reply. I wíll try it. Karsten
  14. 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); } } } } } }
  15. Hi Roger, thank you for reply. I will do what you say and look into that chook-wizard-project. Hope that helps. Thanks Karsten

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