Why comes error"eNotImpementedYet" and how to deal with it?

Why comes error"eNotImpementedYet" and how to deal with it?

Paciguard
Enthusiast Enthusiast
3,008 Views
10 Replies
Message 1 of 11

Why comes error"eNotImpementedYet" and how to deal with it?

Paciguard
Enthusiast
Enthusiast

Hello, everybody:

While I try to apply intersectwith function with two line in .NET, just catch the exception as "eNotImplementedYet", why it comes and how to deal with that?

 

 

Thanks and BR,

0 Likes
Accepted solutions (2)
3,009 Views
10 Replies
Replies (10)
Message 2 of 11

tbrammer
Advisor
Advisor

You should ask .NET questions in the .NET forum. Add a sample (code + drawing) to reproduce your problem if possible.

Do your lines really intersect? Are they lying in the same plane?


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 11

Paciguard
Enthusiast
Enthusiast

Thanks for your reply. Cause I just try ARX not BRX or TX, so I post here. About my two lines, they are very simple line, and whatever they have intersect point, the intersectwith function should work and return a result. But as for this case, I can not even to apply the function. So I confused about where is not implemented for the function.

0 Likes
Message 4 of 11

tbrammer
Advisor
Advisor

I suppose we are talking about AcDbLines, right? Or AcGeLine3d? AcGeLine2d?

Could it be that the lines in question have a (custom) class that is derived from AcDbLine?

Can you check this using LPCTSTR pcClassName = pLine->isA()->desc()

Or try to call pLine->AcDbLine::intersectWith(pOtherLine) explicitely. Does it help?

 

A few lines of sample code and a DWG would really help to clarify your issue.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 11

Paciguard
Enthusiast
Enthusiast

OK.Thans very much for your reply, Sir. My line is Line of Autocad.databaseservices.Line. And part of my codes as follows:

Dim Db as database

Db.readdwgfile("myfile",FileOpenMode.OpenForReadandWriteNoShare, False,"")

dim Btr as BlockTableRecord=Db.CurrentSpaceId.GetObject(OpenMode.ForWrite)

dim Bt as BlockTable=Db.BlockTableId.Getobject(OpenMode.ForWrite)

Brt.Id.Getobject(OpenMode.ForWrite,True,True)

Bt.Objectid.Getobject(OpenMode.ForWrite)

Dim Tr as TransactionManager=Db.TransactionManager

dim Linb as line=nothing

dim acLine as line=nothing

For each ObjId as ObjectId in Btr

dim Enta as Entity=Tr.Getobject(ObjectId,OpenMode.ForWrite)

if Typeof Enta Is Line then

if Enta.ColorIndex=2 then

Linb=Tr.Getobject(Enta.ObjectId,OpenMode.ForWrite)

end if

if Enta.ColorIndex<>2 then

acLine=Tr.Getobject(Enta.ObjectId,OpenMode.ForWrite)

End if

End if

Next

dim Pta3d as Point3dCollection=New Point3dCollection

Linb.Intersectwith(acLine,Intersect.OnBothOperands,Pta3d,IntPtr.Zero,IntPtr.Zero)

if Pta3d.Count>0 then

messagebox "Find Point"

End if

 

and before that, I have two lines in my drawing, one is yellow, one is white.

 

Thanks and BR,

 

0 Likes
Message 6 of 11

tbrammer
Advisor
Advisor

Would you append "myfile.dwg" please?

 

Have you checked whether Linb and acLine are valid before  Linb.Intersectwith(acLine, ...)  ?

I wonder why you open all objects ForWrite. In general you should open objects ForRead if you don't need to modify them.

 

If ObjectId is a line with color 2 your code does:

 

  Enta=Tr.Getobject(ObjectId,OpenMode.ForWrite)

  Linb=Tr.Getobject(Enta.ObjectId,OpenMode.ForWrite)

 

Have you checked whether Linb and acLine are valid before  Linb.Intersectwith(acLine, ...)  ?

I'm not sure that this will be the case if you try to open the same Id twice ForWrite.

 

 

 

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 7 of 11

OysteinW
Advocate
Advocate

If I read the VB code right, Linb, Enta and acLine is all the same object... So intersect with self is not supported on lines (which makes sense). 

 

0 Likes
Message 8 of 11

tbrammer
Advisor
Advisor

No, they are different. Linb has ColorIndex=2 and acLine has ColorIndex<>2.

Enta iterates over all entities in the modelspace within the For-loop.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 9 of 11

OysteinW
Advocate
Advocate

You're right, they are not the same..

 

As the code stands though, we probably wouldn't reach the Linb.intersectWith statement at all as there are no calls to Db.TransactionManager.StartTransaction(), so we should get a eNoActiveTransactions exception on GetObject, if not running into a nullreference exception at line 2 unless VB.Net knows which constructor to call on Database.

 

 

Rewritten into C# and modified a bit, the code works:

 

 

            using (Database Db = new Database(false, true))
            {
                Db.ReadDwgFile(@"D:\test.dwg", FileOpenMode.OpenForReadAndWriteNoShare, false, "");
                using(Transaction tr = Db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord Btr = tr.GetObject(Db.CurrentSpaceId,OpenMode.ForRead) as BlockTableRecord;
                    if (Btr != null)
                    {
                        Line Linb = null;
                        Line acLine = null;
                        foreach (ObjectId ObjId in Btr)
                        {
                            Entity Enta = tr.GetObject(ObjId, OpenMode.ForRead) as Entity;
                            if (Enta is Line)
                            {
                                if (Enta.ColorIndex == 2)
                                {
                                    Linb = tr.GetObject(Enta.ObjectId, OpenMode.ForRead) as Line;
                                }
                                if (Enta.ColorIndex != 2)
                                {
                                    acLine = tr.GetObject(Enta.ObjectId, OpenMode.ForRead) as Line;
                                }
                            }
                        }
                        try
                        {
                            Point3dCollection Pta = new Point3dCollection();
                            Linb.IntersectWith(acLine, Intersect.OnBothOperands, Pta, IntPtr.Zero, IntPtr.Zero);
                        }
                        catch (System.Exception error)
                        {
                            System.Windows.MessageBox.Show(error.StackTrace, error.Message);
                        }
                    }
                    tr.Commit();
                }
            }

 

 

 

 

 

 

 

 

 

 

 

 

Message 10 of 11

tbrammer
Advisor
Advisor
Accepted solution

 

Ok. But does it work with Paciguard's DWG as well`? Maybe it contains custom objects derived from LINE.

 

I would suggest to rewrite the VB code like this:

 

Db.readdwgfile("myfile",FileOpenMode.OpenForReadandWriteNoShare, False,"")
dim Btr as BlockTableRecord=Db.CurrentSpaceId.GetObject(OpenMode.ForRead)
Brt.Id.Getobject(OpenMode.ForRead,True,True)
Dim Tr as TransactionManager=Db.TransactionManager
Dim yellowLine As ObjectId
Dim otherLine As ObjectId

REM find objectIDs of the lines
For each ObjId as ObjectId in Btr
	dim Enta as Entity=Tr.Getobject(ObjectId,OpenMode.ForRead)
	if Typeof Enta Is Line then
		if Enta.ColorIndex=2 then
			yellowLine = ObjectId;
		else
			otherLine = ObjectId;
		End if
	End if
Next

REM open lines and intersect
dim Linb as line=nothing
dim acLine as line=nothing
Linb=Tr.Getobject(yellowLine,OpenMode.ForRead)
acLine=Tr.Getobject(otherLine,OpenMode.ForRead)

dim Pta3d as Point3dCollection=New Point3dCollection
Linb.Intersectwith(acLine,Intersect.OnBothOperands,Pta3d,IntPtr.Zero,IntPtr.Zero)

Changes in short:

+ Loop only stores the objectIDs of the lines and doesn't open them.

+ Open ForRead only instead of ForWrite


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 11 of 11

Paciguard
Enthusiast
Enthusiast
Accepted solution

OK. Thanks very much for your reply. I will try later.

0 Likes