given an attribute ptr how can i get to a field
given an attribute ptr how can i get to a field
i am updating attribute values
i have an attribute which is linked to an acad field
for instance, an attribute which is linked to the "title" or "author" field
//here is the att ptr
oddbattributeptr attptr = attiterator->objectid().safeopenobject();
//then, i believe this would determine it is attached to a field
if(attptr->hasfields())
{
//how do i locate the field this attribute is linked to, then update its value?
}
thanks in advance
bill
try something like this.
code:
oddbobjectidarray ids; ids.append(attptr->objectid());
:

ddbevaluatefields(attptr->database(), oddbfield::kdemand|oddbfield::kregen, &ids);
evaluator module should have been loaded for evaluation to work
vladimir
thanks vladimir, i will try that
just so we are clear, the "fields" i am referring to are perhaps more appropriately called "properties", for instance title, author, so on.
i get confused looking at the docs, in spots referring to fields, does that mean dxf code/value sets, or does it mean field entities.
also, i have th drawing open, but i am not rendering it in any way, i am purely reading through it to get values, or put values then update the file.
thanks for the reply
quote:
just so we are clear, the "fields" i am referring to are perhaps more appropriately called "properties", for instance title, author, so on.
i get confused looking at the docs, in spots referring to fields, does that mean dxf code/value sets, or does it mean field entities.
i'm not sure i understand the question. can you elaborate please?
vladimir
yes, its confusing
in acad dwg, there are properties (title,author, etc)
also one can add custom properties
then, while defining an attribute, one can select a property, but the interface at this point calls it a field
the end result is that the new attribute default value is the value in the property
then, normally, that attribute would get bound into a block, and the block would be inserted.
at this point, in the acad file menu, properties pick, you get a dialog where you can edit the properties.
if you do so, then regen the drawing, you will see the linked attribute take on the property string value.
i have attached a small dwg with such a block.
bring it up, and use file/property to edit the subject property field.
regen the drawing, or save and reopen it, and you will see the bottom attribute update to the new subject string.
what i want to do is, after discovering that attribute is linked (hasfields() == t), i want to get a handle to the field. in this case, that would be the subject property. then i want to update the string value of that field, and have my new value set in both the subject property and the attribute insertion.
attached files (111.9 kb, 1 views)
if you have acad, you may read more about fileds in arx developers guide.
for your purposes the code i posted suits well enough.
if you want to access the field itself, it can be obtained via getfield(l"text")
vladimir
thanks for the reply vladimir;
my problem is, i dont have the field name to generate the "text" from.
thats what i want to discover. i dont see how to traverse from the attribute instance up to the field name.
given the field name string, i agree, your solution is perfect.
l"text" is a name
vladimir
thanks for the reply.
this is the way i undertand it;
for instance, if the subject property is linked to an attribute, using l"subject" would change the desired property.
the problem is, if you have only the attribute insertion, you can discover it has a linked property (hasfields() returns t), but, how do you discover which property. without knowing which property, you dont know the name (in this case l"subject") to supply.
or are you saying that the actual string l"text" is somehow going to do something for me? that would be something.
you do not have to care about the internal field structure. if you want to control "subject" type field updating, you have to overload corresponding field evaluator. you may take current field evaluator as an example. see e.g. examples/exfieldevaluator/exfieldevaluator.cpp,140 (odvarevaluator::evaluate)
evaluator module should be loaded into application like in
examples/win/odamfcapp/odamfcapp.cpp, 670
vladimir