I can not import object data.
Here is my source code.
public Boolean create(ref Tables tables, ObjectData objectData, ref ProjectModel projet)
{
int i = 0;
try
{
FieldDefinitions fieldDefs = projet.MapUtility.NewODFieldDefinitions();
foreach (Field field in objectData.Fields)
{
FieldDefinition fdef = null;
if (field.Type != "")
{
if (field.Type[0] != 'C')
fieldDefs.Add(field.Name, field.Desc, XMLtoACAD[field.Type], i);
else
fieldDefs.Add(field.Name, field.Desc, XMLtoACAD["C"], i);
i++;
}
}
tables.Add(Name, fieldDefs, objectData.Desc, true);
}
catch (Autodesk.Gis.Map.MapException ex)
{
return (false);
}
return true;
}
Table.Add is the problem.
Solved! Go to Solution.
I can not import object data.
Here is my source code.
public Boolean create(ref Tables tables, ObjectData objectData, ref ProjectModel projet)
{
int i = 0;
try
{
FieldDefinitions fieldDefs = projet.MapUtility.NewODFieldDefinitions();
foreach (Field field in objectData.Fields)
{
FieldDefinition fdef = null;
if (field.Type != "")
{
if (field.Type[0] != 'C')
fieldDefs.Add(field.Name, field.Desc, XMLtoACAD[field.Type], i);
else
fieldDefs.Add(field.Name, field.Desc, XMLtoACAD["C"], i);
i++;
}
}
tables.Add(Name, fieldDefs, objectData.Desc, true);
}
catch (Autodesk.Gis.Map.MapException ex)
{
return (false);
}
return true;
}
Table.Add is the problem.
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Well, it is difficult to tell by just reading the small chunk of code without knowing the context of the code runs in. There is also no way to know if the data passed in are correct, for example, in the "foreach (...) loop, you test
if (field.Type!="")
{
}
What happens if the field.Type is "", or null? Did you step through the code in debugging? If "table.Add(....)" is the line that raises exception, what is the MapException's ErrorCode? You can do
try
{
}
catch(MapException ex)
{
var errMsg=((Constants.ErrorCode)ex.ErrorCode).ToString()
MessageBox.Show(errMsg)
}
to decipher the integer error code to get some clue on what the nature of the exception is.
Then, how to you run the code? You may need to lock the drawing before running this code of creating OD table.
Norman Yuan
Well, it is difficult to tell by just reading the small chunk of code without knowing the context of the code runs in. There is also no way to know if the data passed in are correct, for example, in the "foreach (...) loop, you test
if (field.Type!="")
{
}
What happens if the field.Type is "", or null? Did you step through the code in debugging? If "table.Add(....)" is the line that raises exception, what is the MapException's ErrorCode? You can do
try
{
}
catch(MapException ex)
{
var errMsg=((Constants.ErrorCode)ex.ErrorCode).ToString()
MessageBox.Show(errMsg)
}
to decipher the integer error code to get some clue on what the nature of the exception is.
Then, how to you run the code? You may need to lock the drawing before running this code of creating OD table.
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.