Exceptions happen while access AcDbAssocVariable

Hi Team

When I try to access user parameters, exceptions happen while the same code works in ARX.Otherwise, is there a safe way to access user parameters, I traverse current working database space in present.

Please see the attachments for a clear view.

Best Regards,
William.

////////////////////////////////////
Hi William,

Thank you very much for your detailed report/code!

First, I have to say that, unfortunately, due to some technical reasons, we cannot apply fixes to previous BricsCAD versions, such as V22, but only to the current or future versions.

The bad news is that there are some problems with AcDbAssocVariable class in BricsCAD V23 as well. We currently have a related task, but that is not implemented yet:
[BRX] Implement missing AcDbAssocVariable functions

May I ask you to attach here a minimal test .dwg, if possible, please? I would log that and this test case in the above-mentioned task, in order to check/verify if the functionality is completed.

If the development team will implement solution/s in a future release, this support request number and/or a related fix resolution/description will be mentioned in the accompanying release notes.

Kind regards,
Eugen

////////////////////////////////////
Hi William,

After reconsideration, that task is about specific methods only:

Acad::ErrorStatus AcDbAssocVariable::evaluateExpression(AcDbObjectIdArray& idsObject, AcArray& evalValues, AcDbEvalVariant& expressionEval, AcString& error) const
Acad::ErrorStatus AcDbAssocVariable::evaluateExpression(const AcString& expression, const AcString& nameEvaluator, const AcDbObjectId& objectIdNetwork, AcDbEvalVariant& valEvaluatedExpression, AcString& assignedSymbolName, AcString& error)
but I see:
const AcString& name() const;
const AcString& expression() const;
used by you, are implemented.

However, there are other possible dependent classes not implemented for now:
AcDbAssocManager;
AcDbAssocAction;
AcDbAssocActionBody;
AcDbAssocDependency;
AcDbAssocDependencyBody

A minimal .dwg would be very useful, please.
Thank you in advance for your help!

Kind regards,
Eugen
Hi William,

Thank you very much for your drawings/help!

I can confirm a crash with current V23 sources. I logged a new task in our development system:
[BRX] AcDbAssocVariable::name() and/or AcDbAssocVariable::expression() lead/s to BricsCAD exit/crash, when calling OdString::operator=()

As mentioned before, if a BricsCAD fix is added in the future, it will be mentioned in the accompanying Release Notes.

I will close this for now, but please feel free to reopen the SR by adding a Reply, if needed.

All the best,
Eugen
/////////////////////////////////////////
Hi William, Owen,

@William:
Update:
The development team (Owen Wengerd) mentioned there are two issues with the acutPrintf() statement (now corrected) like this:

const AcString acstr1 = pVariable->name();
const AcString acstr2 = pVariable->expression();
acutPrintf(_T("\n Address: %p, ParamName: %s, ParamExpression:%s"), pVariable, acstr1.constPtr(), acstr2.constPtr());
1. It is necessary to call AcString::constPtr() to return a pointer to the actual string buffer, otherwise it tries to interpret the AcString class instance as a string (and gets garbage).

2. There is a quirk in our AcDbAssocVariable class (and a few others) in that every time you call a member function that returns an AcString& (that is, a reference to an AcString), it recycles an internal AcString member to hold the returned string. Therefore, you have to make a copy of the returned AcString from one call, before you call a different member that recycles that internal AcString member. For that reason, it is necessary to first store the two queried strings locally, so that the second call does not clobber the result string from the first.

The actual crash issues after calling AcDbAssocVariable::name() and/or AcDbAssocVariable::expression() are intended to be fixed in a future update, please check the release notes.

Thank you for your help!

All the best,
Eugen