Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Coding the Libraries

How can I specify handle values for objects that I add to a database?

The following code reserves a specified number of object handle values in an OdDbDatabase, and then supplies a custom handle value for an entity that is added to the database:

Code Block
// Create a database but do NOT initialize the default objects 
// in the database.
OdDbDatabasePtr pDb = myServices.createDatabase(false); 

// Reserve myHandSeed handle value, which causes all future 
// object handles created automatically by DWGdirect to be greater 
// than myHandSeed.
pDatabase->getOdDbObjectId(myHandSeed, 
                           true); // Create if not found

// Default objects created starting with handle myHandSeed + 1.
pDb->initialize(); 

// Create a new entity
OdDbCirlePtr pCirc = OdDbCircle::createObject();
// Set circle params...

// Add the circle to database with a specified handle 
pDb->addOdDbObject(
  pCircle,             // Entity to add
  OdDbObjectId::kNull, // OwnerId is set when entity is added to block
  MyCircleHandle);     // Custom object handle

// Add the entity to a block
pBlockRecord->appendOdDbEntity(pCircle);

Compiling the Libraries

Why do I get link errors of the form "operator new already defined in DD_XXXX_Alloc.lib"?

When the Microsoft VC /MT static library version of DWGdirect is linked into an appliation that uses the MFC Static Library (/MT configuration), the linker may issue errors described in the MS KB article Q148652: http://support.microsoft.com/default.aspx?scid=kb;[LN];Q148652.

...

Code Block
extern "C" {

  ALLOCDLL_EXPORT void* odrxAlloc(size_t s)
  {
    return ::malloc(s);
  }

  ALLOCDLL_EXPORT void* odrxRealloc(void* p, size_t new_size, size_t /*old_size*/)
  {
    return ::realloc(p, new_size);
  }

  ALLOCDLL_EXPORT void odrxFree(void* p) 
  {
    ::free(p);
  }

} // extern "C"

Why do I get link errors of the form 'undefined symbol' "public: class OdWString const & __thiscall OdWString::operator=(wchar_t const *)"?

Most likely you have the (/Zc:wchar_t) compiler option set. This causes wchar_t to be defined as its own type. Since the DWGdirect libraries are not built with this option, the linker is treating wchar_t (from your application) as a separate type from the one used to compile the DWGdirect libraries internally (there it is defined as unsigned short).

If you remove this option from your language settings, the error will go away.

Working with DWG Files

When I convert a DWG 2004 file back to R15, why do my gradient fills disappear and other items look different, such as colors?

DWG 2004 files can store a direct color or RGB value, which allows millions of unique color values to be stored in a single drawing. DWG R15 files and earlier versions can only store a color table index, which is a number representing one of 255 possible colors. When saving a DWG 2004 file back as DWG R15 or earlier, each RGB value must be mapped to the closest color table entry and stored as a color table index. As a result, the colors in the DWG R15 file may look bleak or dreary when compared to the original DWG 2004 file. DWG R15 files saved from AutoCAD 2004 exhibit the same behavior.

...

Also note that AutoCAD R14 supports only a single paper space layout, and it does not support lineweights (lineweights were added in AutoCAD 2000).

Working with Drawings

How do I determine the drawing units (millimeters, inches, feet, or kilometers) of a drawing?

There are a number of system variables stored in a drawing that are responsible for units and their display. The DWG version in which the system variables were introduced is important. Some DWG file versions do not store all of the system variables so if an older file is loaded, the newer system variables are assigned default values.

...

NOTE: Altering the values of INSUNITS, LUNITS, or AUNITS does not effect any coordinates stored in the drawing. The contents of the drawing are not scaled.

Why don't linetypes display when using OdDb3dPolyline?

Linetypes do not display for 3D polylines. In AutoCAD, OdDb3dPolylines (AcDb3dPolylines) always display with a SOLID linetype.

...

Note that linetype generation for planar polylines can be different. See OdDb2dPolyline::isLinetypeGenerationOn() and OdDbPolyline::hasPlinegen().

If entities overlap, which one is rendered on top?

It depends. The rendering works differently in 2D wireframe and 3D render modes, as follows:

...