马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写: L. B7 o3 x1 I: E- \6 o
AcDbLayerTable * pLayerTable;* I& l: i0 U4 R
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
* `- L% @9 X5 W; N1 \AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;6 J% I, E, E# E% l* I. Y+ o
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值. I4 a0 \" F: `% D& f# {: T3 P* F
//将新建的图层表记录添加到图层表中,并将图层表记录的ID' D9 ~! Y/ l9 t/ t6 y
//保存到pLayerId中,作为函数的返回值9 f2 d" Q6 _3 V% Z
AcCmColor color; // AcCmColor是ACAD颜色管理类) w0 H" l. a$ i. C6 t. v; i }9 M2 W
color.setColorIndex(1); //红色$ y6 C m4 x; S
(color.setRGB (0,0,0) % L9 a( P& h! N6 C8 }, o
pLayerTableRecord->setColor(color);
& R; I4 ], B# m1 |4 pAcDbObjectId pLayerId;+ C8 G; m7 O. U
pLayerTable->add(pLayerId,pLayerTableRecord);
+ V9 w" a$ y ~: |5 q* ipLayerTable->close();
9 Q' ^7 w3 g# O- A; @7 e6 a9 YpLayerTableRecord->close(); 示例:创建两个图层:
0 | @8 e& a9 M' m# H//打开图层表,打开方式为只写
5 r$ ^9 Q. N4 I$ v0 sAcDbLayerTable * pLayerTable;5 C" } V! Y. X" E$ K D
AcDbLayerTableRecord * pLayerTableRecord ;3 C7 R3 t. }$ h, H q8 ~6 w& i
AcCmColor color;// AcCmColor是ACAD颜色管理类* U0 R1 ^$ y: v1 u# k8 Y
AcDbObjectId pLayerId;
" }$ v* f8 N# } N/ DacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
, [; J0 c$ h9 }. g3 Y//初始化层表记录对象,并设定图层名称“结-1”2 A: W, o% Q) c j% l. N
pLayerTableRecord = new AcDbLayerTableRecord;- ]% E; J3 V; \3 z: y6 p6 f; n
pLayerTableRecord->setName(_T(“结-1″));
+ ?3 @, k) `9 W3 d" i' ?' b8 F$ Wcolor.setColorIndex(5);* j: D+ q5 x" ^1 h7 u
pLayerTableRecord->setColor(color);3 ?" o2 k! S9 _
pLayerTable->add(pLayerId,pLayerTableRecord);
2 |; n O/ c8 Y: ?1 d1 |+ O. o9 N( hpLayerTableRecord->close();
6 i4 c2 |- A, _7 U6 o9 p//设定图层名称“结-2”3 p. S0 x* g3 k$ [3 n' L9 D% Z
pLayerTableRecord = new AcDbLayerTableRecord;
- I9 q, P# E' V1 d0 ypLayerTableRecord->setName(_T(“结-2″));+ |% u' @& e6 k5 L
color.setColorIndex(1);, ?3 t) J. I6 Z) T; A B
pLayerTableRecord->setColor(color);( x! x1 D2 H# h1 _# l# U2 _/ N4 z. c
pLayerTable->add(pLayerId,pLayerTableRecord);
) v0 ~ L* E7 _2 C) PpLayerTableRecord->close();4 s( `6 E+ D5 K$ J$ @9 Y) [
pLayerTable->close(); 8 H0 V/ \" e: G
参考:http://www.colinchou.com/archives/236
" j# {2 [5 B2 m- y: C" l |