.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error handler re-entered

2 REPLIES 2
Reply
Message 1 of 3
peterjacx
581 Views, 2 Replies

Error handler re-entered

Hello,

if i create with the code below-mentioned a solid3d, i have sometimes the error "error handler re-entered".
is there a mistake in the code or is it a problem from the solid3d object?

thanks Peter


I use AutoCAD 2007 ServicePack 1.

Here the code:

using System;
using System.Collections.Generic;
using System.Text;

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager;



[assembly: CommandClass(typeof(ClassLibrary.Zylinder))]


namespace ClassLibrary
{
public class Zylinder
{

[CommandMethod("TestZy")]
static public void Test()
{
Zylinder test = new Zylinder();

test.doit();
}





public bool doit()
{

Point3dCollection points = new Point3dCollection();
points.Add(new Point3d(10, 10, 0));
points.Add(new Point3d(100, 10, 0));
points.Add(new Point3d(150, 50, 0));

Point3d center = new Point3d(10, 10, 0);
//kreis senkrecht zum 1. Liniensegment
Vector3d normal = points[1] - points[0];

Circle dbkreis = new Circle(center, normal, 10);





//Kreis in Liste schreiben
DBObjectCollection curveSegments = new DBObjectCollection();
curveSegments.Add(dbkreis);

//Curve Segments in eine Region umwandeln
DBObjectCollection regionColl = Region.CreateFromCurves(curveSegments);

//Die Konvertierung kreis in Region darf nur ein Regionobjekt liefern
if (regionColl.Count != 1)
return false;



//Curve erzeugen
Curve pline = new Polyline3d(Poly3dType.SimplePoly, points, false);


Solid3d solid = new Solid3d();
//Zylinder als Solid3d erzeugen
solid.ExtrudeAlongPath((Region)regionColl[0], pline, 0);



Database db = Application.DocumentManager.MdiActiveDocument.Database;
DBTransMan tm = db.TransactionManager;


Transaction ta = tm.StartTransaction();

try
{

BlockTable bt = (BlockTable)ta.GetObject(db.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord btr = (BlockTableRecord)ta.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);


//Bauteil in DB schreiben und ID speichern
btr.AppendEntity(solid);

//Transaktion das neue Element zuweisen
ta.AddNewlyCreatedDBObject(solid, true);

ta.Commit();
}
catch
{

}
finally
{
ta.Dispose();
}


return true;
}

}
}
2 REPLIES 2
Message 2 of 3
peterjacx
in reply to: peterjacx

Hello,
I find a solution.

After a call of the garbage collector at the end of the command, i have no problems.

But why? Has someone an explanation for this?


[CommandMethod("TestZy")]
static public void Test()
{
Zylinder test = new Zylinder();

test.doit();

//Garbage Collector
GC.Collect();
}
Message 3 of 3
Anonymous
in reply to: peterjacx

>> Circle dbkreis = new Circle(center, normal, 10);

You're not disposing it.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5425978@discussion.autodesk.com...
Hello,
I find a solution.

After a call of the garbage collector at the end of the command, i have no problems.

But why? Has someone an explanation for this?


[CommandMethod("TestZy")]
static public void Test()
{
Zylinder test = new Zylinder();

test.doit();

//Garbage Collector
GC.Collect();
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost