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:

coolsas

Verified Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by coolsas

  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. 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); } } } } } }
  14. Hi Roger, thank you for reply. I will do what you say and look into that chook-wizard-project. Hope that helps. Thanks Karsten
  15. Hi Roger, sorry for my late response, but I was the last two weeks in france, where I got no internet. With blocking option I mean what you discribed, setting autocursor manually to intersection etc. My question was on X6 and X6MU1 32bit. I've tested now also on 64bit X6MU1, same problem, when my chook is active, the blocking option is still disabled. You can see it an attached picture. On X5 all is ok. I tried something: My Main-Function looks like this sample: extern "C" __declspec(dllexport) int m_main (int not_used) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // for testing CString str = _T("Nullpunkt"); p_3d nullpt; char pt_option; MC_BOOL valid_pt; point_proc (str,&pt_option, nullpt, &valid_pt); // end testing // startfunction StartMatrix_M(); return MC_NOERROR, MC_UNLOADAPP; } When I disable this codeline: AFX_MANAGE_STATE(AfxGetStaticModuleState()); then the autocursor-option is enabled, but than I have a bigger problem, in my startfunction StartMatrix_M(); I start some mfc-dialogs from CDialog-class, these dialogs are not running anymore, when the line is disabled. That means my chook does not work anymore, nothing happens. I need those dialogs urgently. Do you have any suggestions what I can do to use the autocursor-option? Thanks in advance Karsten
  16. Hi there, in my chook I prompt the user to select a point for calculation. I use code like this: CString str = _T("Nullpunkt") p_3d nullpt; char pt_option; MC_BOOL valid_pt; point_proc (str,&pt_option, nullpt, &valid_pt); In X5 it works fine, the blocking option for autocursor is enabled and I can use it to select for instance an intersection point between two lines. But in X6 the blocking option is not enabled, so I can't use it for pointselection. I use VS 2010pro for coding. Is there an option which I have to set before using the point_proc function to enable the blocking option or should I use a different function to prompt the user to select a point? There must be a solution, because the chook "DrawPock.dll" asks also for a point and then the blocking option is enabled for using. Perhaps somebody can help me to solve it. Thanks in advance Karsten
  17. Hi Roger, I want tell you that I've done like you recommend me. It was a little tricky to get the batchfiles working, but now all is running fine and I can simply switch between X-versions. Thank you for your great help. Karsten
  18. Hi Roger, thank you for reply. To change settings with system environment variables before loading the solution is a great idea! I will try this with batchfiles. Then I only have to change the outputplatformsetting X86<->X64 for X6 before compiling, thats ok and simple. I don't use vs2008 anymore since vs2010 has arrived and I don't have it installed. I compile my c-hooks only with vs2010 and they works fine under X3/X4/X5. Probably I don't use relevant functions, which are in need of vs2008, so I got no working problems. Thank you Karsten
  19. Hello Members, I develope a C-Hook in VS 2010 for X5 and now for X6 and X6 64bit. What is the best way to use the same code for all three Mastercamversions, because every version has different project-properties and sdk-directories? One way will be to leave all the code in his place and the settings as they are, and rename everytime the sdk-directory manually and change output from X86 to X64 (Mastercam X6) manually before compiling. Then I have to manage three different sdk-directories. Another way is to make for every mastercam-version in my chook-solution a different project-file and different solution-file. In my solution I have 6 projects. That means I have to manage 18 projectfiles and 3 solutionfiles to support 3 mastercamversions with the same code. Perhaps someone has an advice for me how to differentiate simple between the three outputversions and projectsettings. thank you in advance Karsten
  20. Hello Roger, thank you for answering. If the masking functionality like Mastercam V9 is not possible for the moment, then I leave my code like it is. I live since Mastercam X1 with this problem, it's ok for me. I posted now and asked for a solution because a customer, which I've updated from V9 to X4, asked me about this functionality. Perhaps in a future version may I get this masking work again. Thank you again and have a nice week without trouble. greetings Karsten
  21. Hello again, nobody can help me? Is it possible to do the selection masking in a Mastercam X2/3/4/5 C-Hook like I've done in Mastercam V9, and when yes, what shall I do? Can somebody give me a short code-sample please? Thank you in advance Karsten
  22. Hi Roger, the code for points looks like these sample: short Punkte() { ... CHAIN_ENT *ketten_elem; CHAIN *akt_kette,*ges_kette; ent entity; CString str; short succf; ... // V9 code begin chain_use_ent_mask=TRUE; // yes use selection mask chain_ent_mask=5; // only pints and arcs are allowed // V9 code end alloc_chain(&ges_kette,TRUE); { str = _T("Punkte"); succf=(chain_it_point(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 P_ID: { ... break; } case A_ID: { ... break; } default: break; } ketten_elem=(ketten_elem->next); } while(ketten_elem!=NULL); akt_kette=(akt_kette->next); } while(akt_kette!=NULL); ... } } free_chains(&ges_kette); // V9 code begin chain_ent_mask=8191; // all entities are allowed again // V9 code end ... return(succf); } the code for contour is mostly the same, but there i use "chain_it" instead "chain_it_point". I 've taken the codesample from my original X4-code, the problem I have you can see it in V9-code remarks on start and end of my function. I hope you understand my question. thanks in advance Karsten
  23. Hi Roger, thank you for your reply. My Mazatrol-C-hook is build with VS2010pro since May 2010 and it is running well in X2/X3/X4 and in X5Beta also. Formerly I have used VS2008pro and VS2005pro for X2/3/4. VS2003pro I used only for X1, which I don't want support anymore. But the problem I have is in all versions the same. I don't get a function to set selection-mask working. I have some mfc-dialogs to choose some options and then the user have to select the geometry for chaining, because I need the coordinates. In this function I want to allow the user only to select geometry I want, for instance, if in the dialogs the option drilling is chosen, then the user should only be allowed to select points or arcs for geometry. In VS6 for Mastercam V9 I used following code: chain_use_ent_mask=TRUE; // yes, use selection mask chain_ent_mask=5; // only points and arcs are allowed then in Mastercam V9 the user can select only points or arcs, no lines, splines or other things. This selection-mask setting is not working in Mastercam X and above. In the SDK-Help I cannot find the command "chain_use_ent_mask" or something like that. Is there a possibility to do a similiar thing in the chaining dialog from Mastercam X like in V9? When yes, can you give me a small codesample please, how I have to do. thanks in advance Karsten
  24. hello members, I have a problem with porting a c-hook to Mastercam X(1,2,3,4), original written for Mastercam V9. Everything is running well, but one function does not work. In VC 6.0 for Mastercam V9 I used a function to set the selection-mask, that the user can only select defined entities. The code looks like these: chain_use_ent_mask=TRUE; // yes, use selection mask chain_ent_mask=134; //only lines, arcs and splines are allowed to select In Mastercam X(1,2,3,4) SDK-help I cannot find this function and I've searched this forum and tried some weeks to find a solution but without success. Perhaps somebody here can help and give me a short sample, what I have to do in C++ (I use VS2010) to get this chaining mask working. thank you in advance 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

×
×
  • Create New...