Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

single instance of AcDbObject used by many AcDbEntity

1 view
Skip to first unread message

Igor Jarm

unread,
Aug 9, 2001, 12:04:03 PM8/9/01
to
Hi all,

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

Byron Blattel

unread,
Aug 9, 2001, 1:10:53 PM8/9/01
to
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
|

Jon Rizzo

unread,
Aug 9, 2001, 1:35:13 PM8/9/01
to
Do you mean put the object in a dictionary and keep the hard ownership id of
the dictionary in the entity? If so, then what you are describing will only
be good for 1 entity to access the data. if you meant store a hard
ownership id of the object, then that would cause the object to have 2
owners.

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...

Byron Blattel

unread,
Aug 9, 2001, 1:48:30 PM8/9/01
to
Jon Rizzo wrote:
>
> Do you mean put the object in a dictionary and keep the hard ownership id of
> the dictionary in the entity?

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 Jarm

unread,
Aug 10, 2001, 3:16:23 AM8/10/01
to
Thanks a lot.
This is exactly what I "sort of" wanted to do, but didn't know how.

Igor


"Jon Rizzo" <jri...@langan.com> wrote in message
news:113F623567DD9D7C...@in.WebX.maYIadrTaRb...

Jon Rizzo

unread,
Aug 10, 2001, 7:51:05 AM8/10/01
to

Igor -

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...

Igor Jarm

unread,
Aug 10, 2001, 4:21:20 PM8/10/01
to
Jon,

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...

0 new messages