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:

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

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