马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写) F% N. G: ~: h4 f/ ?4 B$ y2 d
AcDbLayerTable * pLayerTable;
' J1 b& {" E) k7 W8 facdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”4 `% L+ z1 R9 f7 d+ ]! Z
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;+ r; e$ Z! `9 h. M: r1 K- u
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值+ ]5 N7 t! ]1 o
//将新建的图层表记录添加到图层表中,并将图层表记录的ID2 @) [, R6 \' C N! E" z i% n ~
//保存到pLayerId中,作为函数的返回值, H; h: `4 \( M, q
AcCmColor color; // AcCmColor是ACAD颜色管理类
" E! H! O& z6 W0 q7 Tcolor.setColorIndex(1); //红色' b% f. i$ s r% f, B
(color.setRGB (0,0,0)
1 Z' C/ D4 N6 J U+ |2 j- S, n) FpLayerTableRecord->setColor(color);
: E3 j7 x: y6 U6 `+ K, M0 Z5 VAcDbObjectId pLayerId;' A7 j) Q1 b$ A4 k
pLayerTable->add(pLayerId,pLayerTableRecord);
2 t7 a! b7 k( T+ Q- TpLayerTable->close();
4 h# @) {4 f7 c2 |% OpLayerTableRecord->close(); 示例:创建两个图层:' B, b6 z% g( [! y L# i" i
//打开图层表,打开方式为只写6 M2 i# j# t" @
AcDbLayerTable * pLayerTable;
7 q& p% U/ u' ], B6 W& oAcDbLayerTableRecord * pLayerTableRecord ;3 Z( @8 j3 {) V& u9 A$ e7 c6 K5 U
AcCmColor color;// AcCmColor是ACAD颜色管理类; {0 t8 e9 S/ D7 b: E
AcDbObjectId pLayerId;
2 }4 [4 S: [7 o; h9 g: i) o, G- ]+ ZacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);5 U B8 r% g! ^1 K
//初始化层表记录对象,并设定图层名称“结-1”
) B2 X: L- c: Z6 lpLayerTableRecord = new AcDbLayerTableRecord;" y/ @, d4 y- o, u9 d- v% B
pLayerTableRecord->setName(_T(“结-1″));9 d0 _4 W6 U C2 }' _
color.setColorIndex(5);: Y- u' k, H- }. c2 G }4 ^
pLayerTableRecord->setColor(color);
, |6 E" M1 q( W4 d6 s2 CpLayerTable->add(pLayerId,pLayerTableRecord);
( T$ g$ X% W+ [pLayerTableRecord->close();7 o* R, M& m8 u. c" }3 x. C' U
//设定图层名称“结-2”
# k& k3 V2 e- Y o- ~! J9 f& n f; kpLayerTableRecord = new AcDbLayerTableRecord;
" y& q. P, z' g" a5 n- NpLayerTableRecord->setName(_T(“结-2″));
, H6 f1 u Z6 d, V. Kcolor.setColorIndex(1);
' r1 K9 I# e1 X" [pLayerTableRecord->setColor(color);
2 j, d" _6 T% H# k- spLayerTable->add(pLayerId,pLayerTableRecord);
; a, T8 Z5 B4 h$ P2 m/ DpLayerTableRecord->close();! U1 G8 s0 y* {) n
pLayerTable->close(); 3 g* c, |/ H8 M; j6 t; r
参考:http://www.colinchou.com/archives/2368 P& G5 N4 P: a ~1 d4 u4 u- N
|