几何尺寸与公差论坛------致力于产品几何量公差标准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-04, 04:22 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】attribute issues

attribute issues
attribute issues
i'm having intermittent issues related to adding attributes to block references. it appears that adding attributes to a particular block causes corruption issues in some files.
(this appears to be the case, as when i comment out the line of code that appends the attribute to the block reference, no problems occur)
here's the code snippet i'm working with:
code:
/*function: inserterrmark
*purpose: inserts an error marker at the specified coordinates in the specified database.
*input: (oddbdatabaseptr) pdb - database to insert into.
* (odgepoint3d) insertpt - point to put the error at
* (odstring) lbltext - text to print on the marker
*output: (oddbobjectid) - id of the new error marker
*/
oddbobjectid inserterrmark(oddbdatabaseptr pdb, odgepoint3d insertpt, odstring lbltext){
//make sure error block exists
oddbobjectid errblock = createerrorblock(pdb, "general_error");
//open record to insert error mark
oddbblockreferenceptr newblk = oddbblockreference::createobject();
//set to block def
newblk->setblocktablerecord(errblock);
if(insertpt.x==0&&insertpt.y==0){
cerr<<"("<<insertpt.x<<", "<<insertpt.y<<")"<<endl;
}
//insert point
newblk->setposition(insertpt);
//add text attribute.... connect it back the the attributedef attached to the blockdef
oddbblocktablerecordptr blkent = errblock.safeopenobject(oddb::kforwrite);
if(blkent->hasattributedefinitions()){
oddbobjectiteratorptr attptr = blkent->newiterator();
for(; !attptr->done(); attptr->step()){
if(strcmp(attptr->entity()->isa()->name(),"acdbattributedefinition")==0){
oddbattributeptr def = oddbattribute::createobject();
odgematrix3d mat3d;
mat3d.settoidentity();
def->setattributefromblock(oddbattributedefinitionptr(attptr->entity()), mat3d);
def->setposition(insertpt);
def->setalignmentpoint(insertpt);
cout<<"insert point: ("<<insertpt.x<<", "<<insertpt.y<<")"<<endl;
cout<<def->textstring();
def->settextstring(lbltext);
cout<<"->"<<def->textstring()<<endl;
def->setinvisible(false);
newblk->appendattribute(def);
}
}

oddbobjectiteratorptr attiter = newblk->attributeiterator();
int numattrib = 0;
for (; !attiter->done(); attiter->step()){
numattrib++;
}
}
//insert into modelspace
if(addentity(pdb, newblk)==0){
cerr<<"adding to error"<<endl;
if(!haslayer(pdb,"error")){
oddbobjectid tmp = addlayer(pdb, "error");
}
newblk->setlayer("error");
cerr<<"added to error"<<endl;

//insert point
newblk->setposition(insertpt);
}
being that i am restricted from sharing these files, can you recommend an area for me to look into that might cause this type of issue?
hi,
your code seems to be correct.
what means "causes corruption issues" ?
try to generate such file with no confidential information (or remove all such information from existing bug file).
might have been corrupt
when i attempted to create a file without the confidential info, i could not reproduce the error, so i think the file might be corrupt. i'll let you know if i run into it again though.
if you have this problem not always but with some specific file(s) try to check them with autocad's recover command and in odamfcapp sample (file/recover)
they may report errors.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】are these issues regreessions in dd1.14.02 for net2003 yang686526 DirectDWG 0 2009-05-04 04:10 PM
【转帖】positional issues, sorry if this is a repos yang686526 American standards 0 2009-04-29 09:21 PM
【转帖】sw 2009 issues yang686526 SolidWorks二次开发 0 2009-04-13 02:44 PM
【转帖】bill of material issues in solidworks yang686526 SolidWorks二次开发 0 2009-04-13 09:16 AM


所有的时间均为北京时间。 现在的时间是 01:20 PM.


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