几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-05, 11:37 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】given an attribute ptr how can i get to a field

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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】get list of attribute tags yang686526 DirectDWG 0 2009-05-05 11:16 AM
【转帖】block attribute iterator problem yang686526 DirectDWG 0 2009-05-04 04:45 PM
【转帖】attribute and attributedefinition isinvisible90 yang686526 DirectDWG 0 2009-05-04 04:21 PM
【转帖】attribute error yang686526 SolidWorks二次开发 0 2009-04-13 09:07 AM


所有的时间均为北京时间。 现在的时间是 09:03 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多