AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

object data table not created

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
701 Views, 1 Reply

object data table not created

Anonymous
Not applicable

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.

0 Likes

object data table not created

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.

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: Anonymous

norman.yuan
Mentor
Mentor
Accepted 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

Drive CAD With Code

EESignature

0 Likes

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

Drive CAD With Code

EESignature

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

Post to forums  

Autodesk Design & Make Report