I have a problem, which seems very trivial, but I'm not able to do it with
ObjectArx, the COM part crashes at some point no matter what I do.
1) I need to have only one instance of custom AcDbObject or AcDbEntity per
database
2) MANY instances of custom AcDbEntity depend on this AcDbObject, and have
to access this instance at any time
3) instance must be saved in the file
4) fast access to this instance is prefered
I tryed 2 different ways:
1) AcDbObject
a) AcDbDatabase::addAcDbObject
b) wanted to establish a database as an owner, but didn't find
appropriate functions
2) AcDbEntity
a) AcDbBlockTableRecord::appendAcDbEntity
b) access with acedSSGet (it is stupid but it works)
c) almost all implementations work OK
d) OPM and COM functions (put_*,...) tend to crash AutoCad (get_*
functions work fine) even though I lock the document. It crashes with
acedSSGet or AcDbBlockTableRecord::appendAcDbEntity, it depends on the
context.
I even overloaded IAcadBaseObject::SetObjectId, and it crashes there too,
but it won't crash in get_* functions :-(
Do you have any suggestions?
Is there some other, "correct" way to do it?
Could it be done without using the database?
Suggested functions will be very appreciated, I'm lost in ObjectArx
documentation.
Please help.
Thanks.
Igor
The preferred way to do this is to put the AcDbObject(no graphics) in a
dictionary and keep an AcDbHardOwnershipId to it in your custom AcDbEntity
derived object.
|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
| Autodesk Registered Developer
| email: by...@cadwerx.net
| web site: http://www.cadwerx.net
|
What you SHOULD do is to create a dictionary and store this dictionary in
the named objects dictionary. This new dictionary that you create will be
the home for all of the single instance objects that you ever create. In
you AcDbEntity, you want to store an AcDbHardPointerId to the object, or if
the object will always have the same name, just program the object's name
directly into the entity...
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
AcDbDictionary *pNamed, *pDict;
pDb->getNamedObjectsDictionary(pNamed, AcDb::kForWrite);
pDict = new AcDbDictionary();
AcDbObjectId dictId;
pNamed->setAt("ANY_NAME_YOU_WANT", pDict, dictId);
pNamed->close();
pDict->close();
No need to store dictId anywhere - just remember the name of your
dictionary!
Then, you can just use AcDbDictionary::setAt() to add your object to this
new dictionary. This way, any entity in the database can access the
object...
Jon Rizzo
Langan Engineering and Environmental Services, Inc.
"Byron Blattel" <cad...@texas.net> wrote in message
news:3B72C41D...@texas.net...
Actually I meant AcDbHardPointerId to the object stored in the dictionary
(although if there is only one then the name would be sufficient) as you stated
:)
Igor
"Jon Rizzo" <jri...@langan.com> wrote in message
news:113F623567DD9D7C...@in.WebX.maYIadrTaRb...
There are a few samples that ship with the ObjectARX API demonstrating how
to create a custom entity. The class wizard will take the leg work out of
the process, but you should understand what it is doing...
Jon
"Igor Jarm" <igor...@iname.com> wrote in message
news:DBE05AA9FAA11D4C...@in.WebX.maYIadrTaRb...
I know (I think) what is happening and what is not happening with custom
objects and custom entities. I have implemented my own months ago and it's a
pretty good "intelligent" little creature, I'm realy proud of it ;-)
But I don't know exactly what is happening with database, especialy in COM
functions, how to use it, what I can and can't do with it etc. And I need to
do pretty weird things with it on pretty weird occasions. Documentation is
pretty vague as far as "abuse" is concerned, and I'm also not a full time
AutoCad developer...
Thanks for help.
I feel you'll be hearing from me again ;-)
Igor
"Jon Rizzo" <jri...@langan.com> wrote in message
news:38150EF6CE799973...@in.WebX.maYIadrTaRb...