<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Random crash after executing ODTable Copy in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8422701#M24156</link>
    <description>&lt;P&gt;Dear Support/Users!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a big problem that i tried to solve many times but without succes. I will include a part of my code, but first indroduce my program, so you understand what im doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are lines, lwpolylines and 3d polylines in our electric network map, we need to create a securety zone, a buffer of sort. But that is not all, these lines have object table attached, and these tables must be copied to the zones (lwpolylines).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short, i made functions that take these lines in, extracts the vertecies, it calculates the point of the zone, and returns a List&amp;lt;List&amp;lt;Point2d&amp;gt;&amp;gt;, so a list that contains a List of 2d points, from these points i create polylines. This part of the proccess works fine, exept, i have to turn visibility on manually, otherwise the zones wont be visible, until i open the drawing again.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;here comes the problem to be solved:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The problem comes, when i attach or copy object data to the zones. If i do this with about 100-200 objects it works fine, i can do it again and again, without any problem. However if i do it with the whole drawing (2000+ objects) after the second time i do it it crashes, but not every time it seems to be random. Sometimes it occurs on the first try.&lt;/P&gt;
&lt;P&gt;The errors:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;fatal error unhandled access violation reading 0x0000 exception at ...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;r6025 pure virtual function call...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;If i try to debug, the crash doesnt happen in my code, if i recal correctly it is in the&amp;nbsp;ManagedMapApi.dll and i dont know what is causing the problem.&lt;/P&gt;
&lt;P&gt;If i run the program without the od table part it doesnt crash.&lt;/P&gt;
&lt;P&gt;szelesseg = width of the zone.&lt;/P&gt;
&lt;P&gt;metamasol = it is a bool value, the user can select if he wants to copy odtable or not&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Here is the code:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;[CommandMethod("zone_draw")]&lt;BR /&gt; public void test()&lt;BR /&gt; {&lt;BR /&gt; Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; acDoc.LockDocument();&lt;BR /&gt; Database acCurDb = acDoc.Database;&lt;BR /&gt; Editor ed = acDoc.Editor;&lt;BR /&gt; Stopwatch sw;&lt;BR /&gt; PromptSelectionOptions pso = new PromptSelectionOptions();&lt;BR /&gt; pso.MessageForAdding = "\nVálaszd ki a nyomvonalakat amire biztonsági övezetet szeretnél rajzolni!";&lt;BR /&gt; double szelesseg;&lt;BR /&gt; GeneralFunc.CreateLayer("zone", 7);&lt;BR /&gt; ObjectIdCollection objcol = new ObjectIdCollection();&lt;BR /&gt; List&amp;lt;double&amp;gt; szellist = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; PromptSelectionResult pres = ed.GetSelection(this.NyomvonalFilter());&lt;BR /&gt; if (pres.Status == PromptStatus.OK)&lt;BR /&gt; {&lt;BR /&gt; List&amp;lt;Tuple&amp;lt;ObjectId, ObjectId&amp;gt;&amp;gt; nyvesovezet = new List&amp;lt;Tuple&amp;lt;ObjectId, ObjectId&amp;gt;&amp;gt;();&lt;BR /&gt; List&amp;lt;double&amp;gt; szelessegek = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; using (Transaction tr = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt; {&lt;BR /&gt; sw = new Stopwatch();&lt;BR /&gt; sw.Start();&lt;BR /&gt; BlockTable blktable = tr.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;&lt;BR /&gt; BlockTableRecord tblrec = tr.GetObject(blktable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;&lt;BR /&gt; List&amp;lt;List&amp;lt;Point2d&amp;gt;&amp;gt; biztovpoints = new List&amp;lt;List&amp;lt;Point2d&amp;gt;&amp;gt;();&lt;BR /&gt; SelectionSet ss = pres.Value;&lt;/P&gt;
&lt;P&gt;bool canbedrawn = false;&lt;BR /&gt; for (int i = 0; i &amp;lt; ss.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; Entity ent = tr.GetObject(ss[i].ObjectId, OpenMode.ForRead) as Entity;&lt;BR /&gt; if (VlancMegfelelo(ent.ObjectId, tr))&lt;BR /&gt; {&lt;BR /&gt; szelesseg = SzelessegMegad(ent.Layer);&lt;BR /&gt; if (ent.ObjectId.ObjectClass.DxfName == "LWPOLYLINE")&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;Polyline pl = ent as Polyline;&lt;BR /&gt; &lt;BR /&gt; if (BiztonsagiOV(pl, szelesseg, out biztovpoints))&lt;BR /&gt; {&lt;BR /&gt; canbedrawn = true;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else if (ent.ObjectId.ObjectClass.DxfName == "LINE")&lt;BR /&gt; {&lt;BR /&gt; Line pl = ent.Clone() as Line;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; if (BiztonsagiOV(pl as Line, szelesseg, out biztovpoints))&lt;BR /&gt; {&lt;BR /&gt; canbedrawn = true;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else //polyline&lt;BR /&gt; {&lt;BR /&gt; Polyline3d pl = ent as Polyline3d;&lt;/P&gt;
&lt;P&gt;if (BiztonsagiOV(pl as Polyline3d, szelesseg, tr, out biztovpoints))&lt;BR /&gt; {&lt;BR /&gt; canbedrawn = true;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;if (canbedrawn)&lt;BR /&gt; {&lt;BR /&gt; for (int j = 0; j &amp;lt; biztovpoints.Count; j++)&lt;BR /&gt; {&lt;BR /&gt; using (Polyline pline = new Polyline(biztovpoints.ElementAt(j).Count))&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;pline.SetDatabaseDefaults();&lt;/P&gt;
&lt;P&gt;for (int k = 0; k &amp;lt; biztovpoints.ElementAt(j).Count; k++)&lt;BR /&gt; {&lt;BR /&gt; pline.AddVertexAt(k, biztovpoints.ElementAt(j).ElementAt(k), 0, 0, 0);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;pline.Layer = folia;&lt;/P&gt;
&lt;P&gt;tblrec.AppendEntity(pline);&lt;BR /&gt; tr.AddNewlyCreatedDBObject(pline, true);&lt;/P&gt;
&lt;P&gt;nyvesovezet.Add(new Tuple&amp;lt;ObjectId, ObjectId&amp;gt;(ss[i].ObjectId, pline.ObjectId));&lt;BR /&gt; szelessegek.Add(szelesseg);&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; Entity e = tr.GetObject(ent.ObjectId, OpenMode.ForWrite) as Entity;&lt;BR /&gt; e.ColorIndex = 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; tr.Commit();&lt;BR /&gt; }&lt;BR /&gt; using (Transaction tr = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt; {&lt;BR /&gt; for (int i = 0; i &amp;lt; nyvesovezet.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; Entity id = tr.GetObject(nyvesovezet.ElementAt(i).Item2, OpenMode.ForWrite) as Entity;&lt;BR /&gt; if (metaMasol) CopyMetaData(nyvesovezet.ElementAt(i).Item1, nyvesovezet.ElementAt(i).Item2);&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; tr.Commit();&lt;BR /&gt; }&lt;BR /&gt; nyvesovezet.Clear();&lt;BR /&gt; sw.Stop();&lt;BR /&gt; ed.WriteMessage("\nA biztonsági öv meg lett rajzolva: " + sw.ElapsedMilliseconds + " msec alatt.");&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public Dictionary&amp;lt;string, string&amp;gt; GetMetaData(ObjectId objid)&lt;BR /&gt; {&lt;BR /&gt; Dictionary&amp;lt;string, string&amp;gt; tablaertek = new Dictionary&amp;lt;string, string&amp;gt;();&lt;BR /&gt; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; doc.LockDocument();&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Tables tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Table table = tables["EL_META"];&lt;BR /&gt; Editor ed = doc.Editor;&lt;BR /&gt; using (Records records = table.GetObjectTableRecords(0, objid, Autodesk.Gis.Map.Constants.OpenMode.OpenForRead, false))&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; if (records.Count == 0)&lt;BR /&gt; {&lt;BR /&gt; records.Dispose();&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; foreach (Record record in records)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; if (record.TableName == "EL_META")&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; for (int i = 0; i &amp;lt; record.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; FieldDefinitions tableDef = table.FieldDefinitions;&lt;BR /&gt; FieldDefinition column = null;&lt;BR /&gt; column = tableDef[i];&lt;BR /&gt; string colName = column.Name;&lt;BR /&gt; Autodesk.Gis.Map.Utilities.MapValue val = record[i];&lt;BR /&gt; string value = val.StrValue;&lt;BR /&gt; if (!tablaertek.ContainsKey(colName))&lt;BR /&gt; {&lt;BR /&gt; if (column.Type.ToString() == "Character")&lt;BR /&gt; {&lt;BR /&gt; tablaertek.Add(colName, val.StrValue);&lt;BR /&gt; }&lt;BR /&gt; else if (column.Type.ToString() == "Integer")&lt;BR /&gt; {&lt;BR /&gt; tablaertek.Add(colName, val.Int32Value.ToString());&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; tablaertek.Add(colName, val.DoubleValue.ToString());&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; table.Dispose();&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; records.Dispose();&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return tablaertek;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;public void AttachMetaTable(ObjectId objid) //there is no meta data in the object since it is newly created&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;Tables tables = HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Table table = tables["EL_META"];&lt;BR /&gt; Record Rec = Record.Create();&lt;BR /&gt; &lt;BR /&gt; table.InitRecord(Rec);&lt;BR /&gt; table.AddRecord(Rec, objid);&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;public void CopyMetaData(ObjectId baseobject, ObjectId TargetObject)&lt;BR /&gt; {&lt;BR /&gt; Dictionary&amp;lt;string, string&amp;gt; tablaertek = GetMetaData(baseobject);&lt;BR /&gt; AttachMetaTable(TargetObject);&lt;BR /&gt; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; doc.LockDocument();&lt;BR /&gt; if (tablaertek.Count != 0)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Tables tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Table table = tables["EL_META"];&lt;BR /&gt; using (Records records = table.GetObjectTableRecords(0, TargetObject, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, false))&lt;BR /&gt; {&lt;BR /&gt; if (records.Count == 0)&lt;BR /&gt; {&lt;BR /&gt; records.Dispose();&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; foreach (Record Recd in records)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; if (Recd.TableName == "EL_META")&lt;BR /&gt; {&lt;BR /&gt; for (int i = 0; i &amp;lt; Recd.Count; i++)&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;FieldDefinitions tblDefs = table.FieldDefinitions;&lt;BR /&gt; FieldDefinition column = null;&lt;BR /&gt; column = tblDefs[i];&lt;BR /&gt; if (tablaertek.ContainsKey(column.Name))&lt;BR /&gt; {&lt;BR /&gt; Recd[i].Assign(tablaertek[column.Name]);&lt;BR /&gt; records.UpdateRecord(Recd);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; table.Dispose();&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt; }&lt;BR /&gt; tablaertek.Clear();&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to attach od in the first transaction with entlast but didnt work, the problem was still there. Tried disposing entities, used the using statement on the created polyline.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 25 Nov 2018 09:59:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-11-25T09:59:14Z</dc:date>
    <item>
      <title>Random crash after executing ODTable Copy</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8422701#M24156</link>
      <description>&lt;P&gt;Dear Support/Users!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a big problem that i tried to solve many times but without succes. I will include a part of my code, but first indroduce my program, so you understand what im doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are lines, lwpolylines and 3d polylines in our electric network map, we need to create a securety zone, a buffer of sort. But that is not all, these lines have object table attached, and these tables must be copied to the zones (lwpolylines).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short, i made functions that take these lines in, extracts the vertecies, it calculates the point of the zone, and returns a List&amp;lt;List&amp;lt;Point2d&amp;gt;&amp;gt;, so a list that contains a List of 2d points, from these points i create polylines. This part of the proccess works fine, exept, i have to turn visibility on manually, otherwise the zones wont be visible, until i open the drawing again.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;here comes the problem to be solved:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The problem comes, when i attach or copy object data to the zones. If i do this with about 100-200 objects it works fine, i can do it again and again, without any problem. However if i do it with the whole drawing (2000+ objects) after the second time i do it it crashes, but not every time it seems to be random. Sometimes it occurs on the first try.&lt;/P&gt;
&lt;P&gt;The errors:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;fatal error unhandled access violation reading 0x0000 exception at ...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;r6025 pure virtual function call...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;If i try to debug, the crash doesnt happen in my code, if i recal correctly it is in the&amp;nbsp;ManagedMapApi.dll and i dont know what is causing the problem.&lt;/P&gt;
&lt;P&gt;If i run the program without the od table part it doesnt crash.&lt;/P&gt;
&lt;P&gt;szelesseg = width of the zone.&lt;/P&gt;
&lt;P&gt;metamasol = it is a bool value, the user can select if he wants to copy odtable or not&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Here is the code:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;[CommandMethod("zone_draw")]&lt;BR /&gt; public void test()&lt;BR /&gt; {&lt;BR /&gt; Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; acDoc.LockDocument();&lt;BR /&gt; Database acCurDb = acDoc.Database;&lt;BR /&gt; Editor ed = acDoc.Editor;&lt;BR /&gt; Stopwatch sw;&lt;BR /&gt; PromptSelectionOptions pso = new PromptSelectionOptions();&lt;BR /&gt; pso.MessageForAdding = "\nVálaszd ki a nyomvonalakat amire biztonsági övezetet szeretnél rajzolni!";&lt;BR /&gt; double szelesseg;&lt;BR /&gt; GeneralFunc.CreateLayer("zone", 7);&lt;BR /&gt; ObjectIdCollection objcol = new ObjectIdCollection();&lt;BR /&gt; List&amp;lt;double&amp;gt; szellist = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; PromptSelectionResult pres = ed.GetSelection(this.NyomvonalFilter());&lt;BR /&gt; if (pres.Status == PromptStatus.OK)&lt;BR /&gt; {&lt;BR /&gt; List&amp;lt;Tuple&amp;lt;ObjectId, ObjectId&amp;gt;&amp;gt; nyvesovezet = new List&amp;lt;Tuple&amp;lt;ObjectId, ObjectId&amp;gt;&amp;gt;();&lt;BR /&gt; List&amp;lt;double&amp;gt; szelessegek = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; using (Transaction tr = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt; {&lt;BR /&gt; sw = new Stopwatch();&lt;BR /&gt; sw.Start();&lt;BR /&gt; BlockTable blktable = tr.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;&lt;BR /&gt; BlockTableRecord tblrec = tr.GetObject(blktable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;&lt;BR /&gt; List&amp;lt;List&amp;lt;Point2d&amp;gt;&amp;gt; biztovpoints = new List&amp;lt;List&amp;lt;Point2d&amp;gt;&amp;gt;();&lt;BR /&gt; SelectionSet ss = pres.Value;&lt;/P&gt;
&lt;P&gt;bool canbedrawn = false;&lt;BR /&gt; for (int i = 0; i &amp;lt; ss.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; Entity ent = tr.GetObject(ss[i].ObjectId, OpenMode.ForRead) as Entity;&lt;BR /&gt; if (VlancMegfelelo(ent.ObjectId, tr))&lt;BR /&gt; {&lt;BR /&gt; szelesseg = SzelessegMegad(ent.Layer);&lt;BR /&gt; if (ent.ObjectId.ObjectClass.DxfName == "LWPOLYLINE")&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;Polyline pl = ent as Polyline;&lt;BR /&gt; &lt;BR /&gt; if (BiztonsagiOV(pl, szelesseg, out biztovpoints))&lt;BR /&gt; {&lt;BR /&gt; canbedrawn = true;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else if (ent.ObjectId.ObjectClass.DxfName == "LINE")&lt;BR /&gt; {&lt;BR /&gt; Line pl = ent.Clone() as Line;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; if (BiztonsagiOV(pl as Line, szelesseg, out biztovpoints))&lt;BR /&gt; {&lt;BR /&gt; canbedrawn = true;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else //polyline&lt;BR /&gt; {&lt;BR /&gt; Polyline3d pl = ent as Polyline3d;&lt;/P&gt;
&lt;P&gt;if (BiztonsagiOV(pl as Polyline3d, szelesseg, tr, out biztovpoints))&lt;BR /&gt; {&lt;BR /&gt; canbedrawn = true;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;if (canbedrawn)&lt;BR /&gt; {&lt;BR /&gt; for (int j = 0; j &amp;lt; biztovpoints.Count; j++)&lt;BR /&gt; {&lt;BR /&gt; using (Polyline pline = new Polyline(biztovpoints.ElementAt(j).Count))&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;pline.SetDatabaseDefaults();&lt;/P&gt;
&lt;P&gt;for (int k = 0; k &amp;lt; biztovpoints.ElementAt(j).Count; k++)&lt;BR /&gt; {&lt;BR /&gt; pline.AddVertexAt(k, biztovpoints.ElementAt(j).ElementAt(k), 0, 0, 0);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;pline.Layer = folia;&lt;/P&gt;
&lt;P&gt;tblrec.AppendEntity(pline);&lt;BR /&gt; tr.AddNewlyCreatedDBObject(pline, true);&lt;/P&gt;
&lt;P&gt;nyvesovezet.Add(new Tuple&amp;lt;ObjectId, ObjectId&amp;gt;(ss[i].ObjectId, pline.ObjectId));&lt;BR /&gt; szelessegek.Add(szelesseg);&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; Entity e = tr.GetObject(ent.ObjectId, OpenMode.ForWrite) as Entity;&lt;BR /&gt; e.ColorIndex = 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; tr.Commit();&lt;BR /&gt; }&lt;BR /&gt; using (Transaction tr = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt; {&lt;BR /&gt; for (int i = 0; i &amp;lt; nyvesovezet.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; Entity id = tr.GetObject(nyvesovezet.ElementAt(i).Item2, OpenMode.ForWrite) as Entity;&lt;BR /&gt; if (metaMasol) CopyMetaData(nyvesovezet.ElementAt(i).Item1, nyvesovezet.ElementAt(i).Item2);&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; tr.Commit();&lt;BR /&gt; }&lt;BR /&gt; nyvesovezet.Clear();&lt;BR /&gt; sw.Stop();&lt;BR /&gt; ed.WriteMessage("\nA biztonsági öv meg lett rajzolva: " + sw.ElapsedMilliseconds + " msec alatt.");&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public Dictionary&amp;lt;string, string&amp;gt; GetMetaData(ObjectId objid)&lt;BR /&gt; {&lt;BR /&gt; Dictionary&amp;lt;string, string&amp;gt; tablaertek = new Dictionary&amp;lt;string, string&amp;gt;();&lt;BR /&gt; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; doc.LockDocument();&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Tables tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Table table = tables["EL_META"];&lt;BR /&gt; Editor ed = doc.Editor;&lt;BR /&gt; using (Records records = table.GetObjectTableRecords(0, objid, Autodesk.Gis.Map.Constants.OpenMode.OpenForRead, false))&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; if (records.Count == 0)&lt;BR /&gt; {&lt;BR /&gt; records.Dispose();&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; foreach (Record record in records)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; if (record.TableName == "EL_META")&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; for (int i = 0; i &amp;lt; record.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; FieldDefinitions tableDef = table.FieldDefinitions;&lt;BR /&gt; FieldDefinition column = null;&lt;BR /&gt; column = tableDef[i];&lt;BR /&gt; string colName = column.Name;&lt;BR /&gt; Autodesk.Gis.Map.Utilities.MapValue val = record[i];&lt;BR /&gt; string value = val.StrValue;&lt;BR /&gt; if (!tablaertek.ContainsKey(colName))&lt;BR /&gt; {&lt;BR /&gt; if (column.Type.ToString() == "Character")&lt;BR /&gt; {&lt;BR /&gt; tablaertek.Add(colName, val.StrValue);&lt;BR /&gt; }&lt;BR /&gt; else if (column.Type.ToString() == "Integer")&lt;BR /&gt; {&lt;BR /&gt; tablaertek.Add(colName, val.Int32Value.ToString());&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; tablaertek.Add(colName, val.DoubleValue.ToString());&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; table.Dispose();&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; records.Dispose();&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return tablaertek;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;public void AttachMetaTable(ObjectId objid) //there is no meta data in the object since it is newly created&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;Tables tables = HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Table table = tables["EL_META"];&lt;BR /&gt; Record Rec = Record.Create();&lt;BR /&gt; &lt;BR /&gt; table.InitRecord(Rec);&lt;BR /&gt; table.AddRecord(Rec, objid);&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;public void CopyMetaData(ObjectId baseobject, ObjectId TargetObject)&lt;BR /&gt; {&lt;BR /&gt; Dictionary&amp;lt;string, string&amp;gt; tablaertek = GetMetaData(baseobject);&lt;BR /&gt; AttachMetaTable(TargetObject);&lt;BR /&gt; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; doc.LockDocument();&lt;BR /&gt; if (tablaertek.Count != 0)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Tables tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt; Autodesk.Gis.Map.ObjectData.Table table = tables["EL_META"];&lt;BR /&gt; using (Records records = table.GetObjectTableRecords(0, TargetObject, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, false))&lt;BR /&gt; {&lt;BR /&gt; if (records.Count == 0)&lt;BR /&gt; {&lt;BR /&gt; records.Dispose();&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; foreach (Record Recd in records)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; if (Recd.TableName == "EL_META")&lt;BR /&gt; {&lt;BR /&gt; for (int i = 0; i &amp;lt; Recd.Count; i++)&lt;BR /&gt; {&lt;/P&gt;
&lt;P&gt;FieldDefinitions tblDefs = table.FieldDefinitions;&lt;BR /&gt; FieldDefinition column = null;&lt;BR /&gt; column = tblDefs[i];&lt;BR /&gt; if (tablaertek.ContainsKey(column.Name))&lt;BR /&gt; {&lt;BR /&gt; Recd[i].Assign(tablaertek[column.Name]);&lt;BR /&gt; records.UpdateRecord(Recd);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; table.Dispose();&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt; }&lt;BR /&gt; tablaertek.Clear();&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to attach od in the first transaction with entlast but didnt work, the problem was still there. Tried disposing entities, used the using statement on the created polyline.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Nov 2018 09:59:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8422701#M24156</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-25T09:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Random crash after executing ODTable Copy</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8422802#M24157</link>
      <description>&lt;P&gt;Okay, I changed the OD copy and adding function. I made this instead of the two:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public bool CopyODTable(string tablename, ObjectId baseObj, ObjectId targetobj)&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Autodesk.Gis.Map.ObjectData.Tables tables =&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Autodesk.Gis.Map.ObjectData.Table table = tables[tablename];&lt;BR /&gt; &lt;BR /&gt;using (Records records = table.GetObjectTableRecords(0, baseObj, Autodesk.Gis.Map.Constants.OpenMode.OpenForRead, false))&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (records.Count &amp;gt; 0)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Record Rec = records[0].Clone() as Record;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;table.AddRecord(Rec, targetobj);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return true;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;else&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;return false;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This way i thinks there should be no problem with the copy proccess. It works fine, and after I try to create the zones again on all objects it crashes with pure virtual function call.&lt;/P&gt;
&lt;P&gt;I can think of two possibilities:&lt;/P&gt;
&lt;P&gt;Autocad is starting something in the background, and the more elements i create the more time it needs, and after using my program again it isnt finished, and somehow they collide.&lt;/P&gt;
&lt;P&gt;My second tought is that my program doesnt free up something, and in the second run i the Autocads methods cant open something for write.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Nov 2018 13:07:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8422802#M24157</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-25T13:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Random crash after executing ODTable Copy</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8423211#M24158</link>
      <description>&lt;P&gt;Maybe i was impatient, today i could solve, the problem. The reason for the crash is still unknown to me, but at least i got it working.&lt;/P&gt;
&lt;P&gt;Copying OD tables between objects is something i did not encounter on the internet, so im gonna share my code, with this, and a lot of using statements and .dispose() functions i could reduce the speed of my program from 70 seconds to 4 seconds. (of course this depends on the objects, this is the result from my test dwg)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the main problem was putting "&lt;SPAN&gt;Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables" into a variable, if i dispose this variable, then attaching od tables in the drawing is not possible. So i thought then i use it directly and dont use a variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public bool CopyODTable(string tablename, ObjectId baseObj, ObjectId targetobj)&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp;try&lt;BR /&gt;{&lt;BR /&gt;Autodesk.Gis.Map.ObjectData.Table table =&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables[tablename];&lt;BR /&gt;using (Records records = table.GetObjectTableRecords(0, baseObj,&amp;nbsp; &amp;nbsp; Autodesk.Gis.Map.Constants.OpenMode.OpenForRead, false))&lt;BR /&gt; {&lt;BR /&gt; if (records.Count &amp;gt; 0 &amp;amp;&amp;amp; records.Count &amp;lt; 2)&lt;BR /&gt; {&lt;BR /&gt; Record Rec = records[0].Clone() as Record;&lt;BR /&gt; table.AddRecord(Rec, targetobj);&lt;BR /&gt; records.Dispose();&lt;BR /&gt; Rec.Dispose();&lt;BR /&gt; table.Dispose();&lt;BR /&gt; return true;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; records.Dispose();&lt;BR /&gt; table.Dispose();&lt;BR /&gt; return false;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; catch&lt;BR /&gt; {&lt;BR /&gt; return false;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Nov 2018 20:43:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-crash-after-executing-odtable-copy/m-p/8423211#M24158</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-25T20:43:01Z</dc:date>
    </item>
  </channel>
</rss>

