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

rotated dimension and dimassoc problem
rotated dimension and dimassoc problem
hallo
i have a problem with rotated dimension and the osnappointrefs. i think the creation of the dimension / extensiondictionary and osnappointrefs are correct.
when i load the dwg file in autocad all is ok. but when i move a point (point is associative in the dimension) of the polyline then the dimension is corrupt.
what is wrong ????
code :
....
oddbrotateddimensionptr pad = oddbrotateddimension::createobject();
oddbobjectid pobjectid = pblock->appendoddbentity(pad);
pad->setdatabasedefaults(pdb);
pad->setxline1point(point1);
pad->setxline2point(point2);
pad->setdimlinepoint(position);
pad->setrotation(rotation);
pad->usedefaulttextposition();
pad->createextensiondictionary();
pad->setlayer(layerid, true);
....
oddbdictionaryptr dict = pad->extensiondictionary().safeopenobject(oddb::kforwr ite);
oddbdimassocptr dimassoc = oddbdimassoc::createobject();
dimassoc->setdimension(pobjectid);
dimassoc->setrotateddimtype(oddbdimassoc::kparallel);
oddbobjectid dimassid = dict->setat("acad_dimassoc", dimassoc);
oddbosnappointrefptr pointref;
int pointindex=oddbdimassoc::kfirstpoint;
// startpunkt
pointref = exportdimpointref(dimassid, dimassoc,
oddb::kosmodestart,
(oddbdimassoc::associativity)pointindex++,
apu);
// endpunkt
pointref = exportdimpointref(dimassid, dimassoc,
oddb::kosmodeend,
(oddbdimassoc::associativity)pointindex++,
epu);
// setting reactors
if ( !pointref.isnull() ) {
oddbobjectid pobjectid = (const oddbobjectid&) apu->pobjurs;
oddb2dpolylineptr p2dpoly = pobjectid.safeopenobject(oddb::kforwrite);
pad->addpersistentreactor(dimassid);
p2dpoly->addpersistentreactor(dimassid);
pad->recomputedimblock(true);
}
oddbosnappointrefptr dgnexport::exportdimpointref (const oddbobjectid &dimassid,
oddbdimassocptr dimassoc,
oddb:snapmode snapmode,
oddbdimassoc::associativity pointindex,
punk tpu)
{
oddbosnappointrefptr pointref;
// assoziate vermassung erzeugen
if ( tpu && tpu->pobjurs ) {
oddbobjectid pobjectid = (const oddbobjectid&) tpu->pobjurs;
oddbobjectptr pobject = pobjectid.safeopenobject();
oduint32 isubindex = tpu->tmz;
if ( !pobject.isnull() ) {
if (pobject->iskindof(oddb2dpolyline::desc()) ) {
oddbobjectid pvertexid = (const oddbobjectid&) tpu->dum;
oddb2dvertexptr pvertex = pvertexid.safeopenobject();
//oddb2dvertexptr pvertex = pvertexid.safeopenobject(oddb::kforwrite);
//pvertex->addpersistentreactor(dimassid);
if ( !pvertex.isnull() ) {
// oddb2dpolylineptr p2dpoly = pobjectid.safeopenobject(oddb::kforwrite);
pointref = oddbosnappointref::createobject();
pointref->osnappoint() = pvertex->position();
// if (pointindex == oddbdimassoc::kfirstpoint) {
// p2dpoly->addpersistentreactor(dimassid);
// }
}
if ( !pointref.isnull() ) {
pointref->setosnapmode(snapmode);
if ( snapmode == oddb::kosmodeend ) {
pointref->setnearosnap(1.0);
} else {
pointref->setnearosnap(0.0);
}
pointref->mainentity().objectids().append(pobjectid);
pointref->mainentity().subentid().settype(oddb::kedgesubent type);
pointref->mainentity().subentid().setindex(isubindex);
// dimassoc->setosnappointref((oddbdimassoc::associativity)poi ntindex++, pointref);
dimassoc->setosnappointref(pointindex, pointref);
}
}
}
return(pointref);
}
attached files
hello,
you need to add in your code ( method oddbosnappointrefptr dgnexport::exportdimpointref ) after line
pointref->mainentity().objectids().append(pobjectid);
this line
pointref->mainentity().objectids().append(pvertexid);
best regards,
sergey z.
hallo,
we have tested this in our code and this change only little bit. only the first point from
the "diagonal" dimension can be moved and the measurement is correct. by all other movements the dimension will become incorrect !!!! ????
attached files (25.3 kb, 1 views)

hello,
i found what you need
pointref->setosnaptype(oddb::kosmodeend); for second point for wrong situation. it defines start or end endge of polyline is used. or you may set other vertex without change osnap type.
unfortunately i can't help with rules which acad uses for creating associate and i don't know any reference.
best regards,
sergey z.
hallo,
we have solved the problem with the rotated dimension. but we have same trouble with the diameter dimension. when we change the circle in acad the dimension will be corrupt like
the rotated dimension. we have exported a new diameter dimension in acad and compared it with our export. but we do not understand the differences !!!
what is wrong !!!! ?????
with no example it is hard to code an export !!!!!
our code.
oddbobjectid dgnexport::exportdiametricdimension (oddbdatabase* pdb,
oddbblocktablerecord* pblock,
const oddbobjectid& layerid,
const oddbobjectid& dimstyleid,
const odgepoint3d& point1,
const odgepoint3d& point2,
const odgepoint3d& position,
double tx_height,
oddbmtext::attachmentpoint tx_attachment,
const odgepoint3d& tx_position,
double tx_rotation,
oduint16 tx_just,
oduint16 tx_dec,
elem tel,
punk mpu)
{
uwrd aielrgb[3];
swrd ielltyp, ielcolor;
oddbobjectid linetypeid;
oddbdiametricdimensionptr pad = oddbdiametricdimension::createobject();
oddbobjectid pobjectid = pblock->appendoddbentity(pad);
pad->setdatabasedefaults(pdb);
// vermassungs-stil setzen
pad->setdimensionstyle(dimstyleid);
pad->setchordpoint(point1);
pad->setfarchordpoint(point2);
// keine fuehrungslinie fuer masstext setzen
pad->setleaderlength(0.);
// pad->usedefaulttextposition();
pad->createextensiondictionary();
pad->setlayer(layerid, true);
// vm-texthoehe setzen
pad->setdimtxt(tx_height);
// vm-textausrichtung setzen
// pad->settextattachment(tx_attachment);
// vm-textposition setzen
// pad->settextposition(tx_position);
// vm-textwinkel setzen
// pad->settextrotation(tx_rotation);
// vm-text parallel zur masslinie
// pad->setdimtih(false);
// vm-textlage: 0=zentriert, 1=links, 2=rechts
pad->setdimjust(tx_just);
// vm-text: nachkommastellen
pad->setdimdec(tx_dec);
// element-linientyp holen und setzen
ielltyp = get_ellin(tel);
linetypeid = getlinetypid(ielltyp);
if ( !linetypeid.isnull() ) {
pad->setlinetype(linetypeid);
}
// element-linenbreite setzen
dreal relstartwidth = getstartwidth(tel, punull);
if ( relstartwidth > 0. ) {
oddb::lineweight lineweight = convertlinewidth_lineweight(relstartwidth);
pad->setlineweight(lineweight);
}
// element-farbe holen und setzen
ielcolor = getcolorrgb(tel, wel_frb, aielrgb);
if ( ielcolor == gut ) {
odcmcolor col;
col.setcolormethod(odcmentitycolor::kbycolor);
col.setrgb(aielrgb[0], aielrgb[1], aielrgb[2]);
pad->setcolor(col, true);
}
// assoziate vermassung erzeugen
if ( (mpu) &&
(mpu->pobjurs) ) {
oddbdictionaryptr dict = pad->extensiondictionary().safeopenobject(oddb::kforwr ite);
oddbdimassocptr dimassoc = oddbdimassoc::createobject();
dimassoc->setdimension(pobjectid);
dimassoc->setrotateddimtype(oddbdimassoc::kparallel);
oddbobjectid dimassid = dict->setat("acad_dimassoc", dimassoc);
oddbobjectid pobjectid = (const oddbobjectid&) mpu->pobjurs;
oddbcircleptr pcircle = pobjectid.safeopenobject(oddb::kforwrite);
oddbosnappointrefptr pointref = oddbosnappointref::createobject();
pointref->osnappoint() = pcircle->center();
pointref->setosnapmode(oddb::kosmodecen);
pointref->setnearosnap(0.0);
pointref->mainentity().objectids().append(pobjectid);
pointref->mainentity().subentid().settype(oddb::kedgesubent type);
dimassoc->setosnappointref(oddbdimassoc::kfirstpoint, pointref);
// setting reactors
pcircle->addpersistentreactor(dimassid);
pad->addpersistentreactor(dimassid);
}
return(pobjectid);
}
hello,
try to use
dimassoc->setosnappointref(oddbdimassoc::ksecondpoint, pointref);
instead of
dimassoc->setosnappointref(oddbdimassoc::kfirstpoint, pointref);
acad use second point for associativity with diametric and radial dimensions. i don't know why.
best regards,
sergey z.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】dimassoc yang686526 DirectDWG 0 2009-05-04 07:31 PM


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


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