Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have a problem with passing a polyline to C# .Net.
I wrote .Net codes to get an object from Lisp and then calculating Area and also get bounding box of the object, but Autocad crashs after selecting a closed polyline. (I will appreciate anyone who corrects codes and adding bounding box method to it)
(setq ent (car (entsel)))
(mylispfunc ent)
[LispFunction("MyLispFunc")]
public ResultBuffer mylispfunc(ResultBuffer resBuf)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
ResultBuffer rbfResult = default(ResultBuffer);
var args = resBuf.AsArray();
ObjectId co = (ObjectId)((TypedValue)(args.GetValue(0))).Value;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Polyline lwp = tr.GetObject(co, OpenMode.ForRead) as Polyline;
double arr = lwp.Area;
tr.Commit();
}
Solved! Go to Solution.