ObjectARX

Reply
Contributor
mihajlovic.milosh
Posts: 11
Registered: ‎11-07-2011
Message 1 of 12 (275 Views)
Accepted Solution

XData or something else?

275 Views, 11 Replies
04-10-2012 09:19 AM

 

 

I need to save some data for each block reference and then with reactors update block attributes using that saved data and geometric properties of that block. For instance, one block attribute contains X coordinate, prefix text, suffix text and coordinate precision. Each time the block is moved, the program needs to update X coordinate.

 

Sp, what should I use: xData or something else?

acdbEvaluateFields function can help you to update fields.

The problem was that you cannot call acdbEvaluateFields() when closing the object. I had to remember which object was edited in an editor reactor and then in commandEnded() funciton call acdbEvaluateFields().

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 2 of 12 (272 Views)

Re: XData or something else?

04-10-2012 09:25 AM in reply to: mihajlovic.milosh

Hi,

 

>> Each time the block is moved, the program needs to update X coordinate.

I don't know what AutoCAD-version you are using, but why don't you use the built-in fields in attributes (>>>details<<<)? If you add a field into the attribute that grabs the insertion-X from your blockreference everything is done without any programming!

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Distinguished Mentor
owenwengerd
Posts: 635
Registered: ‎08-06-2002
Message 3 of 12 (270 Views)

Re: XData or something else?

04-10-2012 09:25 AM in reply to: mihajlovic.milosh

Unless you must support very old versions of AutoCAD, I would use a field and let AutoCAD do the work. Otherwise, xdata would be fine if your data is always very small. If there's a potential for using up all the xdata space, an extension dictionary would be the next choice.

--
Owen Wengerd
ManuSoft
Contributor
mihajlovic.milosh
Posts: 11
Registered: ‎11-07-2011
Message 4 of 12 (266 Views)

Re: XData or something else?

04-10-2012 09:42 AM in reply to: mihajlovic.milosh
Actually, I am using fields right now. But I don't know how to update fields from the reactor. When I try to regen from reactor acad crashes... Any thoughts?
Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 5 of 12 (262 Views)

Re: XData or something else?

04-10-2012 10:18 AM in reply to: mihajlovic.milosh
acdbEvaluateFields function can help you to update fields.

Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
mihajlovic.milosh
Posts: 11
Registered: ‎11-07-2011
Message 6 of 12 (252 Views)

Re: XData or something else?

04-10-2012 03:52 PM in reply to: mihajlovic.milosh

Thank you.

But this doesn't work (it raises FATAL ERROR dialog in AutoCAD):

 

	void modified(const AcDbObject* dbObj) {
		AcDbObject *pBlkRef;
		ErrorStatus err = acdbOpenObject(pBlkRef, dbObj->objectId(), AcDb::kForWrite);
		if (err != eOk) {
			pBlkRef->close();
			return;
		}
		err = acdbEvaluateFields(dbObj->objectId(), AcDbField::kAutomatic);
		if (err != eOk) {
			pBlkRef->close();
			return;
		}
		pBlkRef->close();
	}

 

Contributor
mihajlovic.milosh
Posts: 11
Registered: ‎11-07-2011
Message 7 of 12 (243 Views)

Re: XData or something else?

04-10-2012 06:37 PM in reply to: mihajlovic.milosh

OK I realized what's the problem.

 

The reactor's modified() function is called when object->close() function is invoked. So acdbEvaluateFields() throws eWasNotified. But I need to call acdbEvaluateFields() from the modified() function. I also tried with objectClosed() method - the same story...

 

Does somebody have a clue how can I solve this? 

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 8 of 12 (240 Views)

Re: XData or something else?

04-10-2012 10:14 PM in reply to: mihajlovic.milosh

What about:

void modified(const AcDbObject* dbObj) 
{
   acdbEvaluateFields(dbObj->objectId(), AcDbField::kAutomatic);
}

?

IMHO. This is not the best place to call acdbEvaluateFields. I would prefer to use a command-reactor (for example, commandEnded). modified-reactor can collect AcDbObjectId of modified objects in order to call acdbEvaluateFields in command-reactor.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
mihajlovic.milosh
Posts: 11
Registered: ‎11-07-2011
Message 9 of 12 (216 Views)

Re: XData or something else?

04-17-2012 05:38 AM in reply to: Alexander.Rivilis

The problem was that you cannot call acdbEvaluateFields() when closing the object. I had to remember which object was edited in an editor reactor and then in commandEnded() funciton call acdbEvaluateFields().

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 10 of 12 (213 Views)

Re: XData or something else?

04-17-2012 05:58 AM in reply to: mihajlovic.milosh

mihajlovic.milosh wrote:

The problem was that you cannot call acdbEvaluateFields() when closing the object. I had to remember which object was edited in an editor reactor and then in commandEnded() funciton call acdbEvaluateFields().


Now OK?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.