马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写* F, w ~ R3 c8 z6 h$ |5 q7 w/ I
AcDbLayerTable * pLayerTable;
9 G/ N1 u! F, r) O, macdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”6 F/ R Y% {! P8 f; F
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;" @( f# }1 ~2 Y/ K/ ]: t
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值
! l. m6 \& z# Y: ~5 T3 b//将新建的图层表记录添加到图层表中,并将图层表记录的ID9 ?( r, X5 w4 y& A/ V
//保存到pLayerId中,作为函数的返回值6 |% d& |) w% r
AcCmColor color; // AcCmColor是ACAD颜色管理类
( ]' e0 B; @& s T$ F+ W+ h4 ucolor.setColorIndex(1); //红色8 v/ P9 H" r5 Z& y) \5 A w& s5 u
(color.setRGB (0,0,0) / l$ }& g. d( p) n" m* K
pLayerTableRecord->setColor(color);* T7 z- d" k3 _, _8 \5 V5 k
AcDbObjectId pLayerId;
5 a' |9 D9 ]3 x2 q1 apLayerTable->add(pLayerId,pLayerTableRecord);4 @3 W0 ~* q; O7 X0 z% k' h
pLayerTable->close();/ F; |2 u% ]3 j: Z' M. K
pLayerTableRecord->close(); 示例:创建两个图层:
% g, p$ ?6 S) W/ y# n//打开图层表,打开方式为只写
! W2 D0 k6 h" p; QAcDbLayerTable * pLayerTable;
& S- o/ _" N& Y0 ]AcDbLayerTableRecord * pLayerTableRecord ;
4 e) Y4 P4 `- @! q8 {- Z) eAcCmColor color;// AcCmColor是ACAD颜色管理类) m# f2 W2 x. O( A( v. R( ]0 X! k& n7 p
AcDbObjectId pLayerId;9 P2 z+ H8 t/ [7 _$ n
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
# O# z, W) f! r1 p9 h//初始化层表记录对象,并设定图层名称“结-1”
4 g& s0 t1 o' g5 O, Z# ipLayerTableRecord = new AcDbLayerTableRecord;/ X$ z7 f3 Y( m8 I* O) B
pLayerTableRecord->setName(_T(“结-1″));
7 ]- q0 D/ w: W3 V& d* n0 E1 n; qcolor.setColorIndex(5);4 n' |" ]( e. p' {: ?1 T
pLayerTableRecord->setColor(color);
+ r4 ^6 J$ g. [4 N9 m/ k1 M4 o/ [$ KpLayerTable->add(pLayerId,pLayerTableRecord);& @1 q6 F: x8 U0 F! |
pLayerTableRecord->close();2 W" X& d7 w( K$ N( k
//设定图层名称“结-2”1 v4 ^ R& }4 P. ^/ q
pLayerTableRecord = new AcDbLayerTableRecord;8 S; t' S# m4 q, S. E" i
pLayerTableRecord->setName(_T(“结-2″));
* u2 ]; Z$ @ i, V* S( G& N5 ccolor.setColorIndex(1);9 o8 B' m. d! |) B# A5 z
pLayerTableRecord->setColor(color);
+ L3 u3 j" @- s( i* M, JpLayerTable->add(pLayerId,pLayerTableRecord);7 C: ^; u; p# {+ Z3 r/ L0 g" ~4 j( Q
pLayerTableRecord->close();
+ D7 q- U' f [. O3 ` [pLayerTable->close(); 2 W# v! |% k! [
参考:http://www.colinchou.com/archives/236
8 o$ b2 Q8 [* ^ |