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:

TJ00_SH

Verified Members
  • Posts

    31
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

839 profile views
  • wwpp

TJ00_SH's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Roger, Thanks for your advice, appreciated. Your're right, Forget about all the job related things. Just have fun. Thanks,
  2. Roger, Hello. It's been a while. I'm a little confused, could you explain it more, please? (1) NETHook3_0 API that ships with X7--> I know this, no problem. (2) As you mentioned above, "NETHook v2" and "NETHook2_0 API" Are these two different things? Currently, I'm using "C:\Program Files\mcamx6\NETHook2_0.dll", dated 05/29/12. This .dll came with X6 MU3, I think.--> This *.dll is "NETHook v2" because I'm having an error, right? (3) How can I get "NETHook2_0 API"? Just like C-hook sdk, it can be obtained through our Mastercam reseller? Thanks for your help.
  3. Mick, Hello. You meant to post "4.3 - The Arc Classes.cs", right? /* * Copyright (c) 2006 CNC Software, Inc. * * NetHook 2.0 API * Example Files - C# * Date: Tuesday, November 21, 2006 * Author: Michael J. Crivello * * * NetHook 2.0 API Example: #4.3 - The Arc Classes * * The arc class, which has some of the most involved math, is arguably one of the simplest * to use. There's no applicable overloaded operators and there's nothing but a center point, * a radius, and two degree values to express the arc completely. * * Internally, once an arc class is defined the math library handles any of the necessary * work in establishing additional information. Since an arc can be exclusively and * unambiguously described by a center point, radius, start and end angles, that's all the * information that's used in the arc object. */ using System; using Mastercam.App; using Mastercam.App.Types; using Mastercam.BasicGeometry; using Mastercam.IO; using Mastercam.Math; using Mastercam.Curves; namespace NetHook2Example { public class ArcClassesExample { public static String DialogTitle = "Arc Classes Example"; public static MCamReturn RunExample() { FileManager.New(true); // The arc class default constructor initializes all of the member data to 0.0's, // so the center point will be at the origin, the radius will be 0.0 units in // length, and the start and end angle degrees will both be 0.0. Arc3D DefaultArc = new Arc3D(); DisplayArcData(DefaultArc); // The arc class also has a parameterized constructor which takes a center point, // a radius, a starting angle, and an ending angle. This arc should be a circle // (because the start angle is o.o degrees and the end angle is 360.0 degrees) // with radius 1.0. Arc3D ParamArc = new Arc3D(new Point3D(0.0, 0.0, 0.0), 1.0, 0.0, 90.0); DisplayArcData(ParamArc); // Now, let's explore some of the concepts behind these parameters. We're going // to be creating some arc geometry, and while geometry will be covered in a // later chapter this should still allow us to see the visual effects of the // parameters we'll be changing. // Obviously the center point represents the center point the arc is anchored // from and the radius represents the distance from the center point to the edge // of the arc. But what do the start and end angles represent? Simply put, the // start and end angles representing the beginning and end point of the arc in // terms of degrees. If we were to describe it in terms of a clockface, the // degrees measure from 0.0 degrees at 9 o'clock, in a clockwise direction, // all the way around. So, 90.0 degrees would be 12 o'clock, 180.0 would be 3 // o'clock, etc. So if we create some arc geometry with the arc math object we // just constructed at the last step and you're in standard top view, you should // see a quarter circle in the upper left quadrant of the screen. ArcGeometry NewArcGeom = new ArcGeometry(ParamArc); NewArcGeom.Commit(); GraphicsManager.Repaint(true); DialogManager.OK("There should be a quarter-circle on the screen now - is there?", DialogTitle); // If you wanted to create a full circle, all you would have to do is create // an arc with a start angle of 0.0 degrees and an ending angle of 360.0 // degrees, making a full circle. // This one works with C#, but not VB.NET <--This is my comment when I was testing with VB.NET. (Late binding isuue...) NewArcGeom.Data.StartAngleDegrees = 0.0; NewArcGeom.Data.EndAngleDegrees = 360.0; NewArcGeom.Commit(); // We have to do a full regen of the database because we're changing a // geometry object that's already in the database - if we were just creating a // new arc we wouldn't have to do this. GraphicsManager.Repaint(true); DialogManager.OK("Our old quarter-circle should now be a full circle - is it?", DialogTitle); return MCamReturn.NoErrors; } public static void DisplayArcData(Arc2D DisplayArc) { String Arc2DString1 = String.Format("This 2D arc has the data:\n\nCenter Point:\n X - {0}\n Y - {1}", DisplayArc.CenterPoint.x, DisplayArc.CenterPoint.y); String Arc2DString2 = String.Format("\n\nRadius: {0}\nStart Angle: {1}\nEnd Angle: {2}", DisplayArc.Radius, DisplayArc.StartAngleDegrees, DisplayArc.EndAngleDegrees); DialogManager.OK(String.Concat(Arc2DString1, Arc2DString2), DialogTitle); } public static void DisplayArcData(Arc3D DisplayArc) { String Arc2DString1 = String.Format("This 3D arc has the data:\n\nCenter Point:\n X - {0}\n Y - {1}\n Z - {2}", DisplayArc.CenterPoint.x, DisplayArc.CenterPoint.y, DisplayArc.CenterPoint.z); String Arc2DString2 = String.Format("\n\nRadius: {0}\nStart Angle: {1}\nEnd Angle: {2}", DisplayArc.Radius, DisplayArc.StartAngleDegrees, DisplayArc.EndAngleDegrees); DialogManager.OK(String.Concat(Arc2DString1, Arc2DString2), DialogTitle); } } } Thanks for your help.
  4. Hello All, Well, it's been more than a year and half since my last post , sidetracked to SolidWorks API, learned something, it was sort of fun, and came back. Currently, using Win7, Mcam X6 MU3, NETHook2_0.dll, .NETFramework4, VS2010 Pro. Now, I'm looking at NetHook2Example sample program in C#. In the beginning, I was looking at the same program in Visual Basic, but there were some posts here talking about "Late binding", so I switched to C#. I have an error in Debug mode, as follows: public class ArcClassesExample ... // see a quarter circle in the upper left quadrant of the screen. ArcGeometry NewArcGeom = new ArcGeometry(ParamArc); NewArcGeom.Commit(); <--Error happens here. GraphicsManager.Repaint(true); DialogManager.OK("There should be a quarter-circle on the screen now - is there?", DialogTitle); Error message on screen says "Waring-zero length arc". Error detail: Mastercam.App.Exceptions.EntityWriteFailedException was unhandled by user code HResult=-2146233088 Message=A database error has occurred - the writing of an entity to the database has failed. Source=NETHook2_0 Name=Mastercam Database Exception: Entity Write Failed Just for a try out, downloaded X7 preview version and NETHook3_0.dll (comes with X7), it just worked fine. Am I missing something? Or, if this is a known problem, then are there any way to go-around the problem? Thanks for your help, appreciated.
  5. Roger, Hello. Thanks for your reply. Right, I completely forgot that. I've just finished installing VS2008 SP1, and tested my program again. Bautiful, as if nothing happened before. Thank you for your help every time, appreciated. P.S. This is just a chit-chat... Last couple of months, I've been working on SolidWorks API, using VS 2010 Express edition. Glad I had some knowledge about VB and VC#, learned when I was making some .Nethook programs several months ago. Once learned how to layout controls, mostly labels, buttons, check-boxes, List-boxes, arrays, etc. in the Form, and assign event handlers for those, the rest of it is to look for suitable class/methods/properties. Like you said in recent post, "Intellisense" will be very helpful. I 100% agree with you, even though I'm still a newbie.
  6. Hello All, Recently, installed X5 MU1 and X5 MU1 sdk at the same time on a used PC, but all "Windows Update" has been done, so XP is up-to-date. It may be irrelevant, but SolidWorks 2011 is also running on this PC. When I tried to compile an existing C-hook program, bunches of error messages are displayed. For a test, tried to compile the same program on different PC, X5 MU1, compile/link are OK, and it makes a .dll file. I also tested this C-hook program to compile for X4 MU3 version, no problem at all. I uninstalled Mastercam software completely from the PC, and installed it again, but still the same. Just trying to make a sample C-hook program by C-hook Wizard, no luck, still the same problem. It's been a while since I worked on my last C-hook program, so I might be missing or forgetting something very important. Here is a partial copy of error messages. There are 16 error messages in all, but each error is related to one of these three header files. Error 1 error C2039: 'shared_ptr' : is not a member of 'std::tr1' c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h 26 create_midpoint Error 8 error C2065: 'tp_tool_ptr' : undeclared identifier c:\program files\mcamx5\sdk\interfaces\core\TlToolMill_CH.h 64 create_midpoint Error 9 error C2065: 'LATHETOOL_PTR' : undeclared identifier c:\program files\mcamx5\sdk\interfaces\core\TlToolLathe_CH.h 59 create_midpoint Here is a copy of command line for compilation (VS 2008). /O2 /Oi /GL /I "C:\Program Files\mcamx5\sdk\\" /I "C:\Program Files\mcamx5\sdk\\interfaces\gui" /I "C:\Program Files\mcamx5\sdk\\interfaces\core" /I "C:\Program Files\mcamx5\sdk\\interfaces\control" /I "C:\Program Files\mcamx5\sdk\\interfaces\geomsld" /I "C:\Program Files\mcamx5\sdk\\interfaces\lathe" /I "C:\Program Files\mcamx5\sdk\\interfaces\machinedef" /I "C:\Program Files\mcamx5\sdk\\interfaces\matss" /I "C:\Program Files\mcamx5\sdk\\interfaces\mill" /I "C:\Program Files\mcamx5\sdk\\interfaces\post" /I "C:\Program Files\mcamx5\sdk\\interfaces\msurf" /I "C:\Program Files\mcamx5\sdk\\interfaces\wire" /I "C:\Program Files\mcamx5\sdk\\interfaces\uictrls" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_AFXEXT" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /FD /EHsc /MD /Gy /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt Any suggestions/advice are welcome. Thanks for your help.
  7. Roger, Hello. As for "MCReal", I think you meant was this, right? CMyModelessDialog::CMyModelessDialog(CWnd* pParent /*=NULL*/) : MCDialog(CMyModelessDialog::IDD, pParent) //,m_p1_x (0.0, 0.0, MAXREAL, -1) --> @param[in] nDec Number of decimal places, -1 = use system default / from "MCREAL_CH.H" or--> //,m_p1_x (1.0, 0.0, MAXREAL, 5) or--> ,m_p1_x (1.0, MINREAL, MAXREAL, FALSE, FALSE, 5) ,m_p1_y (1.0, MINREAL, MAXREAL, FALSE, FALSE, 5) ,m_p2_x (2.0, MINREAL, MAXREAL, FALSE, FALSE, 5) ,m_p2_y (2.0, MINREAL, MAXREAL, FALSE, FALSE, 5) ,m_mdp_x (3.0, MINREAL, MAXREAL, FALSE, FALSE, 5) ,m_mdp_y (3.0, MINREAL, MAXREAL, FALSE, FALSE, 5) ,m_make_line (FALSE) { //{{AFX_DATA_INIT(CMyModelessDialog) m_p1_x.modeless = TRUE; m_p1_y.modeless = TRUE; m_p2_x.modeless = TRUE; m_p2_y.modeless = TRUE; m_mdp_x.modeless = TRUE; m_mdp_y.modeless = TRUE; // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } Now, displayed number is much shorter than before, but it still shows 6 places after decimal point even though I put 5 for "nDec". I have to look at my program again. Maybe, read/write PRM file is doing something...? // Data members 00076 public: 00083 BOOL modeless; ///< Is parent window modeless When I was checking "MCREAL_CH.H", I found this. For a try out, put "m_p1_x.modeless = TRUE;" and applied the same for the rest of valuables. I was not sure this was OK or not..., but it worked. Press ESC key once, not twice, will get me out of this C-hook program. I still need to add a routine to get out "get_point" mode when "OK" and "CANCEL" button were pressed. Well, it's little better than last week. Thank you.
  8. Roger, Hello. Thanks for your advice. Let me take a look at my program. Thanks,
  9. Hello, all. Using VS C++ 2008 and X5. It was a good timing after I learned "Shapes", I had a chance to make a real *.dll at work. So, I made a small C-hook program based on the sample program "Shapes", and "modeless" dialog sample program generated by C-hook Wizard. What it does is to create the midpoint between 2 points, any existing points such as endpoints, center points, etc., selected by mouse on screen. I used functions "get_point", "make_center", "make_line" and "compute_axis_vectors" from "Shapes", and made 6 edit controls as readouts (that's why I need the dialog to be displayed while operation is on), for the first, second and midpoint of X & Y coordinate. Also put a check box for "make a line" as an option if a user wants to see a line connected two points selected by mouse. Compile/link were successful, and made "create_midpoint.dll." When executed, the dialog is displayed and "get_point" asks the first point, and the second point, then makes a midpoint finally. Check box on/off works, too. It works as I expected. However, when I press OK button in the dialog, the dialog is gone, but "get_point" still keeps asking the first point. It even works without the dialog. If I hit "ESC" key, then "get_point" is gone. (Yes, I understand it is made that way.) In other words, if I press ESC key twice, both "get_point" and the dialog will be gone. Seems I don't need OK and CANCEL button in the dialog... Two questions. (1) Is there any way to finish both the dialog and "get_point" function at the same time? (If one of two is gone, then the other should also be gone, doesn't matter which one is first.) Maybe, I can put some routine near "TODO", but I don't know how to do it. -->This code snippet is from sample program Modeless dialog / Tracking mouse // Okay button command else if (event.m_type == EM_Command && event.m_command == IDOK) { // TODO: OnOk handling done = true; } // Cancel button command else if (event.m_type == EM_Command && event.m_command == IDCANCEL) { // TODO: OnCancel handling done = true; } (2) For X, Y coordinate readout, can I set the format? All I need is 5 places after decimal. Right now, number is too long. -->from MyModelessDialog.h enum { IDD = IDD_MyModelessDialog }; double m_p1_x; double m_p1_y; double m_p2_x; double m_p2_y; double m_mdp_x; double m_mdp_y; BOOL m_make_line; -->from MyModelessDialog.cpp DDX_Text(pDX, IDC_P1_X, m_p1_x); DDX_Text(pDX, IDC_P1_Y, m_p1_y); DDX_Text(pDX, IDC_P2_X, m_p2_x); DDX_Text(pDX, IDC_P2_Y, m_p2_y); DDX_Text(pDX, IDC_MDP_X, m_mdp_x); DDX_Text(pDX, IDC_MDP_Y, m_mdp_y); DDX_Check(pDX, IDC_MAKE_LINE, m_make_line); Any advice will be appreciated. Thank you.
  10. Roger, Hello. Thanks for your prompt reply. PUSHBUTTON "OK",IDOK,..,..,36,18,BS_BITMAP PUSHBUTTON "Cancel",IDCANCEL,..,..,36,18,BS_BITMAP I checked these two lines ,"...36,18,BS_BITMAP", in *.rc file, but they were OK. Problem still persists... class Cshapedlg : public MCDialog I checked "shapedlg.h", it was OK. BOOL Cshapedlg::OnInitDialog() { ... <-- skipped some lines //CDialog::OnInitDialog(); MCDialog::OnInitDialog(); Matching lines: 13 Matching files: 2 Total files searched: 12 Then, I searched a string "CDialog" in "shapedlg.cpp", and found it. Changed from "CDialog" to "MCDialog" and rebuild the program and tested. I saw both OK and Cancel Mastercam bitmaps! Problem solved. Find all "CDialog", Subfolders, Keep modified files open, Find Results 1, "Entire Solution" F:\Mastercam_C-hook_related2\shapes\shapedlg.cpp(66):// CDialog::DoDataExchange(pDX); F:\Mastercam_C-hook_related2\shapes\shapedlg.cpp(67): MCDialog::DoDataExchange(pDX); F:\Mastercam_C-hook_related2\shapes\shapedlg.cpp(179): //CDialog::OnInitDialog(); F:\Mastercam_C-hook_related2\shapes\shapedlg.cpp(180): MCDialog::OnInitDialog(); ... <-- skipped some lines Matching lines: 13 Matching files: 2 Total files searched: 12 To make sure whether or not there were some more "CDialog" exist in my entire solution, searched again. Yes, there were bunches of them. Well, I learned a lot this time, too. There is a will, there is a way. Thanks for your advice, really appreciated.
  11. Roger, Hello. Right, I will try to. A couple of things I would like to bring up. (1) I've been comparing your C-hook program and mine, and found why I had a problem with icons, (background color was black, so I had to invert color for shape), in List control. After modified the program, icons were displayed correctly. Problem has been solved. // m_shape_image.Create (32, 32, 0, 0, 8); <-- Original code from old Developer's Guide // c_shape_image.Create(32, 32, ILC_COLOR16 | ILC_MASK, 4, 1); <-- your original code. m_shape_image.Create(32, 32, ILC_COLOR16 | ILC_MASK, 4, 1); <-- renamed for my program icon[0] = AfxGetApp()->LoadIcon(IDI_RECTANGLE); icon[1] = AfxGetApp()->LoadIcon(IDI_OBROUND); icon[2] = AfxGetApp()->LoadIcon(IDI_SINGLE_D); icon[3] = AfxGetApp()->LoadIcon(IDI_DOUBLE_D); for (i = 0; i < N_SHAPES; i++) m_shape_image.Add (icon[i]); (2) A question about using "OK",IDOK(Button Control) and "Cancel",IDCANCEL(Button Control) in dialog. I'm trying to switch to OK, check mark in green, and Cancel buttons, cross in red, to Mastercam default bitmaps, but for some reason, it doesn't show bitmaps when executed. I'm sure I changed OK & Cancel button settings in each property page "Bitmap" to "True", and checked "Owner Draw" was set to "false." For a test, I made a C-hook program generated by C-hook Wizard, using Dialog sample program, there is no problem at all. I see Mastercam OK and Cancel bitmaps. I also made a C-hook program without a dialog, then manually added a dialog, and changed settings for OK and Cancel buttons, it works fine. I looked a *.h, *.rc and *.cpp files, but no luck... Am I still missing something? Thanks for your help and advice.
  12. Roger, Hello. Thanks for the e-mail and attached *.zip file. Wow, I was more than I expected that you would send me a whole C-hook project file. Unzipped, compiled/linked, everything is working just fine. It made me smile. Now, I can compare your program and mine, and I will see the difference, also learn ideal C-hook programming using MFC. Although I haven't checked in detail yet, I noticed right away that your were using "String Table." I was using string arrays and pointers, nothing fancy, typical "C" (not even C++) programming style. Again, thank you very much for your help every time, appreciated.
  13. Hello, all. Since my last post on 04/22/11, I've been working on another C-hook sample programs, "revctr" and "Shapes" from Developer's Guide, Ver. 9.0 (Beta 2). "revctr" was not so difficult because no GUI (dialog) was used. However, "Shapes" was really a tough one for me, I had to spend so many hours to make it work. On top of that, I'm new to MFC, so I had to learn basics of MFC concurrently. I'm reading a book "Introductions to MFC Programming with Visual C++", kind of old, targeted VC++6.0,but good for understanding the basics. It was just yesterday, "Shapes" finally started to work. No pain no gain, indeed... I have a couple of questions. (1) How do I use "m_notify" function in my C-hook program? In this case, I'm using repaint" and" fit", whenever I move my mouse a messagebox is displayed and asks to hit OK button. I know it is made so, but I even cannot do my operation because messagebox appears one after another, kind of pesky... If a message box goes away by itself in a second or two, maybe OK. Besides that, when a C-hook is done, come back to Mastercam, it seems "m_notify" still in memory, and keeps reacting. I could be wrong though... Here is the code snippet. extern "C" __declspec(dllexport) int m_notify (int notify_code) { MC_RETURN result = MC_NOERROR; switch (notify_code) { case MCEVENT_REPAINT: // result = HandleRepaint(); // ::MessageBox (NULL, (LPCTSTR)"Repaint", (LPCTSTR)"M_repaint", MB_OK | MB_ICONINFORMATION); break; case MCEVENT_FIT: // result = HandleFit(); // ::MessageBox (NULL, (LPCTSTR)"Fit screen", (LPCTSTR)"M_fit_screen", MB_OK | MB_ICONINFORMATION); break; } return MC_NOERROR; } (2) In "Shapes" dialog, icons are used. The original background color is green, but when my C-hook starts, it's black. I couldn't see the shape, so I inverted the color for the shape, but the background color stays black. Maybe, I just don't know how to edit color for background. I tried to insert image files, *.png, but not successful. -------------------------------------------------------------------------------------------------------------------- Roger, Hello. I would appreciate if you could give me some pieces of advice because "shapes.txt" file is not used anymore, so I modified the program my own way. I know you are busy, but if you could check/verify my "Shape" program, I can send it to you by e-mail, now I know which files I have to send, no more fat e-mail attachment(s). ------------------------------------------------------------------------------------------------------------------- Any advice will be appreciated. Thank you.
  14. Roger, Hello. Thanks for prompt reply. Tried and checked your advice using Cstring. For a time being, I will keep go on trying to familiarize C-hook programs. In fact, I've already found next C-hook project. To me, programming is just like solving a puzzle. If it's too easy, not much fun. If it's too difficult, loose interest, or hard to keep motivated. If a problem is just above my knowledge/skill, then a lot of satisfaction when solved a problem, and my program works just as expected, makes me addict, sort of... Thanks for your help and valuable advice.
  15. Roger, Hello. Good news. To make it short, VS 2008 compiled/linked and made a *.dll. Tested, it was a beauty. Thank you very much. I'm happy. Before finish it up, a few things... (1) Linker error ..."C"\Program.obj" --> fixed. Linker properties, Input, Additional Dependencies -> mastercam.lib mccore.lib mcmill.lib UICtrls.lib I set to like this: $(SDK_X5)\release\masetercam.lib, blah, blah... (It was working fine many times, but not this time.) (2) A question. If I want to display some data, e.g."max_n_spline_pts",in MessageBox, converted to string, is this OK? I searched on the internet and copied a code snippet,it works, but I'm not sure. There may be some other way, better way, to do that. Like ToString()? short max_n_spline_pts = CSplineNodeMgr::get_max_n_spline_pts(); // *ADDED* TCHAR str[255]; sprintf_s(str, (LPCTSTR)"value of max_n_spline_pts = %d", max_n_spline_pts); ::MessageBox (NULL, (LPCTSTR)str, (LPCTSTR)"max_n_spline_pts", MB_OK); if (n_pts > max_n_spline_pts) (3) *.prm fle locations are nice, too. I liked it. Well, it was little tough, but good experience for me. I learned a lot. Again, thanks for your help.

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