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:

Jure Klemencic from Camincam

Verified Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by Jure Klemencic from Camincam

  1. I found a way to save your file if you get stuck in Mastercam reading the message: Exit current function before running new command. Function not responding to MC_EXITFUNC request. Please report error to dealer. You have to press Alt+A and you get the AutoSave dialog, from which you can save your current MCX. Afterwards you certainly have to kill Mastercam pressing Ctrl+Alt+Delete. I hope sometime this would help someone.
  2. I found a way to save your file if you get stuck in Mastercam reading the message: Exit current function before running new command. Function not responding to MC_EXITFUNC request. Please report error to dealer. You have to press Alt+A and you get the AutoSave dialog, from which you can save your current MCX. Afterwards you certainly have to kill Mastercam pressing Ctrl+Alt+Delete. I hope sometime this would help someone.
  3. Roger, thank you very much. Today I remembered that some time ago I was able to program code like this, but then I forgot a little... Your code works well. But the way you get the references to all entities seems a little odd to me. I've done it in an other (also odd way: code: public static int[] AllEntities() { CEntRef[] entList; int eptr; int[] allEnts = new int[10000]; int i = 0; int[] levels = Levels.GetVisibleLevels(); foreach (int level in levels) { entList = Levels.GetLevelEnts(level); foreach (CEntRef ent in entList) { eptr = ent.eptr; allEnts = eptr; i++; } } return allEnts; } I'll appreciate any comments to my code.
  4. Takashi, thank you. This code: Chain.ChainManager(opRef, chainRefs, 4, 0); works. I only tried it now, because when I asked this question (a year ago) I made a workaround myself. Now I faced this problem again and I had to solve it the right way. Bye.
  5. Hi, this must be a very simple question for programming in C# API 1.0: how to move all the objects to a given Level x? This is how I started: code: Mastercam.GUI.SelectAll(); Now what? Thanks.
  6. I have programmed a NetHook for Mastercam X MR2 in VS 2003. In this NetHook I used the method: code: Mastercam.Chain.ChainAll(false, false, false, geomLevel, true, chainRefs) to chain all the entities on level "geomLevel" and store the chain (it was always one single chain on geomLevel) in "chainRefs". The entities were chained in the order in which they were created. Therefore I was able to control the direction of the chain by the order of creation. As I updated this NetHook for Mastercam X2 MR2 in VS 2005 and NetHook 1.0 API I noticed that the chain direction didn't correspond to the order of creation any more. So I can't control the direction of my chain any more. Is there any other way to chain entities in the prefered direction? All the entities are created within the same NetHook so I have their (int) database pointers. I tried to use the method: code: Mastercam.Chain.ChainSomeEnts but was not successful. To conclude: I'm looking for any way to chain one chain in a known direction. Thank anyone for help.
  7. Thank you guys. I used this code: code: COperationRef opRef = new COperationRef(0); opRef.operationID = opID; opRef = new COperationRef(opRef.operationID); and now the .operationTool works fine. BUT it works only with mill operations. In fact I am interested in lathe operations. I guess I will have to combine my managed code with some unmanaged C++ code in order to reach lathe tools. I will try that in future. Now, I have questions concerning working with MS Excel. I find it easy to write strings to Excel, but I don't fully understand opening and closing XLS files. I used this code: code: Excel.OpenExcelFile("C:Test.XLS"); Excel.WriteExcelString("A1", "test"); Excel.SaveExcelFile("C:Test.XLS"); Excel.CloseExcelFile(); 1. Why don't I see any Excel window open? 2. Why is there still an Excel process in computer's memory after this code finishes. 3. How to start a new Excel file instead of opening the existing one? 4. How to start a macro in Excel? Thank you for your great help.
  8. Mike, I will try to answer you, but I can't debug my code so I don't see the values of my variables in every moment. 1. I don't know what the value of 'operationTool' is because whenever I try to reference it or ANY of its members, I get an error. If I say for example: code: opRef.operationTool.ToString() I get an error. 2. I am not checking if operationTool is null. 3. I can't access anything in the 'operationTool' (slot, diameter values, etc.), even not the 'operationTool' itself. Thanks for your help.
  9. Mike, thank you for your answer. According to it the .operationTool doesn't work as it should. This is my (shortened) code: code: public override MC_RETURN Run(int param) { (int[] opList = all selected operations) foreach (int opID in opList) { if (opID > 0) { COperationRef opRef = new COperationRef(0); opRef.operationID = opID; GUI.ShowString("comment " + opRef.comment); GUI.ShowString("operationTool.toolComment " + opRef.operationTool.toolComment); } } return (MC_RETURN.MC_UNLOADAPP); } When testing this code I always use a MCX file with clean Mill operations, all with regular tools. In this code the line opRef.comment works whereas the line opRef.operationTool.toolComment doesn't work. It results in this error window: That's it. Thank you again for your help.
  10. Please, help me to get to Tool members (properties) in NetHook 1.0 API in Mastercam X2 MR2. I thought: code: opRef.operationTool.<Tool Member> should work, but it doesn't. Thank you.
  11. Hi, I am here again with my "Lathe" questions. I know Nethook API is not intended to manage Lathe operations, but I got quite far with the old nethook.dll and I am trying to reprogram my NetHook for the new NETHook2_0.dll. Using nethook.dll I managed to import a lathe operation from an existing file: code: public static int MakeOperationFromName(string operationsFile, string opName, string geomLevel, int SS, bool reverseChain) { //Remember geometry level state and turn it on bool geomLevelVis = Levels.IsLevelVisible(geomLevel); Levels.SetLevelVisibleByName(geomLevel, true); //Chain all on this level ArrayList chainRefs = new ArrayList(); if (!Mastercam.Chain.ChainAll(false, false, false, geomLevel, true, chainRefs)) { //Reset geometry level state to remembered value Levels.SetLevelVisibleByName(geomLevel, geomLevelVis); return 0; } else { COperationRef opRef; opRef = COperationRef.ImportFromFile(operationsFile, opName); //Does operation exist in the operations file? if (opRef == null) throw new Exception("RouteLevel::COperationRef.ImportFromFile(" + operationsFile + ", " + opName.ToString() + ") not found!!!"); //Predefine spindle speed for it to work. opRef.spindleSpeed = 0; opRef.spindleSpeed = SS; opRef.isSelected = true; if (Chain.ChainManager(opRef, chainRefs, 1, 0)) { if (!Toolpath.RegenOp(opRef)) throw new Exception("Call to RouteLevel::RegenOp() on level " + geomLevel + " failed!!!"); } else throw new Exception("Call to RouteLevel::Chain.ChainManager() on level " + geomLevel + " failed!!!"); if (chainRefs.Count > 0) { if (!Mastercam.Chain.FreeChains(chainRefs)) throw new Exception("Call to RouteLevel::FreeChains() on level " + geomLevel + " failed!!!"); } //Reset geometry level state to remembered value Levels.SetLevelVisibleByName(geomLevel, geomLevelVis); return opRef.operationID; } } , but using the new NETHook2_0.dll I can't do that: code: Operation opImp = OperationsManager.ImportOperation("C:JureOPS.MCX", "MyOperation"); ChainBasedOperation opChBas = (ChainBasedOperation)opImp; opChBas.Chains = ChainManager.ChainAll(false, false, 1); opChBas.Commit(); opChBas.Regenerate(); This code works if MyOperation is a Mill operation and does not work if MyOperation is a Lathe operation. In the latter case I get this message: Unhandled Exception: System.NullReferenceException - Object reference not set to an instance of an object If there is really no way to work with Lathe operations using NETHook2_0.dll, could I somehow write only this segment of code in the old nethook.dll. If not, then I know it is possible to combine NetHook with C++. Please, help! And thank you very much.
  12. Please, don't tell me there's no method to draw fillets in Nethook2_0 API?! If it has really gone, then I would appreciate any code or instructions how to draw a fillet between two wire objects. At least a simple 2D fillet between two 2D lines? Thank you very much.
  13. This works perfectly! Thank you, I am doing fine. I didn't program Nethooks for quite some time. Now I am afraid I will get stuck and will not be able to update all of my old code. It seems some good old commands are missing in the Nethook2_0 (please see also my other recent posts).
  14. Is there a method to get the Mastercam directory (e.g. c:McamX2-MR1) in the Nethook2_0 API? In the old Nethook API this method was called "Mastercam.GUI.GetMCRootDir()". Thank you.
  15. Hi again, I am trying to update my C# NetHook for lathe parametrical programming from Nethook API to Nethook2_0 API. Since a lot of commands are different I started to write the whole code anew. Nevertheless I got into trouble: The methods of Mastercam.Database.Operation work only with Mill, but don't work with Lathe. I tried these: .GetOperationID() and .ToolDisplayOn. I am sure there must be a workaround, could somebody help me, please?
  16. Mike, Thank you, I got the examples now. Please say a word more about the "Extranet developer's page". I do have access to Extranet, but I don't see 'Developer' menu there. Can you explain why and what to do to get it displayed? Thank you for the answer.
  17. Mike, I was very happy to see that 2.0 API examples are available. I downloaded the file NetHook_2.0_SP1.zip from Downloads section of Mastercam.com: http://www.mastercam.com/Support/Downloads/Misc/Default.aspx, but this is the new version of API not the examples. Please, explain once again, where can I get the examples. I do have access to Extranet, but I don't see 'Developer' menu there. Thank you, I'm desperately waiting for new examples...
  18. Mick, this is called HELP! I think I got "the brand new database system" and I think I will like it. I don't know why you mentioned "scoping issue", because the translate method works well in my NetHook. I added this line: code: line1.Translate(TranslationMode.Copy, pt1, pt2, 1, 1); to your code and on my computer it works just fine. In the next days I won't bother with basic questions any more, but after a while I will have some hard ones for sure. Till then, have a nice time!
  19. Mike, thank you again. You are really very helpful. I understood: It isn't possible to mix the two APIs. All the old NetHooks will have to be rewritten for the new API NH 2.0. I tried out the HelloWorld code you provided and at first it didn't work. After I added Mastercam.IO. into the line to become: code: Mastercam.IO.DialogManager.OK("Hello World!!", "Hello World App"); it worked well. Then I added another line: code: Mastercam.IO.SelectionManager.SelectAllGeometry(); which also worked. But I can't imagine why I can't translate the selected objects now: code: Mastercam.Database.Geometry.Translate( ... ) (doesn't work.) I know I can use Object Browser to explore the API and right there I can see the method Mastercam.Database.Geometry.Translate, which I cannot use. Neither can I draw one single line... I bet you already guessed, what I will say now: "Please, help!" If you think it is necesary to learn "the brand new database system", please start with that.
  20. Mike, thank you for your kind reply. Could you be a little more clear, please: If NetHook 1.0 API is intended for backwards compatibility, is it possible to include both .DLLs in the same project? This would enable the programmer to keep the old code and to develop it further. I have asked for documentation because I tried to use the simplest method using NetHook 2.0 API, but I didn't succeed. At this point I actually don't urgently need any documentation, only one single but complete example of C# NetHook code. Therefore, I kindly request you to provide this example, preferably including the method: Mastercam.Database.Geometry.Translate. Thank you for your answer
  21. Hello, starting to use Mastercam X2 I would also like to make the transition from VS 2003 to VS 2005. If I use the new nethook.dll everything works fine, but I don't see any point, because there is nothing new in nethook.dll, is there? On the other hand, if I use the new NETHook2_0.dll, my old code doesn't work any more and updating is quite demanding. Besides, I couldn't find any documentation about the new NETHook2_0.dll (all documentation available in fact refers to nethook.dll). To conclude, I would like to solve two problems: 1. How to update my old .NET (C#) programs to get the ability to use new functions (is it possible to include both nethook.dll and NETHook2_0.dll in the same project)? 2. How to use the new NETHook2_0.dll? Is there really no documentation / examples of (C#) code available? Thank the one who answers very much.
  22. Mike Crivello, thank you for your answer. I have already lost my patience and the topic has lost its label "urgent". I know Lathe is not so well supported, but I am already fairly deep in .NET programming for lathe, which is important to me. So I appeal to CNC Software to improve the .NET support for lathe in the future. This is the requested code for the method to make an operation: code: public static int MakeOperationFromName(string operationsFile, string opName, int geomLevel, int SS, bool reverseChain) { //Chain all on this level ArrayList chainRefs = new ArrayList(); if (!Mastercam.Chain.ChainAll(false, false, true, geomLevel, true, chainRefs)) return 0; else { COperationRef opRef; opRef = COperationRef.ImportFromFile(operationsFile, opName); //Does operation exist in the operations file? if (opRef == null) throw new Exception("RouteLevel::COperationRef.ImportFromFile(" + operationsFile + ", " + opName.ToString() + ") not found!!!"); //Predefine spindle speed in order for it to work opRef.spindleSpeed = 0; opRef.spindleSpeed = SS; if (Chain.ChainManager(opRef, chainRefs, 1, 0)) { if (reverseChain) foreach (CChainRef cr in chainRefs) { if (!Chain.ReverseChain(cr)) throw new Exception("Call to RouteLevel::Chain.ReverseChain() failed on level " + geomLevel + "!!!"); } if (!Toolpath.RegenOp(opRef)) throw new Exception("Call to RouteLevel::RegenOp() on level " + geomLevel + " failed!!!"); } else throw new Exception("Call to RouteLevel::Chain.ChainManager() on level " + geomLevel + " failed!!!"); if (chainRefs.Count > 0) { if (!Mastercam.Chain.FreeChains(chainRefs)) throw new Exception("Call to RouteLevel::FreeChains() on level " + geomLevel + " failed!!!"); } return opRef.operationID; } } The operation is created, but the direction of its chain is always the same, regardless of the value of the bool reverseChain parameter. Please, don't hesitate to ask for additional information, since your help means a lot to me. Thank you.
  23. Hello, I am writing a NET-Hook for Mastercam X MR2 Lathe. How to reverse a chain for an operation (Chain.ReverseChain as used in this http://www.emastercam.com/ubb/ultimatebb.p...c;f=13;t=000238 post does not work in my case). Please help, I urgently need the answer to my problem. Thank you.
  24. Hi, I also have some questions about COperationRef.ImportFromFile method, which I use with Mastercam X MR2 Lathe: 1. The parameter Spindle Speed does not import from operations file like other parameters. It remains zero and must be set manually. How could I import it from an operation? 2. How to import miscellaneous operation Stock Transfer or at least set its parameters? 3. How to reverse chain in an operation (Chain.ReverseChain as used in this http://www.emastercam.com/ubb/ultimatebb.p...c;f=13;t=000238 post does not work in my case). Thank you for an answer to 1., 2. or 3.!

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