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


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


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-16, 10:35 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】objectarx&dummies教程(七)——containers

objectarx&dummies教程(七)——containers
objectarx&dummies教程(七)——containers
class 7 - containers
hello,
on this class i will present the concepts and features of objectarx container objects. we have talked a little bit about them before but now we will go into further details.
introduction
the container object purpose is to store and manage objects of the same type or class. there are two types of containers: symbol tables and dictionaries. each type of container has some specific functionalities that were designed to allow easy and efficient access methods.
symbol tables
this type of container is designed to store the so called records. each symbol table object store its records using an unique entry name. through this entry you can obtain the record pointer and read or write information. the container may also receive new entries or even has entries removed (in case they are not used by other objects).
to walk through an object container entries you will need to use a proper iterator which will allow you to get entries and access its objects. autocad has some symbol tables to store layers, linetypes, text styles and other objects. as these containers work almost the same way, there is a common base class for each of symbol tables, its records and the proper iterators.
the symbol table class tree is as follows:
acdbsymboltable
acdbabstractviewtable
acdbviewporttable
acdbviewtable
acdbblocktable
acdbdimstyletable
acdblayertable
acdblinetypetable
acdbregapptable
acdbtextstyletable
acdbucstable
acdbsymboltablerecord
acdbabstractviewtablerecord
acdbviewporttablerecord
acdbviewtablerecord
acdbblocktablerecord
acdbdimstyletablerecord
acdblayertablerecord
acdblinetypetablerecord
acdbregapptable
acdbtextstyletable
acdbucstable
acdbsymboltableiterator
acdbabstractviewtableiterator
acdbviewporttableiterator
acdbviewtableiterator
acdbblocktableiterator
acdbdimstyletableiterator
acdblayertableiterator
acdblinetypetableiterator
acdbregapptableiterator
acdbtextstyletableiterator
acdbucstableiterator
so, to create a layer, for instance, you will need to:
open current database;
open acdblayertable (for write);
create an acdblayertablerecord (using new operator);
configure the acdblayertablerecord;
add it to acdblayertable which is its proper container;
close the record;
close the container.
void createlayer() {
acdblayertable *playertbl = null;
acdbhostapplicationservices()->workingdatabase()
->getsymboltable(playertbl, acdb::kforwrite);
if (!playertbl->has("mylayer")) {
acdblayertablerecord *playertblrcd = new acdblayertablerecord;
playertblrcd->setname("mylayer");
accmcolor color;
color.setcolorindex(1); // red
playertblrcd->setcolor(color);
playertbl->add(playertblrcd);
playertblrcd->close();
} else acutprintf("\nlayer already exists");
playertbl->close();
}
to list all existing layers:
open current database;
open acdblayertable (for read);
create an acdblayertableiterator;
perform a loop through container entries;
get the key name for each entry;
close the container.
void iteratelayers() {
acdblayertable* playertbl = null;
acdbhostapplicationservices()->workingdatabase()
->getsymboltable(playertbl, acdb::kforread);
acdblayertableiterator* playeriterator;
playertbl->newiterator(playeriterator);
acdblayertablerecord* playertblrcd;
char *plname;
for (; !playeriterator->done(); playeriterator->step()) {
playeriterator->getrecord(playertblrcd, acdb::kforread);
playertblrcd->getname(plname);
playertblrcd->close();
acutprintf("\nlayer name: %s",plname);
acutdelstring(plname);
}
delete playeriterator;
playertbl->close();
}
dictionaries
this type of container is designed to store generic acdbobject derived class objects. this container is very useful because we can also store our custom objects inside it. the dictionary structure is much like a tree structure where we have nodes and entries. inside the same node, entries can not repeat its name because they need to be unique inside the same level. these are the so called key entries and each key entry will map to an acdbobject pointer which can be retrieved directly or through an interator (acdbdictionaryiterator).
to store an object we need to create an entry using the setat() method passing also the object pointer which we already have instantiated with the new operator. after add this object we need to close() it. acdbdictionary container will return the given acdbobjectid for each entry.
this container is also used by some autocad features like groups and multiline styles. we will cover more about dictionaries on the custom objects chapter.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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



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


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