Author Topic: AcDbObjectPointer 2009  (Read 3145 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7032
  • AKA Daniel
AcDbObjectPointer 2009
« on: April 06, 2008, 10:16:26 AM »
Read more about it here
http://through-the-interface.typepad.com/through_the_interface/2008/04/automatic-closi.html

Quote
...
AcDbObjectPointer<AcDbLine> line;

line.create();

// set the properties for it
line->setStartPoint(AcGePoint3d(10,10,0));
line->setEndPoint(AcGePoint3d(20,30,0));
...
« Last Edit: April 06, 2008, 10:22:14 AM by Daniel »

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7032
  • AKA Daniel
Re: AcDbObjectPointer 2009
« Reply #1 on: April 06, 2008, 10:20:36 AM »
Very similar to DRX 


Code: [Select]
...
  OdDbLinePtr pNewLine = OdDbLine::createObject();

  //Make a couple of points
  pNewLine->setStartPoint( startPt );
  pNewLine->setEndPoint( endPt );
...

Spike Wilbury

  • Guest
Re: AcDbObjectPointer 2009
« Reply #2 on: September 21, 2008, 09:09:03 PM »
I know it is an old topic....


Daniel,

This feature it is available also on AutoCAD 2007, I always noticed the create() method, but never use it..... (as far it is something different in the A2009)

Have a look:
Quote
static void AddSDElevZone(void)
{
   AcGePoint3d pt;
   acedGetPoint(NULL,_T("\nPick location: "),asDblArray(pt));

   AcDbObjectPointer<SDElevZone> pEZone;
   pEZone.create();
   pEZone->setDatabaseDefaults();
   pEZone->setPosition(pt);

   AcDbDatabase* pDb=acdbHostApplicationServices()->workingDatabase();
   AcDbBlockTableRecordPointer pBTR(pDb->currentSpaceId(),AcDb::kForWrite);

   if (Acad::eOk==pBTR.openStatus())
      pBTR->appendAcDbEntity(pEZone);
}

Also it is available on A2005-2006.... I just wrote the code, without testing it, but appears is there too.  :)

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7032
  • AKA Daniel
Re: AcDbObjectPointer 2009
« Reply #3 on: September 22, 2008, 02:35:53 PM »
Interesting,
I know Kean does not recommend using this before ac2009, according to one of the comments in his blog.
 Sure would be nice to use for all versions though

Spike Wilbury

  • Guest
Re: AcDbObjectPointer 2009
« Reply #4 on: September 22, 2008, 02:54:09 PM »
Interesting,
I know Kean does not recommend using this before ac2009, according to one of the comments in his blog.
 Sure would be nice to use for all versions though


I think this is what it is new:
Quote
Last but not the least is the new AcDbSmartObjectPointer template class in ObjectARX 2009, defined in the header file dbobjptr2.h.

This new template class works in the same way as AcDbObjectPointer template class except that it works by NOT opening an object at all if its open state is already what was requested, or even closing an object multiple times before opening in the desired manner. It merely hands you the already opened object pointer for your use. This means that it is much more efficient and also much more powerful in its usage. It also treats kForNotify and kForRead in the same manner, which is effectively kForRead.

One feature of this new SmartPointer class that Iíd like to talk about is the ability to multiply open an object for write, from different places, at the same time, a bit like a Transaction can Ė this is extremely powerful when you think about it.

At the same time though, I find thinking about the power that this can provide can start generating some other complex thoughts and scenarios that maybe we should be cautious of; the bottom line is that you should be very careful about multiply opening an object for write no matter how good the class that controls it.

An example of where this type of functionality really might be useful to us developers is in say an Object Reactor callback. Quite often you might want to modify the current objectís state but of course you canít because it is already open for notify. Using this new SmartPointer class it makes it possible to modify the object as you see fit in this context, but be careful to handle the recursive object modified notifications that will be fired by doing this.

All in all a very exciting new addition to the ObjectARX API, make sure you check it out.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7032
  • AKA Daniel
Re: AcDbObjectPointer 2009
« Reply #5 on: September 22, 2008, 03:07:42 PM »
Ok, that makes sense; I must have misread it the first time around