How do I read Custom Properties/Attributes from an anonymous object?

How do I read Custom Properties/Attributes from an anonymous object?

jlobo2
Advocate Advocate
2,057 Views
8 Replies
Message 1 of 9

How do I read Custom Properties/Attributes from an anonymous object?

jlobo2
Advocate
Advocate

How do I read Custom Properties/Attributes from an anonymous object?

 

I can read the attributes of the object, but not sure how to read the below:

 

CustomProperites.jpg

 

Any help will be greatly appreciated.

0 Likes
Accepted solutions (1)
2,058 Views
8 Replies
Replies (8)
Message 2 of 9

Alexander.Rivilis
Mentor
Mentor

C# or C++? If C# - you (as usually)  created topic in wrong forum. Right forum is: https://forums.autodesk.com/t5/net/bd-p/152

Also no difference between getting custom properties from anonymous and named block references.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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

0 Likes
Message 3 of 9

jlobo2
Advocate
Advocate

Yes @Alexander.Rivilis , I did post it on the .NET forum as well.

https://forums.autodesk.com/t5/net/how-do-i-read-custom-properties-attributes-from-an-anonymous/td-p...

My bad, I thought this forum was for C++.

 

How to access the custom properties for the block references or anonymous blocks in C++ though?

Thank You for your help once again.

0 Likes
Message 4 of 9

Alexander.Rivilis
Mentor
Mentor
Accepted solution

@jlobo2 wrote:

How to access the custom properties for the block references or anonymous blocks in C++ though?

 


https://adndevblog.typepad.com/autocad/2012/08/how-to-access-and-modify-a-dynamicblockreference-prop...

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 5 of 9

jlobo2
Advocate
Advocate

@Alexander.Rivilis , How do I set the property value for the block?

I am using the following code, but it does not update the value.

 

if (wcscmp(blkProp.propertyName().kACharPtr(), L"Visibility1") == 0)
{
	AfxMessageBox(_T("Visibility1 Found"));
	blkProp.setValue(_T("TEST"));
}

Also, how do I access or print this following value in TCHAR?

 

 

//Get allowed values for property
AcDbEvalVariantArray evalAry;
if ((err = blkProp.getAllowedValues(evalAry)) == Acad::eOk)
{
if (evalAry.length() >= 1) { AcDbEvalVariant eval = evalAry[1];
// How do I access this value as a TCHAR or string
// to print in the command line?
if (!blkProp.readOnly()) { if ((err = blkProp.setValue(eval)) != Acad::eOk) { acutPrintf(L"\nError setting property value..."); } } } }

 

 

0 Likes
Message 6 of 9

Alexander.Rivilis
Mentor
Mentor

Not

AcDbEvalVariant eval = evalAry[1];

but

AcDbEvalVariant eval = evalAry[0];

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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

0 Likes
Message 7 of 9

jlobo2
Advocate
Advocate

Ok. I am getting a hang of it now. Basically we are accessing from a set of pre-defined objects and modifying the custom properties to dynamically change it. 

@Alexander.Rivilis  am I on the right track?

 

Also, how do I access the text value of the property?

if (wcscmp(blkProp.propertyName().kACharPtr(), L"Visibility1") == 0)
{
	AfxMessageBox(_T("Visibility1 Found"));

// How to display the value as text? AfxMessageBox( blkProp.value() ); blkProp.setValue(_T("B1")); }
0 Likes
Message 8 of 9

jlobo2
Advocate
Advocate

@Alexander.Rivilis  Nevermind - I got it working through the code in C#.NET

 

Thanks a lot once again for your help. I really appreciate it.

0 Likes
Message 9 of 9

Alexander.Rivilis
Mentor
Mentor

As far as AcDbEvalVariant is derived from struct resbuf, you can use function dxfToStr  or printResbufChain (which defined in ObjectARX SDK samples\database\ARXDBG\AcadUtils\ArxDbgRbList.cpp) to convert AcDbEvalVariant to CString

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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