QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
7天前
查看: 2034|回复: 0
收起左侧

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

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

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

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

x

//打开图层表,打开方式为只写, E; s' j8 K9 |6 p5 u
AcDbLayerTable * pLayerTable;8 n2 Z0 T6 t; z, k5 L. ~
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);

//初始化层表记录对象,并设定图层名称“NewLayer”" G- \8 W0 A# Y, X' R* J) c
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;
( |9 A1 L' Z- @$ l: cpLayerTableRecord->setName(L”NewLayer”);

//图层的其他属性(例如颜色、线形等)都用默认值
1 L# r+ N+ L* [! Y  y/ J4 [//将新建的图层表记录添加到图层表中,并将图层表记录的ID3 ~% {/ s+ m: d, M  i$ b: }% ]: c
//保存到pLayerId中,作为函数的返回值
+ b# @3 Z& ]5 w# I! @* l0 A7 j: BAcCmColor color; // AcCmColor是ACAD颜色管理类
- g; I3 ~! M0 ^$ ?# F: M/ C' f1 Kcolor.setColorIndex(1); //红色7 {& H  \4 D6 e: l
(color.setRGB (0,0,0)5 j" U9 H+ M. j. `* J
pLayerTableRecord->setColor(color);
$ \2 h4 I5 u8 O6 v) ?1 L) x9 EAcDbObjectId pLayerId;  Q. b3 O6 E/ ^7 s" [  D
pLayerTable->add(pLayerId,pLayerTableRecord);& \% ]4 e" ?7 z# Y2 O: Q- r4 f
pLayerTable->close();: K0 `, {8 J$ Y4 r+ o- \7 O
pLayerTableRecord->close();

示例:创建两个图层:2 R4 |7 h) b/ e% u
//打开图层表,打开方式为只写- T: p* E8 m6 P: S2 x/ c
AcDbLayerTable * pLayerTable;
& E1 `* E3 ^: W, a/ gAcDbLayerTableRecord * pLayerTableRecord ;
5 M8 H1 G! E7 A- H' e( ^AcCmColor color;// AcCmColor是ACAD颜色管理类
( @  t; _: x, A, o7 v* C6 TAcDbObjectId pLayerId;9 r! z  i* P$ L
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
$ J& D6 g& ?' f//初始化层表记录对象,并设定图层名称“结-1”
1 ?1 E/ X, J+ L! U7 t/ spLayerTableRecord = new AcDbLayerTableRecord;
, h) e) m5 B3 H  ]4 f* |  apLayerTableRecord->setName(_T(“结-1″));
$ n  c1 x! P( s, m2 }) ~color.setColorIndex(5);
5 w; S* u4 l  w" r5 W+ H" RpLayerTableRecord->setColor(color);
7 M+ b1 q: i, Z" i- UpLayerTable->add(pLayerId,pLayerTableRecord);% F7 Y. B% Y. n
pLayerTableRecord->close();
5 K0 z1 Q4 |! Q" x% {* v//设定图层名称“结-2”
- Z7 F6 J8 t$ v* K- KpLayerTableRecord = new AcDbLayerTableRecord;
, K% v$ B5 t, r" K& r; qpLayerTableRecord->setName(_T(“结-2″));: B5 I2 g) |$ F, f, d
color.setColorIndex(1);
+ v6 S1 u5 \. J. `1 G$ qpLayerTableRecord->setColor(color);
3 {, }5 D& Y- Y: tpLayerTable->add(pLayerId,pLayerTableRecord);
2 ]3 m: a, U' LpLayerTableRecord->close();
. N. z/ y; @) c1 ApLayerTable->close();


( F% H1 q9 K1 L' A7 E% w参考:http://www.colinchou.com/archives/236
- O7 U  @+ D& E) ?& [( u! [
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


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

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

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