You also can use the following APIs to create COM objects for your AcDbObject-derived class:
IAcadBlock::AddCustomObject(BSTR ClassName, LPDISPATCH* pObject) IAcadModelSpace::AddCustomObject(BSTR ClassName, LPDISPATCH* pObject) IAcadPaperSpace::AddCustomObject(BSTR ClassName, LPDISPATCH* pObject) IAcadDictionary::AddObject(BSTR Keyword, BSTR ObjectName, struct IAcadObject** pObject)
Using only the AcDbObject-derived class name (for example, AcDbMyObject), these APIs create the COM object and then call its IAcadBaseObject::SetObjectId() implementation. SetObjectId(), in turn, calls your COM wrapper's IAcadBaseObject::CreateNewObject() function. Your implementation of CreateNewObject() is expected to create an instance of the AcDbObject-derived class and add it to the database. See Adding a Custom Object or Entity to an Object Model for an example of how to write CreateNewObject().