马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写9 d' a c, `3 z9 z4 F+ M
AcDbLayerTable * pLayerTable;
: D: H4 |. u. K& H% PacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”( d: {( a; G* K! g' j" f
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;% ]$ e3 K4 N/ F6 ~7 A* L" i: `
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值4 h0 V- C" j# R8 N# ~
//将新建的图层表记录添加到图层表中,并将图层表记录的ID
* a: J/ P; G _//保存到pLayerId中,作为函数的返回值$ b4 b6 R" } w; _ u, ?
AcCmColor color; // AcCmColor是ACAD颜色管理类
! b7 Q, E7 ?6 t) G7 Ucolor.setColorIndex(1); //红色
! l- g5 g! F8 k9 A9 P) q(color.setRGB (0,0,0)
+ A, E% T0 C0 ApLayerTableRecord->setColor(color);3 d1 n) j: E3 K, r6 w
AcDbObjectId pLayerId;
& x/ }4 ?& i3 c% J& OpLayerTable->add(pLayerId,pLayerTableRecord);
" H9 n2 Z, q; JpLayerTable->close();5 J3 K+ S8 i% R5 h
pLayerTableRecord->close(); 示例:创建两个图层:
- k3 d- c" p/ j* I' H' s( X1 t; r//打开图层表,打开方式为只写& [( y; C0 B2 \' ^; n, z
AcDbLayerTable * pLayerTable;' W/ A* `3 ~* p% s% q; [
AcDbLayerTableRecord * pLayerTableRecord ;
8 v. c8 G* `! v R" r0 jAcCmColor color;// AcCmColor是ACAD颜色管理类. i- p' H$ |; D' Q, t$ H
AcDbObjectId pLayerId;$ m; y7 x. ^% ]9 \
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); I6 X9 d: s3 w. n/ Y% r
//初始化层表记录对象,并设定图层名称“结-1”/ C W: R- ]1 I/ u, r$ I
pLayerTableRecord = new AcDbLayerTableRecord;
) Y8 i" b- B% e R/ {! EpLayerTableRecord->setName(_T(“结-1″));) h- V' V2 b& {1 ~- i. A
color.setColorIndex(5);0 r M) U7 l/ b- z, q! t5 o7 h. p
pLayerTableRecord->setColor(color);9 V6 N( `+ ^# U q& `% [, g% O6 r
pLayerTable->add(pLayerId,pLayerTableRecord);9 `. R% a; z1 I/ G* K5 E A
pLayerTableRecord->close();( h( y& J3 Y* ^5 f7 _9 p
//设定图层名称“结-2”
+ m1 o L& b; w" f1 C; SpLayerTableRecord = new AcDbLayerTableRecord;
! d) z8 y5 Y& K/ u# a. hpLayerTableRecord->setName(_T(“结-2″));# {' U' w8 [" K; }# P
color.setColorIndex(1);
* Z8 l$ v2 c2 xpLayerTableRecord->setColor(color);
& w5 N1 Q) I& k6 RpLayerTable->add(pLayerId,pLayerTableRecord); N) D- ^) t4 g' H& N% O+ w
pLayerTableRecord->close(); M' k! p( ]$ v, d
pLayerTable->close();
~. z1 r6 b1 B! I) m参考:http://www.colinchou.com/archives/236; `+ m$ P1 j0 G: y% T7 Q, m
|