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

Jure Klemencic from Camincam's Achievements

Newbie

Newbie (1/14)

0

Reputation

  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.

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