马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写: o3 w' |+ b+ q8 T. k# K/ ]
AcDbLayerTable * pLayerTable;
( _1 C7 q6 C. ~. c4 uacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
' m& ?4 n* z5 t0 G3 P4 K3 w/ g9 EAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;% m& j% \& P" o+ x: t1 H2 z2 D
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值
* \. e" I) k3 N' W//将新建的图层表记录添加到图层表中,并将图层表记录的ID. k1 p! t! ?1 h# N8 j; T" v$ j
//保存到pLayerId中,作为函数的返回值
& w9 ^1 [/ T0 D0 S0 p \AcCmColor color; // AcCmColor是ACAD颜色管理类! s) I, H0 K. e: P! k
color.setColorIndex(1); //红色9 f6 U6 R- w9 G
(color.setRGB (0,0,0)
; C4 g8 m6 [. N! f' y' I& hpLayerTableRecord->setColor(color);4 ^# t: R+ s8 j
AcDbObjectId pLayerId;
+ d7 x+ ^, A% K4 x( a* M% c3 g5 y. gpLayerTable->add(pLayerId,pLayerTableRecord);3 F+ V; O2 o. p
pLayerTable->close();6 ^2 U) F# P% \( @# ^) |$ M
pLayerTableRecord->close(); 示例:创建两个图层:- e* w! Y y+ e1 k8 ]
//打开图层表,打开方式为只写
! Q0 ~* Q- G) f! W6 }5 hAcDbLayerTable * pLayerTable;
2 r, w0 X/ W- S! yAcDbLayerTableRecord * pLayerTableRecord ;
/ W9 y$ z5 J- o' ], l4 ^# F/ \2 @" t+ W AAcCmColor color;// AcCmColor是ACAD颜色管理类* ], b/ j1 q# h( W- K
AcDbObjectId pLayerId;
4 ~. G& Q% q, Y1 f2 Z8 t. DacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);8 R) |' @/ l& e9 h7 M- n0 Y
//初始化层表记录对象,并设定图层名称“结-1”" z' R+ O' T/ h: c
pLayerTableRecord = new AcDbLayerTableRecord;8 r3 z# v4 s9 k
pLayerTableRecord->setName(_T(“结-1″));- y4 [/ ]; F0 v: x, f
color.setColorIndex(5);* W2 Y# z7 D. H1 z# Y
pLayerTableRecord->setColor(color);
R3 B8 p# ^6 y: V9 x7 J! s3 G& opLayerTable->add(pLayerId,pLayerTableRecord);
- b: h0 B/ t" G; U/ ipLayerTableRecord->close();
5 o) v/ [5 t# M T8 Y# [% ]//设定图层名称“结-2”
8 n% V9 F7 z8 y5 p, X* ]4 rpLayerTableRecord = new AcDbLayerTableRecord;, ?; i7 W3 H6 x0 p
pLayerTableRecord->setName(_T(“结-2″));( T1 o' g9 H# A( N& v! y; P
color.setColorIndex(1);
- h% u# s1 R9 d' T& e% o% DpLayerTableRecord->setColor(color);
6 h9 N, q' h9 M3 @$ QpLayerTable->add(pLayerId,pLayerTableRecord);8 X( K( i0 T/ Y- Z/ `# r/ a
pLayerTableRecord->close();
9 s% _0 v' @( GpLayerTable->close(); + w' r; I/ P2 c7 F) M
参考:http://www.colinchou.com/archives/236' y" X. t" A1 B% T
|