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:

Automatic tool creation


Recommended Posts

Hi,

 

how do I know if the tool already exists in my part file or in a library?

 

Can I search for tools in a tool library and use them for NET-Hook-created operations?

Or at least decide if a tool already exists in my current part file and use it, if present?

 

Here is the code I use to create contour operations:

 

FlatMill = new Mastercam.Tools.EndMillFlatTool();  
FlatMill.Diameter = 2;
FlatMill.Name = "FlatMill2";
if (!FlatMill.Validate())       //Isn't that supposed to
{                               // check if the tool is already present?
FlatMill.Commit();             // But the tool is created regardless
}                               // Plus: some other tools appear and I don't know why
Op.OperationTool = FlatMill;
. //chaining and assigning 
. //depth, feed and speed
Op.Commit();
Op.Regenerate();

Actually I am reading layer and tool information from a text file.

All geometry on a certain layer gets chained and I want to create the tool only if necessary.

But when a tool has to be used twice, it will appear twice in the text file, on different lines, of course.

And the above code will store that tool twice.

Isn't Validate() like I used it here supposed to check this?

How do I avoid it?

 

And if I get around this:

How can I then re-use that tool in another Operation in the same part file?

 

My favourite method would use tools from a tool library, but that does not seem to be possible, or is it?

 

Sorry, I'm still quite unfamiliar with NET-Hooks.

Link to comment
Share on other sites

I hadn't tried Validate; I was under the impression that it worked hand-in-Hand with .Commit (for instance, if you raised an Exception)

I had also unsuccessfully tried the EQUALS Function with a Tool Object that was yet to be commited to the DataBase.

 

What I was trying to do at that time, was to nail down *which* of my multiple Tool #1's were the Tool #1 that was actually being used in an Operation.

Link to comment
Share on other sites

The <object>.Validate() in the NETHook checks to see if the object being validated is already in Mastercam's database.

This is *not* "duplicate" checking.

This type of "Validate" is used in many places; on geometry objects; points, lines, arcs, etc...

 

Your Tool object in your NETHook may only exist in your NETHook, which is true until you .Commit() it.

The .Commit() does the actual "add this object" into Mastercam's database.

 

Another way thinking about this is to consider the example of ArcGeometry object.

You can create one in your NETHook, but until you .Commit() it, it does not exist in Mastercam.

So now you .Commit() your ArcGeometry object...

Doing a Validate() on this ArcGeometry object after you .Commit() will tell you that "that specific object" already exists in Mastercam.

That would not stop you from creating another ArcGeometry object with the exact same data and doing a .Commit() on this new object ->

which would create a duplicate arc in Mastercam's database.

*Duplicate here means "the same data", not the exact same object.

Link to comment
Share on other sites

Well,

 

I solved it by pre-reading the textfile and creating an array which then holds every tool once.

But still:

every time I call

 

 DrillOperation drlop = new DrillOperation();

or

 ContourOperation ctrop = new ContourOperation();

 

an extra tool with random(default?) parameters is created.

 

They are not used in any operation, but it's irritating to have loads of them lurking around.

 

Why is that?

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