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

Everything posted by TJ00_SH

  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.
  16. Roger, Hello. Received your e-mail and attached *.zip file. Thank you very much. Also, thanks for tips for sending *.zip file, appreciated. Let me try it, and I will get back to you as soon as possible. Thanks again,
  17. Roger, Hello. Sent two e-mails with attached *.zip files. Thank you.
  18. Roger, Hello. OK, I will send an e-mail with attached .zip file this evening. In fact, I've been working on C-hook program at home. (can't make time at work...) Thank you.
  19. Roger, Hello. Thanks for your prompt reply. I modified main.cpp as instructed. Compiled for X5 MU1, (and X4 MU3 for a test, too). (1) Added #include "CSplineNodeMgr_CH.h" -> done. (2) short max_n_spline_pts = get_max_n_spline_pts(); -> done. It was strange, even though I added CSplineNodeMgr_CH.h, an error message ".\main.cpp(122) : error C3861: 'get_max_n_spline_pts': identifier not found" was displayed. So, I changed it to "short max_n_spline_pts = CSplineNodeMgr::get_max_n_spline_pts();", then it was OK. (3) pts = (p_3d *) MALLOC (n_pts, sizeof(p_3d)); -> done. if( pts == (p_3d *)NULL) -> done. (4) .\main.cpp(174) : warning C4002: too many actual parameters for macro 'MALLOC' was displayed.-> warning. (5) LINK : fatal error LNK1181: cannot open input file 'C:\Program.obj' was displayed. (F.Y.I. If compiled for X4, this error message was not displayed. It made a .dll, but when executed, I didn't see any helical curve on screen. -> forget about this for now.) Checked Microsoft Support, and they say: To work around this problem, include the drive name for the Intermediate file folder and for the Output file folder. To edit the entries for the IntDir folder or for the OutDir folder, follow these steps: 1. On the Project menu, click Properties Pages. 2. In the Properties Pages dialog box, click Configuration Properties. 3. In the General list, type new entries for the Output Directory items and for the Intermediate Directory items that include the drive names. Currently, my Configuration Properties set to $(ConfigurationName). How do I have to change this setting to? $(SDK_X5)? Sorry, I tried to make my questions organized, but it looks like a mess. Thanks for your great help, appreciated.
  20. Roger, Hello. I tried it. I used "CHookSample" for a test. It worked fine, but I need more practice. Feel like I don't get the grip... I printed all files,*.cpp and *.h, both old(as-is from 2006) and new(made from CHook Wizard), and compared them one by one, (side by side). The difference was clear at a glance. Since I don't have many 'old' sample programs, except ones from Developer's Guide, I'd rather make a base, or skeleton, program, then port necessary code from the old program. For a try out, I chose "Thelix.c" from very old Developers Guide,Version 9.0 (Beta2) 2001. It was 2004, when I started to learn C-hook for the first time. (I couldn't make it,just gave up...) Of course, there were many errors when compiled for the first time, then I tried to eliminate them as much as I could. However, these two errors I couldn't get rid of, I looked at C-hook help file, but no luck. Could you tell me what's wrong with it? Here is the whole code, (main.cpp). Some lines commented out were deleted. // main.cpp for Masa_helix // C-Hook code generated by CHookWizard // (c) Copyright 2011, CNC Software, Inc. // All rights reserved. // #include "stdafx.h" #include "m_core.h" #include "m_mastercam.h" #include "Masa_helix.h" // GetChookResourceHandle() static real radius = 1.0; static real theta0 = 0.0; static real d_theta = 5.0 * D2R; static real n_rev = 1.0; static real dz_per_rev = 0.1; static real taper_angle = 0.0; static char TXT_HDR[] = "thelix"; static char prm_header[] = "thelix"; //static char thelix_prm_name[FILENAME_MAX] = "thelix.prm"; static char thelix_prm_name[FILENAME_MAX] = "F:\\Mastercam_C-hook_related2\\Masa_test05\\new_CHookNotify_Projects\\Masa_helix\\thelix.prm"; static boolean params_set = FALSE; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern "C" __declspec(dllexport) int m_version (int version) { int ret = C_H_VERSION; // This allows the C-Hook to run in any version of Mastercam // that has the same major version if ( (version / 100) == (C_H_VERSION / 100) ) ret = version; return ret; } /* __________ get_defaults __________ Purpose: Read the default values from THELIX.PRM if it exists */ static void get_defaults (void) { char fname[FILENAME_MAX] = "F:\\Mastercam_C-hook_related2\\Masa_test05\\new_CHookNotify_Projects\\Masa_helix\\thelix.prm"; FILE *f; /* First set default values in case the parameter files does not exist */ rd_param_open (thelix_prm_name, prm_header, params_set, &f); rd_param (f, "%lf", 1, &radius); rd_param (f, "%lf", 2, &theta0); rd_param (f, "%lf", 3, &d_theta); rd_param (f, "%lf", 4, &n_rev); rd_param (f, "%lf", 5, &dz_per_rev); rd_param (f, "%lf", 6, &taper_angle); params_set = TRUE; FCLOSE (f); // ::MessageBox (NULL, (LPCTSTR)"File read end", (LPCTSTR)"get_defaults", MB_OK); } /* __________ save_defaults __________ Purpose: Write the default values into THELIX.PRM */ static void save_defaults (void) { FILE *f; params_set = TRUE; wr_param_start (thelix_prm_name, prm_header, &f); if (f == NULL) return; wr_param (f, "%lf", 1, radius); wr_param (f, "%lf", 2, theta0); wr_param (f, "%lf", 3, d_theta); wr_param (f, "%lf", 4, n_rev); wr_param (f, "%lf", 5, dz_per_rev); wr_param (f, "%lf", 6, taper_angle); FCLOSE (f); // ::MessageBox (NULL, (LPCTSTR)"File write end", (LPCTSTR)"save_defaults", MB_OK); } static void make_thelix (void) { // boolean succf=false; MC_BOOL succf; char pt_opt; short i=0; short n_pts=0; real x, y, z; real theta, a, dz, dr, r, tan_taper_angle; DB_LIST_ENT_PTR d_ptr; //db_ptr_type d_ptr; // --> Now what is it?? 04/16/11 m. p_3d helix_center; // center point in world coordinates p_3d *pts; p_3d dum; /* Read defaults */ get_defaults (); /* Get values for number of revolutions, radius, incremental angle, pitch and taper angle */ get_real (TXT_HDR, &radius, &succf); if (!succf) return; get_angle (TXT_HDR, &theta0, &succf); if (!succf) return; get_angle (TXT_HDR, &d_theta, &succf); if (!succf) return; get_real (TXT_HDR, &n_rev, &succf); if (!succf) return; get_real (TXT_HDR, &dz_per_rev, &succf); if (!succf) return; get_angle (TXT_HDR, &taper_angle, &succf); if (!succf) return; while (TRUE) { cleartextall(); // write_msg (TXT_HDR, m_11); point_proc ("", &pt_opt, helix_center, &succf); if (!succf) break; cleartextall(); // write_msg (TXT_HDR, m_9); tan_taper_angle = sin (taper_angle) / cos (taper_angle); n_pts = round (n_rev * TWO_PI / d_theta) + 1; if (n_pts > max_n_spline_pts) { // post_warning (TXT_HDR, m_8); return; } pts = MALLOC (n_pts * sizeof (p_3d)); if (pts == NULL) { // post_warning (TXT_HDR, m_10); return; } theta = theta0; a = dz_per_rev / TWO_PI; /* Compute points on the helix and write to the ascii file */ for (i = 0; i < n_pts; i++) { dz = a * (theta - theta0); dr = tan_taper_angle * dz; r = radius + dr; x = r * cos (theta); y = r * sin (theta); z = dz; if(constr_view_n <= 1) vec_3d (x, y, z, pts[i]); else { vec_3d (x, y, z, dum); view_to_world(dum, constr_view_n, pts[i]); } v_add_3d (pts[i], helix_center, pts[i]); theta += d_theta; } make_spline_from_pts (pts, n_pts, main_color, main_level, 1, dum, 1, dum, FALSE, &d_ptr, &succf); FREE (pts); clean_pt (pt_opt, helix_center); } save_defaults(); // ::MessageBox (NULL, (LPCTSTR)"function make_thelix end", (LPCTSTR)"make_thelix", MB_OK); } 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()); make_thelix (); // ::MessageBox (NULL, (LPCTSTR)"Masa_helix END", (LPCTSTR)"Masa_helix", MB_OK); return MC_NOERROR; } Here is the error message from VS C++ 2008. StdAfx.cpp Masa_helix.cpp main.cpp .\main.cpp(157) : error C2065: 'max_n_spline_pts' : undeclared identifier .\main.cpp(162) : error C2440: '=' : cannot convert from 'void *' to 'p_3d (*)' Conversion from 'void*' to pointer to non-'void' requires an explicit cast Build log was saved at "file://f:\Mastercam_C-hook_related2\Masa_test05\new_CHookNotify_Projects\Masa_helix\Release\BuildLog.htm" Masa_helix - 2 error(s), 0 warning(s) ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== Thanks for your help, appreciated.
  21. Roger, Hello. To be honest with you, I flinched a little when I read it first time. OK, I will try it this weekend. Thanks for your help,
  22. Roger, Hello. It worked, thanks for your help every time. I'm happy. By the way, are there any newer sample code for "Extension style" DLLs? If so, it would be very nice. Thank you.
  23. Mr. A. Lapointe, Hello. Thanks for your advice, appreciated. What I wanted to do was to change NC file name, (nci name), of Toolpath Group and operations under the group. My colleague said that one of X+ Tool, chgnci.dll, from GMCCS was exactly what we, (my colleague and I), were looking for. Although chgnci.dll will take care of daily job, I still want to make C-hook or NetHook program(s) myself. Thank you.
  24. Hi, All. Using VS C++ 2008. I'm testing a sample project "CHookNortify" from Developer's Guide. Made it by C-hook Wizard first. (If converted old source code to VS 2008, there were more errors!) When made it as a "do-nothing C-hook", merely displaying a message box, it works fine. Then, I added code for "CHookNortify" copied from Developer's Guide, and compiled. Seems compiling process is OK, but when linking, I see the following errors. I thought these errors were from VS 2008, so I added "/FORCE:MULTIPLE" in "Command Line" in property pages for Linker. It compiled and linked, and even made a .dll, but when executing the C-hook, an error message "Failed to initialize COM!" displayed. ------ Build started: Project: CHookNortify, Configuration: Release Win32 ------ Linking... mfcs90.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in CHookNortify.obj Creating library Release\CHookNortify.lib and object Release\CHookNortify.exp Release\CHookNortify.dll : fatal error LNK1169: one or more multiply defined symbols found Build log was saved at "file://f:\Mastercam_C-hook_related2\Masa_test04\CHookNortify\Release\BuildLog.htm" CHookNortify - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== How can I correct these errors? As a matter of fact, I've been struggling for this for two days... Any advice will be appreciated. Thank you.
  25. Roger, Hello. Thanks for your help every time. Downloaded and installed VS 2008 SP1, and tried it again. Beautiful. It compiled as if it didn't remember my problems... Thanks again,

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