QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
9天前
查看: 1971|回复: 0
收起左侧

[原创] 【ARX 一步一步开发CAD】01-新建图层

[复制链接]
发表于 2013-12-8 19:01:47 | 显示全部楼层 |阅读模式 来自: 中国江苏南京

马上注册,结识高手,享用更多资源,轻松玩转三维网社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x

//打开图层表,打开方式为只写
+ _3 t1 ?9 P* uAcDbLayerTable * pLayerTable;7 u$ n4 F: Z0 B9 a: l2 G
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);

//初始化层表记录对象,并设定图层名称“NewLayer”
8 d6 r3 `3 s9 f* B5 kAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;
& L% i& e7 K. B4 B$ `, spLayerTableRecord->setName(L”NewLayer”);

//图层的其他属性(例如颜色、线形等)都用默认值
- Y; w% k+ P, |" L4 X4 {9 l//将新建的图层表记录添加到图层表中,并将图层表记录的ID
+ ^( x7 q; U0 M9 B/ L/ T0 c- b% O//保存到pLayerId中,作为函数的返回值. J+ B0 E9 a4 k1 g, s% s
AcCmColor color; // AcCmColor是ACAD颜色管理类
# O7 d" s5 \1 ycolor.setColorIndex(1); //红色
) G( C' u& c. m7 u9 i& [(color.setRGB (0,0,0)
9 C0 {' S8 A& x. y7 l8 P( m! [* ZpLayerTableRecord->setColor(color);$ V5 h  S/ Q" c2 \+ R
AcDbObjectId pLayerId;8 \6 G/ P9 S! d2 f
pLayerTable->add(pLayerId,pLayerTableRecord);- `( d2 S) G. }; Y* O% j
pLayerTable->close();
: X3 T' x( c9 Y1 @pLayerTableRecord->close();

示例:创建两个图层:
- g5 O/ t' ]( G+ G% Z2 n//打开图层表,打开方式为只写! e- @5 g" D5 F5 I' j
AcDbLayerTable * pLayerTable;
# u; |3 k# @0 o" d: [2 _AcDbLayerTableRecord * pLayerTableRecord ;
- u/ T; o+ N8 H& gAcCmColor color;// AcCmColor是ACAD颜色管理类
, V$ n: k' X  P/ z' _  e% A- CAcDbObjectId pLayerId;
& q5 D& h! F# qacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
1 ?( j9 U1 c* h( Z& Q//初始化层表记录对象,并设定图层名称“结-1”3 J. l# U, e, J( u+ H& w4 g. l1 j
pLayerTableRecord = new AcDbLayerTableRecord;. U. D8 ~* ^8 i8 }  C
pLayerTableRecord->setName(_T(“结-1″));
9 q( H! j5 k- H  w6 F5 Ucolor.setColorIndex(5);
+ }8 ~% Q* V4 W+ v1 _" r" IpLayerTableRecord->setColor(color);$ }( s2 x8 E+ n. q9 Y
pLayerTable->add(pLayerId,pLayerTableRecord);, D. E+ Y# J& j" |0 r9 \7 Z1 e+ N
pLayerTableRecord->close();( l( F: y6 y" I& |  R' ?' v, h. {
//设定图层名称“结-2”
# v8 G5 }; Z" r* y! T& _# ~pLayerTableRecord = new AcDbLayerTableRecord;
* J$ Q. t# ^# y& N1 {& z0 opLayerTableRecord->setName(_T(“结-2″));
* p9 @# y/ {) K) Wcolor.setColorIndex(1);: H2 E; |8 ?  Z4 G1 b; B3 N
pLayerTableRecord->setColor(color);
. M- V+ o  A3 |  \pLayerTable->add(pLayerId,pLayerTableRecord);
- k4 H) x; L$ a6 r! X, K# V9 npLayerTableRecord->close();
' a% Q0 D# m9 g) O* x3 bpLayerTable->close();


" X& A* y0 l3 s* f! j参考:http://www.colinchou.com/archives/236
( I  I2 O9 O0 o0 e6 e
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Licensed Copyright © 2016-2020 http://www.3dportal.cn/ All Rights Reserved 京 ICP备13008828号

小黑屋|手机版|Archiver|三维网 ( 京ICP备2023026364号-1 )

快速回复 返回顶部 返回列表