马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
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! [ |