马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写
+ R3 p* \0 {& U: w! X; v& z6 f/ p$ nAcDbLayerTable * pLayerTable;) g% z% F' |. ?0 ]- P0 O
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
8 }( Z( T: _/ b% _; [AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;4 k% G! s0 G( g) K [
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值
3 K, W; O2 d* l8 }9 c- _& H/ I//将新建的图层表记录添加到图层表中,并将图层表记录的ID
& M2 D+ ]2 K" ^( p/ W& o; q; Y4 O//保存到pLayerId中,作为函数的返回值: H4 z6 P; S; E4 j& q7 C
AcCmColor color; // AcCmColor是ACAD颜色管理类
3 N2 d) O% B% d# O- f- r+ Ecolor.setColorIndex(1); //红色
7 d1 K! o9 d1 _& B1 k( M(color.setRGB (0,0,0) 7 v. c( A. O! I8 [; h
pLayerTableRecord->setColor(color);
7 l/ I; Q- y5 VAcDbObjectId pLayerId;
" K$ G) A( Z5 h; Z/ w7 }pLayerTable->add(pLayerId,pLayerTableRecord);5 P! S: T( u1 \; e' G' K' i
pLayerTable->close();% b* G( }6 G3 R1 I! q. V% s# ?" E
pLayerTableRecord->close(); 示例:创建两个图层:
( ^* ]) A) A, L6 W//打开图层表,打开方式为只写+ J" c2 u7 R9 t5 i7 `4 F J8 r
AcDbLayerTable * pLayerTable;% @5 F% }5 i+ Y9 _0 M7 o h
AcDbLayerTableRecord * pLayerTableRecord ;3 d, A3 \1 W* G, i! z' c# u
AcCmColor color;// AcCmColor是ACAD颜色管理类
! \, A) y: P5 D8 W+ _. U$ cAcDbObjectId pLayerId;# B+ C* }# D) j! x4 J
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);9 N3 ~& I9 `- x1 E3 }8 o+ c$ {
//初始化层表记录对象,并设定图层名称“结-1”* g, ^. M. ^1 k" B) y" m& V, [
pLayerTableRecord = new AcDbLayerTableRecord;/ _" k) j7 t" w- ~: C6 |+ `7 p
pLayerTableRecord->setName(_T(“结-1″));
& g& S* }( u. d6 i8 ccolor.setColorIndex(5);
4 q5 A# M: w P! [9 fpLayerTableRecord->setColor(color);7 U' O: _% I% d. |, M& ?! T
pLayerTable->add(pLayerId,pLayerTableRecord);
6 M3 \ X1 t* apLayerTableRecord->close();
% C. u, N( ?% n7 m% ~% K) \2 m//设定图层名称“结-2”1 K6 n2 B5 W0 |' N" w) D# ]3 f* h
pLayerTableRecord = new AcDbLayerTableRecord;
$ D$ |/ D$ u* h2 g! t# RpLayerTableRecord->setName(_T(“结-2″));* X. F' F4 t* [7 n9 j1 X; c" l
color.setColorIndex(1);' l$ n" G" b0 M, Z5 y' k U: I
pLayerTableRecord->setColor(color);0 Q6 N9 m! J+ h
pLayerTable->add(pLayerId,pLayerTableRecord);
9 E9 |) [! z/ A$ V# U4 Q) MpLayerTableRecord->close();4 m4 X0 T/ P0 U5 H4 n
pLayerTable->close();
% |5 t% ?" K; W参考:http://www.colinchou.com/archives/236- f8 |2 ]- C2 [' A6 {/ ]- ^
|