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:

NetHook2Example / ArcClassesExample / Error


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

That specific ArcGeometry constructor (passing an Arc3D as the parameter) does not work properly in the NETHook v2.

This was corrected in the NETHook2_0 API and NETHook3_0 API that ships with X7.

 

The data in the ParamArc being passed to the ArcGeometry constructor looks OK.

Centerpoint = X0, Y0, Z0

Radius = 1.0

Start Angle = 0.0

EndAngle = 90.0

 

But a 'valid' ArcGeometry object (NewArcGeom) is not getting properly initialized.

Thus the "Zero length error" when you attempt to Commit that object. ;(

 

You can just use any of the other methods of constructing an ArcGeometry object and you should be OK

 

Please note that the NETook2_0 is "frozen".

All future updates to the .NET API will be in the NETHook3_0 only.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Sorry for the confusion of terms.

When I say NETHook v2, that is the same as NETHook2_0.DLL (the v2 of the NETHook API)

 

The reason you see an error is that you are running X6 (any MU#)

 

There is not an SDK like the for CHooks, as you already have everything in the NETHook2_0.DLL (or the NETHook3_0.DLL)

Those are "the .NET API".

 

The NETHook3_0.DLL that ships with X7 is the new "version 3" of the .NET API

Lots of new functionality in this new v3 .NET API for Mastercam.

 

I hope that answers your questions for now, as I'll be "offlline" until later this month.

I'm at JFK and my flight leaves in an hour for the other side of the world.

Where I'll have no internet, no phone, no TV, nothing from the outside.

Now that's what I call a vacation! :)

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