Author Topic: Add row in a Table - Question  (Read 9724 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Re: Add row in a Table - Question
« Reply #15 on: March 17, 2006, 09:54:18 AM »
You was not right. You Can use transaction manager. Look at this code and compare with yours code:
Code: [Select]
  static void TableAddRow(void)
  }
In other words You can not use acdbTransactionManager->getObject(...,AcDb::kForRead) and after then use upgradeOpen(). upgradeOpen() is valid only with objects not in transaction.

Thank you Alex;

I mention that on a previous post

Quote
That is not available as function on ARX, I know what that function does in .NET, now what happens is that it is needed to wait for the transactionEnded() signal and after that, do the modifications... hmm...

It is contradictory, since when it is used the transaction manager, the good about it is to not care of closing objects.... unless [and it is possible] I am wrong... <<<<<<<<<<<<<<

I will change my code to use smart pointers... and see what happens.

Great, now I will understand this part :-)

Using the smart pointer's route, the code is more straight forward, compact and easy to understand..... [I will go back to what I read about transaction. too.... I see that it was just very minor changes you did]

Rock & Roll !!!

LE

  • Guest
Re: Add row in a Table - Question
« Reply #16 on: March 17, 2006, 10:21:46 AM »
This one works too, by taking out the upgradeOpen() and using AcDb::kForWrite

I see you are using cast(), what is the benefit on that Alex ?

Thanks!

Code: [Select]
static void LESQsomefunctions_ADDROW(void)
{
ads_name ename;
ads_point ptres;
if ( acedEntSel( "\nSelect TABLE:", ename, ptres ) == RTNORM ) {
AcDbTable *pTable = NULL;
AcDbObjectId entId;
acdbGetObjectId( entId, ename );
acdbTransactionManager->startTransaction();
if ( acdbTransactionManager->getObject(
( AcDbObject*& )pTable, entId, AcDb::kForWrite) == Acad::eOk) {
if ( pTable->isKindOf( AcDbTable::desc() ) ) {
if (( pTable->insertRows( pTable->numRows(),
pTable->rowHeight( 1 ) ) == Acad::eOk ) &&
( pTable->generateLayout() == Acad::eOk )) {
acutPrintf( "\nAdded one row and table updated." );
} else {
acutPrintf( "\nTable not updated." );
}
}// end of is AcDbTable
}// end of getObject
acdbTransactionManager->endTransaction();
}// end of acedEntSel
}

LE

  • Guest
Re: Add row in a Table - Question
« Reply #17 on: March 17, 2006, 10:26:22 AM »
Rivilis is quite correct Luis. You can use transactions in the code you posted. However, is it better than using smart pointer objects and checking all return codes...open for debate.
Smart pointers let you take some syntactical shortcuts in my opinion, however, transactions are Adesk's *preferred* method is transactions and have their own benefits.

Glenn;

Yes, I want to know not just one method or way... great comments.


Thanks!

Alexander Rivilis

  • Bull Frog
  • Posts: 212
  • Programmer from Kyiv (Ukraine)
Re: Add row in a Table - Question
« Reply #18 on: March 17, 2006, 11:20:02 AM »
I see you are using cast(), what is the benefit on that Alex ?
I'd like using CLASS::cast() method. I think that this method more elegant than isKindOf(CLASS::desc() )   and can be useful for classes derived from CLASS.
And what about this code: http://www.theswamp.org/index.php?topic=9125.msg117509#msg117509 ?
For immediately updating graphic I used acTransactionManagerPtr()->flushGraphics()

LE

  • Guest
Re: Add row in a Table - Question
« Reply #19 on: March 17, 2006, 11:30:17 AM »
I'd like using CLASS::cast() method. I think that this method more elegant than isKindOf(CLASS::desc() )   and can be useful for classes derived from CLASS.
And what about this code: http://www.theswamp.org/index.php?topic=9125.msg117509#msg117509 ?
For immediately updating graphic I used acTransactionManagerPtr()->flushGraphics()

Thank you Alex;

Great sample BTW.... !

I would be implementing your code style in my next training code....  :-)

[I'm still learning....]

Regards,
Luis.

LE

  • Guest
Re: Add row in a Table - Question
« Reply #20 on: March 17, 2006, 11:46:46 AM »
Good;

I just tested your code Alex, and works nice, I will be using this as a template, for my future coding!... and it is great, Class is something I still need to digest...  :-)


Thanks.

Code: [Select]
class Trans
{
public:
 }

Alexander Rivilis

  • Bull Frog
  • Posts: 212
  • Programmer from Kyiv (Ukraine)
Re: Add row in a Table - Question
« Reply #21 on: March 17, 2006, 12:00:20 PM »
I just tested your code Alex, and works nice, I will be using this as a template, for my future coding!... and it is great, Class is something I still need to digest...  :-)
:-) I am glad to help you!!!