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

iterating modelspace entities
iterating modelspace entities
hi
i am just beginning to learn my way through the dwgdirect interface. i have three questions.
1. what are lightweight polylines stored as in the oddbdatabase?
2. how do i ensure it doesn't convert any polylines to lightweight when it loads the drawing?
3. is it possible to put this code fragment into a switch statement? i don't mind it all. i basically need to know what type of entity it is so that i can process it accordingly. just ineterested if it could be done.
here is the code and thanks in advance.
code:
void cdwgdirectdlg::readentities(oddbobjectid id)
{
oddbblocktablerecordptr pblock = id.safeopenobject(oddb::kforread);
oddbobjectiteratorptr pentiter;
// iterate modelspace entities
for(pentiter = pblock->newiterator(); !pentiter->done(); pentiter->step())
{
// get the entity
oddbentityptr pent = pentiter->entity(oddb::kforread);
// what type of entity is it?
if(pent->iskindof(oddb3dpolyline::desc()))
{
// 3d polyline
oddb3dpolylineptr pentpoly3d = pent;
// process object
}
else if(pent->iskindof(oddb2dpolyline::desc()))
{
// 2d polyline
oddb2dpolylineptr pentpoly2d = pent;
// process object
}
else if(pent->iskindof(oddbline::desc()))
{
// line
oddblineptr pentline = pent;
// process object
}
else if(pent->iskindof(oddbblockreference::desc()))
{
// block (insert)
oddbblockreferenceptr pentblock = pent;
// process object
}
else if(pent->iskindof(oddbtext::desc()))
{
// text
oddbtextptr penttext = pent;
// process object
}
else if(pent->iskindof(oddbpoint::desc()))
{
// point
oddbpointptr pentpoint = pent;
// process object
}
else
{
// object not required
}
}
}
andrew
1. lightweight polylines are represented by oddbpolyline class.
2. plinetype variable is responsible for converting polylines to lightweight polylines:
oddbhostappservises::getplinetype()
oddbhostappservices::setplinetype()
3. switch can't be used in this case. but instead of using "if-else if.." another method is possible (more efficient) - protocol extensions. see readex sample.
sergey slezkin
i think i will stay with the if/else/if ladder if it is an appropriate way of coding.
andrew
quote:
originally posted by sergey slezkin
2. plinetype variable is responsible for converting polylines to lightweight polylines:
oddbhostappservises::getplinetype()
oddbhostappservices::setplinetype()
i can't find these methods in the help file anywhere.
andrew
help file (as many other things in this world) is far from ideal.
look into oddbhostappservices.h (#include "sysvardefs.h") and into sysvardefs.h
sergey slezkin
i was seraching for getplinetype. i didn't realise that it was some different code with get##name or whatever.
i understand about not all things being perfect, but if something is not documented, one doesn't know it is there.
thanks for clarification.
andrew
quote:
originally posted by sergey slezkin
3. switch can't be used in this case. but instead of using "if-else if.." another method is possible (more efficient) - protocol extensions. see readex sample.
what happens if you don't cater for a object in the database?
andrew
sorry, but i don't understand the question.
sergey slezkin
sorry for confusion. you create dispatch classes for line, circle and text. and in code you call the disptach method.
what happens if you get a "point" which you don't have a dispatch class for?
make sense now?
andrew
in odreadex sample a dumper interface is added to oddbentity and some oddbentity's inheritants: line, circle, text.
if a line is quried for dumper interface - it's own dumper is returned. if a point is quried for dumper - oddbentity's dumper is returned.
if no dumper interface was added to oddbentity queryx will return null, assignment operator
dumperptr = ppointptr;
will throw exception.
protocol extension is similar to c++ virtual functions. adding an interface to the base class can be used to process "default" case of "switch" statement.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】how to get the color of merged entities yang686526 DirectDWG 0 2009-05-06 02:44 PM
【转帖】hatching entities yang686526 DirectDWG 0 2009-05-05 12:01 PM
【转帖】exploding block references = invisible entities yang686526 DirectDWG 0 2009-05-05 10:17 AM
【转帖】coping entities yang686526 DirectDWG 0 2009-05-04 06:18 PM
用vb编写的直齿圆柱齿轮参数化设计的完整程序 yang686526 ObjectARX(AutoLISP) 0 2009-04-27 11:10 AM


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


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