马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写) m2 R6 ]8 x- N# x2 |" q
AcDbLayerTable * pLayerTable;/ {; t3 [6 c; W1 z8 @; L
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
7 t( a" l: n$ W4 lAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;
& p! l+ J6 t& @- f7 ~pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值
# n9 a }2 B# m* w+ Y//将新建的图层表记录添加到图层表中,并将图层表记录的ID
9 _6 V! ~1 E5 l$ E1 H5 q0 v" y//保存到pLayerId中,作为函数的返回值' Z1 _* z0 U) k# f1 d& e' j
AcCmColor color; // AcCmColor是ACAD颜色管理类5 l0 P5 e+ q/ b
color.setColorIndex(1); //红色8 a+ F3 O4 E' I/ g9 k
(color.setRGB (0,0,0) 8 i$ ?$ S- o. ~1 Z. w7 A8 \& S6 D9 J
pLayerTableRecord->setColor(color);) N% F- e2 k0 v, t1 |+ D- ~/ w
AcDbObjectId pLayerId;9 m! m" o3 [* K
pLayerTable->add(pLayerId,pLayerTableRecord);
$ J& K7 c, a, U4 s) Q( M4 rpLayerTable->close(); R5 [7 S8 r" b
pLayerTableRecord->close(); 示例:创建两个图层:: e" u+ D1 B- ~' n& X: B5 k
//打开图层表,打开方式为只写
0 r$ p* E: f5 f v2 B8 G( |7 I6 wAcDbLayerTable * pLayerTable;
+ s1 d. X# v8 CAcDbLayerTableRecord * pLayerTableRecord ;3 d. D& k5 ^9 C: D3 E' M) t3 W
AcCmColor color;// AcCmColor是ACAD颜色管理类( E! [, D" J1 H# u
AcDbObjectId pLayerId;
$ x& O) c% v: E/ iacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);% x& M. l! D) n$ ]
//初始化层表记录对象,并设定图层名称“结-1”( u# S, b/ Y: Y5 `3 Q
pLayerTableRecord = new AcDbLayerTableRecord;
8 v. D$ u/ M9 a# y2 Q' U2 CpLayerTableRecord->setName(_T(“结-1″));' s5 E# p, G: z Q$ T
color.setColorIndex(5);
* p; c3 c6 C0 _2 ppLayerTableRecord->setColor(color);5 {& k5 I8 r O3 H! L5 \
pLayerTable->add(pLayerId,pLayerTableRecord);
- ]4 Q, [6 y5 e9 ^pLayerTableRecord->close();8 h+ v+ l e% T+ F$ o
//设定图层名称“结-2”
; `* L. P, Q9 q4 G- U4 R) b( PpLayerTableRecord = new AcDbLayerTableRecord;8 D- q5 r+ t3 M" U; w) i% H
pLayerTableRecord->setName(_T(“结-2″));& f- W b- ?, p4 b, [
color.setColorIndex(1);9 x8 d3 {9 L4 D$ H7 v3 n7 M7 C4 t
pLayerTableRecord->setColor(color);
" J+ S, W7 r$ I4 Z* h1 _! C( rpLayerTable->add(pLayerId,pLayerTableRecord);% Y' O" K' L+ s' P
pLayerTableRecord->close();
1 s; ?( H. k7 ppLayerTable->close(); * X1 Y& q8 O! A$ d: R
参考:http://www.colinchou.com/archives/2367 J) k, z8 J) D2 M; U; r- d+ \5 {
|