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

a dimension error
a dimension error
the error occurs when i export a line and a dimension. opening the attachment file drawing10.dwg, the left is the correct dimension(it's a named block,and is inserted into the drawing). the right is the line and the wrong dimension. what does cause this error? now the dwgdirect library i am using is 1.10 update 1.
attached files
if i understood you correctly you create a dimension which should look like the picture at the left but it looks like the dimension at the right.
what code do you use to create it?
sergey slezkin
this is my code
yes, you are right!
//create a rotate dimension
oddbrotateddimensionptr protdim = ddbrotateddimension::createobject( );
//create a block to contain the visual representation(dimension lines and so on, return this block by its id)
oddbobjectid dimblockid;
dimblockid.setnull( );
//create block
char blkname[] = "*d"; // must be "*d"
oddbblocktablerecordptr ptmpblk = oddbblocktablerecord::createobject();
ptmpblk->setname( odstring( blkname ));
oddbblocktableptr pblocks = pdb->getblocktableid().safeopenobject( oddb::kforwrite );
//add this block to block table
pblocks->add( ptmpblk );
//write the block interior (entities to represent dimensions visually)
// first dimension line
oddblineptr pline = oddbline::createobject( );
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// second dimension line
oddblineptr pline = oddbline::createobject( );
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// extension line 1
oddblineptr pline = oddbline::createobject( );
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// extension line 2
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// add dimension text(oddbmtext) into the ptmpblk block
...........
ptmpblk->appendoddbentity(pmtext);
// add leader into the ptmpblk block
.................
ptmpblk->appendoddbentity(ppolyline);
dimblockid = ptmpblk->objectid( );
assert( !dimblockid.isnull() );
protdim->setdimblockid( dimblockid ); //set dim block id
//set dimension
protdim->setxline1point( odgepoint3d( planept0[0],planept0[1],planept0[2] ));
protdim->setxline2point( odgepoint3d( planept1[0],planept1[1],planept1[2] ));
protdim->setdimlinepoint( odgepoint3d( dimlinest[0],dimlinest[1],dimlinest[2] ));
protdim->setrotation( ...);
protdim->settextrotation(...);
protdim->setdimensiontext( textstr.getbuffer(textstr.getlength()+1) );
// set initial location of text .
protdim->settextposition( odgepoint3d(textpt[0],textpt[1],textpt[2]) );
protdim->settextattachment(oddbmtext::kmiddlecenter );
//add this dimension to the modelspace block
pmodelspaceblock->appendoddbentity( protdim );
the export is right in other case, e.g. the dimension line is parallel with the line. but in this case it is error.
quote:
originally posted by sergey slezkin
if i understood you correctly you create a dimension which should look like the picture at the left but it looks like the dimension at the right.
what code do you use to create it?
after a dimension is created or modified dd recomputes dimension block based on dimension properties and style.
the situation you have may happen if
1. coordinates you set to dimension realy specify a dimension you see as result.
2. dd incorrectly recomputes dimension block.
to determine the reason i need actual values you set to dimension.
it's possible to avoid recomputing of dimension block by dd if you call pdim->recordgraphicsmodified(false) after you set all properties to dimension.
please made the following experiment:
insert protdim->recordgraphicsmodified(false) at the end of your code.
save the file.
open the file with autocad. you see your block.
select the dimension and alter something in its properties (color for example). the dimension block gets recomputed by autocad.
if it's appearence is the same (except color) - dd was incorrectly recomputing the block.
if it's appearence changes - coordinates you set to dimension do not match block you generated.
sergey slezkin
the test result
thanks for your help!
following as you told me, i made this experiment.here is the result: after adding this code protdim->recordgraphicsmodified(false), exporting a case like the first post to autocad, the dimension looked like the dimension block. in autocad, modifing the dimension color, the block was not
modified by autocad. they looked like the same except the color.
quote:
originally posted by sergey slezkin
after a dimension is created or modified dd recomputes dimension block based on dimension properties and style.
the situation you have may happen if
1. coordinates you set to dimension realy specify a dimension you see as result.
2. dd incorrectly recomputes dimension block.
to determine the reason i need actual values you set to dimension.
it's possible to avoid recomputing of dimension block by dd if you call pdim->recordgraphicsmodified(false) after you set all properties to dimension.
please made the following experiment:
insert protdim->recordgraphicsmodified(false) at the end of your code.
save the file.
open the file with autocad. you see your block.
select the dimension and alter something in its properties (color for example). the dimension block gets recomputed by autocad.
if it's appearence is the same (except color) - dd was incorrectly recomputing the block.
if it's appearence changes - coordinates you set to dimension do not match block you generated.
so it seems that dd computes dimension block incorrectly. but i failed to reproduce it. probably it depends on specific coordinates and properties. it can be verified if you load the file you created in odamfcapp and invoke edit/recompute dimension blocks. if dimension appearence changes as a result of this operation please send me the file or post it to the forum.
sergey slezkin
i will test
i will test as you told me, and i will post the result as soon as possible.
quote:
originally posted by sergey slezkin
so it seems that dd computes dimension block incorrectly. but i failed to reproduce it. probably it depends on specific coordinates and properties. it can be verified if you load the file you created in odamfcapp and invoke edit/recompute dimension blocks. if dimension appearence changes as a result of this operation please send me the file or post it to the forum.
the right and error file
if you open the right.dwg file in odamfcapp, in blocktable section, you will see a block named "d", it is the right dimension block.when exporting this file, i called protdim->recordgraphicsmodified(false) function to prevent dwgdirect recompute this dimension block. and in model_space block, you will see a rotae dimension entity, this dimension entity refers to the block "d".
if you open the error.dwg file, you will see a block named "d" and a block named "*d5", the block "d" is the right block. i didn't create the block "*d5" in my code. maybe this block is created by dwgdirect by recomputing the right block "d". add the rotate dimension refers to the error block "*d5" but not to the right block "d". when exporting this file, i didn't call function recordgraphicsmodified(false) to prevent dwgdirect to recompute the right dimension block.the dwgdirect recomputes the block "d" incorrectly.
quote:
originally posted by enigma
i will test as you told me, and i will post the result as soon as possible.
attached files (11.8 kb, 3 views)
(12.5 kb, 3 views)

the dimension was created incorrectly.
open right.dwg with autocad. save it to dxf.
select the dimension and change its linetype for example to force revomputing of block. set it back to bylayer.
save the file to dxf.
comparing 2 files shows that autocad altered dimension line definition point (group code 10) to heal the entity.
dd treats such kind of incorrect data a bit differently. we'll fix it.
btw, the dimension entity has null dimstyle. both autocad and dd can live with it but it's better to set it to some value.
sergey slezkin
my dimension is wrong?
my "right" dimension is wrong? what's wrong cause autocad alteres dimension line definition point (group code 10) ? can you tell me in detail where is wrong in my code in the previous post and how can fix it?
quote:
originally posted by sergey slezkin
the dimension was created incorrectly.
open right.dwg with autocad. save it to dxf.
select the dimension and change its linetype for example to force revomputing of block. set it back to bylayer.
save the file to dxf.
comparing 2 files shows that autocad altered dimension line definition point (group code 10) to heal the entity.
dd treats such kind of incorrect data a bit differently. we'll fix it.
btw, the dimension entity has null dimstyle. both autocad and dd can live with it but it's better to set it to some value.
sorry, i was wrong saying that your dimension is created incorrectly. theoretically it's ok but:
your dimension has dimension line point set on extension line 1. autocad sets it on extension line 2. during block recomputing autocad updates it and sets it to the point on extension line 2 (group code 10 changes).
dd has a bug which has effect in your case (dim line point on extension line 1).
untill we fix it possible work around is to set dim line point on extension line 2 as autocad does.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】2005 link error yang686526 DirectDWG 0 2009-05-04 02:57 PM
【转帖】[arx]请问关于objcetarx开发包中函数问题! yang686526 ObjectARX(C++) 0 2009-04-16 12:43 PM
【转帖】error when i change the property of a dimension controlled b yang686526 SolidWorks二次开发 0 2009-04-13 10:44 AM
【转帖】macro to update dimension has an error message yang686526 SolidWorks二次开发 0 2009-04-12 06:56 PM


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


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