Share

AcDbObject::dxfInFields

C++

Acad::ErrorStatus dxfInFields(
    AcDbDxfFiler* filer
) override;

Description

This function is called by dxfIn(). Its purpose is to allow the object to read in its data.

There is a fixed set of steps that should be followed when implementing your own version of this function:

  1. Call assertWriteEnabled().
  2. Call the parent class's dxfInFields(), passing it pFiler. If this returns Acad::eOk, then continue; otherwise immediately return whatever the parent class's dxfInFields() returned.
  3. Call pFiler->atSubclassData(), passing in the string that was written out with group code 100 in dxfOutFields(). If this returns Adesk::kTrue, then continue. Otherwise immediately return an error status other than Acad::eOk (for example, Acad::eBadDxfSequence).
  4. Now read in the data. The DXF filer has only one readItem function which reads a single data item into a resbuf structure. The data read in must then be copied from the resbuf into whatever data member it belongs in.

As of R13, it is possible to have order-dependent data. In custom classes you can have all order-independent, all order-dependent, or a mix of some order-independent and some order-dependent.

For order-independent read in, use a loop that reads a single data item and then uses a switch statement or if-then-elseif chain to figure out what has been read in and place it into the appropriate data member. If an unexpected or unknown group code is read in, use pFiler->pushBackitem() to rewind the file pointer back to the item that was wrong. Then return immediately with an appropriate error status (such as Acad::eBadDxfSequence or Acad::eInvalidDxfCode).

For order-dependent read in, use individual pFiler->readItem() calls to read each data item. Be sure to verify that each item read in is what it's supposed to be. If not, use pFiler->pushBackitem() to rewind the file pointer back to the item that was wrong and then return immediately with an appropriate error status (such as Acad::eBadDxfSequence, or Acad::eInvalidDxfCode).

Note

An object ID comes in as an ads_name in the resbuf's resval.rlname field. Use the global function acdbGetObjectId() to convert it into an objectId and place it in the appropriate data member.

Following these steps results in all base classes having their implementations of this function called as well, thus reading in all the object's data in class hierarchical order.

The actual AcDbObject::dxfInFields() implementation takes care of reading in the object's handle as well as its persistent reactor, extension dictionary, and xdata information.

This function should return Acad::eOk if successful. In your own custom class implementations of this function, it's easiest to just return pFiler->filerStatus().

Parameters

Parameters Description
pFiler Passed in pointer to filer to use to read in the object's data

Links

AcDbRasterImageDef

Was this information helpful?