ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

XData or something else?

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
mihajlovic.milosh
901 Views, 11 Replies

XData or something else?

 

 

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?

11 REPLIES 11
Message 2 of 12

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 12

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
Message 4 of 12

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?
Message 5 of 12

acdbEvaluateFields function can help you to update fields.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 6 of 12

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();
	}

 

Message 7 of 12

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? 

Message 8 of 12

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.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 9 of 12

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

Message 10 of 12


@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?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 11 of 12

Yes.

 

Though I have one more question. Can I somehow make persistent editor reactor that would load with the concrete DWG file?

Message 12 of 12

No.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost