Author Topic: eNotApplicable Exception...  (Read 10965 times)

0 Members and 1 Guest are viewing this topic.

troga

  • Guest
eNotApplicable Exception...
« on: June 23, 2009, 04:04:40 PM »
Hi ,

I´m struggeling with an exception, in the following situation:
1. ACAD 2009
2. NET command for modifying polylines
3. Adding vertices via AddVertexAt(...) to a newly created polyline, after finishing, I´m using a transaction to write the poly to the DB, after that
    I´m trying to receive a PromptPoint from User to work on with the newly created poly ... after calling ed.GetPoint(...) I get an exception-> eNotApplicable ???

Q: What doe s that  mean ? I tried to lock the doc, changed the CommandFlags but nothing seemed to help... Anyone can help me out ?

NOTE: The exception occurs only on some *.DWG files !! I couldn´t figure out where the difference is .. :-(


Any help is appreciated...  and Thanks in advance.

Glenn R

  • Guest
Re: eNotApplicable Exception...
« Reply #1 on: June 23, 2009, 04:34:14 PM »
Without more information, members would only be guessing.

When posting, to get the maximum chances of people responding, you should provide the following:

1. Code
2. Example data
3. AutoCAD version
4. .NET Framework version
5. OS (including 32bit vs. 64bit)
6. Visual Studio version (or your IDE choice and version)

With no more info than what you've supplied, I would only be guessing; is the GetPoint call inside your transaction for the newly created polyline?

troga

  • Guest
Re: eNotApplicable Exception...
« Reply #2 on: June 23, 2009, 04:48:48 PM »
Without more information, members would only be guessing.

When posting, to get the maximum chances of people responding, you should provide the following:

1. Code
2. Example data
3. AutoCAD version
4. .NET Framework version
5. OS (including 32bit vs. 64bit)
6. Visual Studio version (or your IDE choice and version)

With no more info than what you've supplied, I would only be guessing; is the GetPoint call inside your transaction for the newly created polyline?

First, thanks for the fast reply...

1. will apply tomorrow... currently @home
2. ... like no. 1 ...
3. ACAD 2009
4. Vista 32 Bit
5. Visual Studio 2005
6. Yes it´s inside the transaction...

Thanks, I´ll provide the rest of the data tomorrow...

troga

  • Guest
Re: eNotApplicable Exception...
« Reply #3 on: June 23, 2009, 04:56:46 PM »
Code: [Select]
[code][quote author=troga link=topic=29269.msg348168#msg348168 date=1245790128]
[quote author=Glenn R link=topic=29269.msg348164#msg348164 date=1245789254]
Without more information, members would only be guessing.

When posting, to get the maximum chances of people responding, you should provide the following:

1. Code
2. Example data
3. AutoCAD version
4. .NET Framework version
5. OS (including 32bit vs. 64bit)
6. Visual Studio version (or your IDE choice and version)

With no more info than what you've supplied, I would only be guessing; is the GetPoint call inside your transaction for the newly created polyline?
[/quote]

First, thanks for the fast reply...

1. will apply tomorrow... currently @home
2. ... like no. 1 ...
3. ACAD 2009
4. Vista 32 Bit
5. Visual Studio 2005
6. Yes it´s inside the transaction...

Thanks, I´ll provide the rest of the data tomorrow...
[/quote]

ok, found a copy of the code :-)

                AcGe.Matrix3d ucs = _Ed.CurrentUserCoordinateSystem;
                AcGe.Point3d origin = new AcGe.Point3d(0, 0, 0);
                AcGe.Vector3d normal = new AcGe.Vector3d(0, 0, 1);
                normal = normal.TransformBy(ucs);

                AcGe.Plane plane = new AcGe.Plane(origin, normal);
                AcDb.Polyline pline = new AcDb.Polyline(points.Count);
                pline.Normal = normal;
                foreach (AcGe.Point3d pt in points)
                {
                    AcGe.Point3d transformedPt = pt.TransformBy(ucs);
                    pline.AddVertexAt(pline.NumberOfVertices, plane.ParameterOf(transformedPt), 0, 0, 0);
                }

                using (AcDb.Transaction tr = _Tm.StartTransaction())
                {
                    AcDb.BlockTable bt = (AcDb.BlockTable)tr.GetObject(_Db.BlockTableId, AcDb.OpenMode.ForRead);
                    AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(bt[AcDb.BlockTableRecord.ModelSpace], AcDb.OpenMode.ForWrite);
                    AcDb.ObjectId plineId = btr.AppendEntity(pline);
                    tr.AddNewlyCreatedDBObject(pline, true);
                    tr.Commit();

                    AcEd.PromptPointOptions opts = new AcEd.PromptPointOptions("\nPlease select direction: ");
                    opts.UseBasePoint = true;
                    opts.BasePoint = points[0];
                    AcEd.PromptPointResult result = _Ed.GetPoint(opts);
                    if (result.Status == AcEd.PromptStatus.OK)
                        tempPt = result.Value;
                    else
                    {
                        return;
                    }
                }
[/code]

also the message:
utodesk.AutoCAD.Runtime.Exception: eNotApplicable
   bei Autodesk.AutoCAD.Runtime.Interop.ThrowExceptionForErrorStatus(Int32 errorStatus)
   bei AcMgUserInteraction.{ctor}(AcMgUserInteraction* , AcApDocument* pDoc, Boolean prompting)
   bei Autodesk.AutoCAD.EditorInput.Editor.DoPrompt(PromptOptions opt)
   bei Autodesk.AutoCAD.EditorInput.Editor.GetPoint(PromptPointOptions options)
   bei MM_MechanicalSheet.MechanicalSheet.FoilBend()
   bei Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   bei Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   bei Autodesk.AutoCAD.Runtime.CommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
   bei Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

and attached a sample DWG

Glenn R

  • Guest
Re: eNotApplicable Exception...
« Reply #4 on: June 23, 2009, 04:57:46 PM »
Your numbered points are out - you still don't specify .NET Framework version.

Off the top of my head, move the GetPoint call outside the transaction ie. Create poly, add to dbase, commit, then start another transaction for the GetPoint and see how that goes.

Glenn R

  • Guest
Re: eNotApplicable Exception...
« Reply #5 on: June 23, 2009, 05:01:27 PM »
That's not the whole code and your error message to me indicates something else is possibly wrong...

troga

  • Guest
Re: eNotApplicable Exception...
« Reply #6 on: June 23, 2009, 05:09:00 PM »
That's not the whole code and your error message to me indicates something else is possibly wrong...

ok, let´s try again: I use .Net 2.0 and that is  the whole routine:

Code: [Select]

        [AcRx.CommandMethod("FOILSHEET")]
        public static void FoilBend()
        {
            _isMetal = false;
            AcIn.AcadDocument doc = GetDoc();
            doc.Layers.Add(Configuration._foilsheetLayer);

            showMainFoilOptionsDialog();

            AcGe.Point3d tempPt = new AcGe.Point3d();
            SteelplateJig spj = new SteelplateJig();
            AcGe.Point3dCollection points = spj.Run();
            if (points.Count == 0 || points.Count < 2)
                return;
            else
            {
                AcGe.Matrix3d ucs = _Ed.CurrentUserCoordinateSystem;
                AcGe.Point3d origin = new AcGe.Point3d(0, 0, 0);
                AcGe.Vector3d normal = new AcGe.Vector3d(0, 0, 1);
                normal = normal.TransformBy(ucs);

                AcGe.Plane plane = new AcGe.Plane(origin, normal);
                AcDb.Polyline pline = new AcDb.Polyline(points.Count);
                pline.Normal = normal;
                foreach (AcGe.Point3d pt in points)
                {
                    AcGe.Point3d transformedPt = pt.TransformBy(ucs);
                    pline.AddVertexAt(pline.NumberOfVertices, plane.ParameterOf(transformedPt), 0, 0, 0);
                }

                using (AcDb.Transaction tr = _Tm.StartTransaction())
                {
                    AcDb.BlockTable bt = (AcDb.BlockTable)tr.GetObject(_Db.BlockTableId, AcDb.OpenMode.ForRead);
                    AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(bt[AcDb.BlockTableRecord.ModelSpace], AcDb.OpenMode.ForWrite);
                    AcDb.ObjectId plineId = btr.AppendEntity(pline);
                    tr.AddNewlyCreatedDBObject(pline, true);
                    tr.Commit();

                    AcEd.PromptPointOptions opts = new AcEd.PromptPointOptions("\nPlease select the direction: ");
                    opts.UseBasePoint = true;
                    opts.BasePoint = points[0];
                    AcEd.PromptPointResult result = _Ed.GetPoint(opts);
                    if (result.Status == AcEd.PromptStatus.OK)
                        tempPt = result.Value;
                    else
                    {
                        return;
                    }
                }
            }
            //
            // sve the point for later usage
            double[] directionPt = tempPt.ToArray();
            double dirAngle = getLinesAngle(points[1].ToArray(), points[0].ToArray(), directionPt);
            _isMid = System.Math.Abs(dirAngle) < .01;
            if (!_isMid)
                _movingLeft = dirAngle < 0;
            if (points != null && points.Count != 0)
            {
                AcIn.Common.AcadPolyline pl = null, polyLeft = null, polyRight = null;
                createOffset(doc, points, directionPt, out pl, out polyLeft, out polyRight, true);
                if (pl == null || polyLeft == null || polyRight == null)
                    return;

                try
                {
                    loadLinetype(doc);
                }
                catch (System.Exception ex)
                {
                    string msg = "Error in loading linetype: " +
                        ex.Message.ToString() + "Stack: " + ex.StackTrace;
                    Debug.Assert(true, msg);
                }

                string lt2 = "ACAD_ISO03W100";
                if (Configuration._lineTypeName != String.Empty)
                    lt2 = Configuration._lineTypeName;

                pl.Layer = Configuration._foilsheetLayer;
                pl.Lineweight = AcIn.Common.ACAD_LWEIGHT.acLnWt100;
                pl.color = AcIn.Common.ACAD_COLOR.acByLayer;

                polyLeft.Linetype = lt2;
                polyLeft.Layer = Configuration._foilsheetLayer;
                polyLeft.ConstantWidth = Configuration._selectedSheetWidth;
                polyLeft.color = AcIn.Common.ACAD_COLOR.acByLayer;
                polyLeft.Lineweight = AcIn.Common.ACAD_LWEIGHT.acLnWt100;

                polyRight.Layer = Configuration._foilsheetLayer;
                polyRight.Lineweight = AcIn.Common.ACAD_LWEIGHT.acLnWt100;
                polyRight.color = AcIn.Common.ACAD_COLOR.acByLayer;
            }
        }


Thanks Glen for your patience  :wink:  !!

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: eNotApplicable Exception...
« Reply #7 on: June 23, 2009, 06:23:36 PM »


Where is this defined

_Ed.


don't have tiime to have a good look, but
Have you tried setting a breakpoint in the debug code and then stepping through to find the error
... or indicate to us the line the error is on when the exception happens.

looks like a COM error to me ..   :|

///kdub
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: eNotApplicable Exception...
« Reply #8 on: June 23, 2009, 06:29:57 PM »
looks like there is a lot more going on that you originally indicated ..

I assume the AcIn.  is Interop ??

            AcIn.AcadDocument doc = GetDoc();
            doc.Layers.Add(Configuration._foilsheetLayer);

where is this coming from (Configuration._foilsheetLayer)  

Where is this coming from
SteelplateJig


/// kwb
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

troga

  • Guest
Re: eNotApplicable Exception...
« Reply #9 on: June 24, 2009, 03:53:30 AM »
looks like there is a lot more going on that you originally indicated ..

I assume the AcIn.  is Interop ??

            AcIn.AcadDocument doc = GetDoc();
            doc.Layers.Add(Configuration._foilsheetLayer);

where is this coming from (Configuration._foilsheetLayer)  

Where is this coming from
SteelplateJig


/// kwb

Hi kdub,

The Configuration._foilsheetLayer is a string, that gets read out of a customer database at this point it is checked and filled correctly.
_Ed is a static property the gets initialized during Initialize().

While debugging and setting the breakpoint, I get a crash at line -> AcEd.PromptPointResult result = _Ed.GetPoint(opts); /*** _Ed. is not invalid ***/

First I got an 'eLock' exception (with the code I provided yesterday), after that I tried to use DocumentLock() and defined a scope around the Transaction block.
After that I´m getting the eNotApplicapable exception at the line mentioned above.

so actually the code looks like this (the critical part):
Code: [Select]
                AcGe.Matrix3d ucs = _Ed.CurrentUserCoordinateSystem;
                AcGe.Point3d origin = new AcGe.Point3d(0, 0, 0);
                AcGe.Vector3d normal = new AcGe.Vector3d(0, 0, 1);
                normal = normal.TransformBy(ucs);

                AcGe.Plane plane = new AcGe.Plane(origin, normal);
                AcDb.Polyline pline = new AcDb.Polyline(points.Count);
                pline.Normal = normal;

                foreach (AcGe.Point3d pt in points)
                {
                    AcGe.Point3d transformedPt = pt.TransformBy(ucs);
                    pline.AddVertexAt(pline.NumberOfVertices, plane.ParameterOf(transformedPt), 0, 0, 0);
                }

                try
                {
                    // NOTE: *** after applying the following DocumentLock Block of code, the eLock exception disapeared! ***
                    using (AcAp.DocumentLock l = _Ed.Document.LockDocument())
                    {
                        using (AcDb.Transaction tr = _Tm.StartTransaction())
                        {
                            AcDb.BlockTable bt = (AcDb.BlockTable)tr.GetObject(_Db.BlockTableId, AcDb.OpenMode.ForRead);
                            AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(bt[AcDb.BlockTableRecord.ModelSpace], AcDb.OpenMode.ForWrite);
                            AcDb.ObjectId plineId = btr.AppendEntity(pline);

                            tr.AddNewlyCreatedDBObject(pline, true);
                            tr.Commit();
                        }
                    }
                   
                    AcEd.PromptPointOptions opts = new AcEd.PromptPointOptions("\nPlease select direction: ");
                    opts.UseBasePoint = true;
                    opts.BasePoint = points[0];
                    AcEd.PromptPointResult result = _Ed.GetPoint(opts);  // NOTE: *** <--- here the app crashes...  :realmad:
                    if (result.Status == AcEd.PromptStatus.OK)
                        tempPt = result.Value;
                    else
                    {
                        return;
                    }
                }
                catch (AcRx.Exception ex)
                {
                    // shut up all exceptions for now...
                }


Thanks in advance...



troga

  • Guest
Re: eNotApplicable Exception...
« Reply #10 on: June 24, 2009, 03:57:22 AM »
looks like there is a lot more going on that you originally indicated ..

I assume the AcIn.  is Interop ??

            AcIn.AcadDocument doc = GetDoc();
            doc.Layers.Add(Configuration._foilsheetLayer);

where is this coming from (Configuration._foilsheetLayer)  

Where is this coming from
SteelplateJig


/// kwb

Hi kdub,

The Configuration._foilsheetLayer is a string, that gets read out of a customer database at this point it is checked and filled correctly.
_Ed is a static property the gets initialized during Initialize().

While debugging and setting the breakpoint, I get a crash at line -> AcEd.PromptPointResult result = _Ed.GetPoint(opts); /*** _Ed. is not invalid ***/

First I got an 'eLock' exception (with the code I provided yesterday), after that I tried to use DocumentLock() and defined a scope around the Transaction block.
After that I´m getting the eNotApplicapable exception at the line mentioned above.

so actually the code looks like this (the critical part):
Code: [Select]
                AcGe.Matrix3d ucs = _Ed.CurrentUserCoordinateSystem;
                AcGe.Point3d origin = new AcGe.Point3d(0, 0, 0);
                AcGe.Vector3d normal = new AcGe.Vector3d(0, 0, 1);
                normal = normal.TransformBy(ucs);

                AcGe.Plane plane = new AcGe.Plane(origin, normal);
                AcDb.Polyline pline = new AcDb.Polyline(points.Count);
                pline.Normal = normal;

                foreach (AcGe.Point3d pt in points)
                {
                    AcGe.Point3d transformedPt = pt.TransformBy(ucs);
                    pline.AddVertexAt(pline.NumberOfVertices, plane.ParameterOf(transformedPt), 0, 0, 0);
                }

                try
                {
                    // NOTE: *** after applying the following DocumentLock Block of code, the eLock exception disapeared! ***
                    using (AcAp.DocumentLock l = _Ed.Document.LockDocument())
                    {
                        using (AcDb.Transaction tr = _Tm.StartTransaction())
                        {
                            AcDb.BlockTable bt = (AcDb.BlockTable)tr.GetObject(_Db.BlockTableId, AcDb.OpenMode.ForRead);
                            AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(bt[AcDb.BlockTableRecord.ModelSpace], AcDb.OpenMode.ForWrite);
                            AcDb.ObjectId plineId = btr.AppendEntity(pline);

                            tr.AddNewlyCreatedDBObject(pline, true);
                            tr.Commit();
                        }
                    }
                   
                    AcEd.PromptPointOptions opts = new AcEd.PromptPointOptions("\nPlease select direction: ");
                    opts.UseBasePoint = true;
                    opts.BasePoint = points[0];
                    AcEd.PromptPointResult result = _Ed.GetPoint(opts);  // NOTE: *** <--- here the app crashes...  :realmad:
                    if (result.Status == AcEd.PromptStatus.OK)
                        tempPt = result.Value;
                    else
                    {
                        return;
                    }
                }
                catch (AcRx.Exception ex)
                {
                    // shut up all exceptions for now...
                }


Thanks in advance...




forgot to mention....  the SteelPlateJig is a Polyline Jig to draw a kind of 'Ghost Polyline' and to collect coordinates for creating a cross-section of a plastic foil...


Bryco

  • Water Moccasin
  • Posts: 1883
Re: eNotApplicable Exception...
« Reply #11 on: June 24, 2009, 10:42:11 AM »
swap
opts.UseBasePoint = true;
opts.BasePoint = points[0];
It likes to have a point before you tell it to use it

troga

  • Guest
Re: eNotApplicable Exception...
« Reply #12 on: June 24, 2009, 11:50:16 AM »
swap
opts.UseBasePoint = true;
opts.BasePoint = points[0];
It likes to have a point before you tell it to use it

Thanks I´ll try that...

troga

  • Guest
Re: eNotApplicable Exception...
« Reply #13 on: June 24, 2009, 03:37:08 PM »
Hey Bryco,

your suggestion works!!!

Thanks a lot...  amazing community !

It would be interesting why I got those eLock and eNotAplicable Exceptions, just for understanding, does anybody knows
where to find this kind of information ?

Thanks again.

Troga.

Glenn R

  • Guest
Re: eNotApplicable Exception...
« Reply #14 on: June 25, 2009, 07:30:16 AM »
Good spot Bryco! Have a beer mate.