MapValue Assign error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'd like to update a record of ObjectData, and it doesn't work as I want
I've written this simplified code to show what hapens.
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Gis.Map;
using Autodesk.Gis.Map.ObjectData;
namespace TestOD
{
public class Class1
{
[CommandMethodAttribute("TestUpdOD")]
public void TestUpdOD()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
// Récupère les tables existantes dans le dessin
Tables oTables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;
// Select entity
PromptEntityResult per = ed.GetEntity("\nSelect an object with OD : ");
if (per.Status != PromptStatus.OK)
return;
// Get and Initialize Records
using (Records records = oTables.GetObjectRecords(0, per.ObjectId, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, false))
{
// Iterate through all records
foreach (Record record in records)
{
// Get record info
for (int i = 0; i < record.Count; i++)
{
Autodesk.Gis.Map.Utilities.MapValue oMapVal = record[i];
switch (oMapVal.Type)
{
case Autodesk.Gis.Map.Constants.DataType.Integer:
oMapVal.Assign(123); // PROBLEM IS HERE
break;
case Autodesk.Gis.Map.Constants.DataType.Real:
oMapVal.Assign(123.456);
break;
case Autodesk.Gis.Map.Constants.DataType.Character:
oMapVal.Assign("INFO");
break;
case Autodesk.Gis.Map.Constants.DataType.UnknownType:
break;
case Autodesk.Gis.Map.Constants.DataType.Point:
break;
default:
continue;
}
}
records.UpdateRecord(record);
}
}
}
}
}
I've target .Net 4.5 and Map 3D 2015, DLL compiles fine, and execution is OK.
If I try to load my DLL in Civil 2019 (or 2020) when entering my command, first thing I obtain is this error message
If I reopen my solution, target .Net 4.7 and Reference Dll from Civil 2019 instead of MAP 2015, without changing anything in code, compile is OK, and execution is OK in 2019 and 2020. But I can't use this DLL in MAP 2015.
If I comment this following line
oMapVal.Assign(123)
I can compile with .Net 4.5 and MAP 2015 and execute without problem in 2015 AND 2019 AND 2020.
Method Assign(double) and Assign(string) work fine, but Assign(Int32) doesn't work.
Until now I've always build 2 dll, 1 for 2012 an prior, and 1 for 2013 and above, and it has always worked from 2010 to 2020 without any problem.
Do you have any solution?
Thanks
Olivier
Olivier Eckmann