马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写6 W |% \* g. H* ~/ a
AcDbLayerTable * pLayerTable;
' z; _& ?6 S+ Z( L# [8 JacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
% n) [' s7 U. m: {6 L, C1 N1 UAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;
6 l, \! U% L) D6 U* e7 F' s6 `6 ypLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值; I/ c2 f: [4 J( w; g
//将新建的图层表记录添加到图层表中,并将图层表记录的ID
* t2 z( v7 D0 c) ]1 N//保存到pLayerId中,作为函数的返回值
8 H. z0 u% \+ w( g8 UAcCmColor color; // AcCmColor是ACAD颜色管理类6 w4 S, y: A% m6 D' H
color.setColorIndex(1); //红色$ m9 Q% c8 _& q( ]1 [8 l3 d
(color.setRGB (0,0,0)
7 a. ]9 d4 ^* r! x# opLayerTableRecord->setColor(color);
8 `4 J% \9 o/ x2 F0 T3 |" q' i/ EAcDbObjectId pLayerId;
1 h0 D0 {8 H( W/ |pLayerTable->add(pLayerId,pLayerTableRecord);
7 ^3 C9 v" m" b* k$ HpLayerTable->close();
7 g' I5 B, J, f3 MpLayerTableRecord->close(); 示例:创建两个图层:
; K- \% y* e8 Q0 P q//打开图层表,打开方式为只写
' j" l. Y5 t9 i- `6 B( BAcDbLayerTable * pLayerTable;
, k2 ~7 R1 y ? v7 fAcDbLayerTableRecord * pLayerTableRecord ;8 P& v# W1 P ?1 R- d1 P
AcCmColor color;// AcCmColor是ACAD颜色管理类
/ {/ p$ A" L) Q- {3 _3 V4 H2 TAcDbObjectId pLayerId;; X& o2 x' [; } _
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); W5 A! [' [: t% ~/ L# u
//初始化层表记录对象,并设定图层名称“结-1”4 L/ w# v8 `/ v) ~( F) s
pLayerTableRecord = new AcDbLayerTableRecord;9 a" Z3 G' T/ ~$ `2 d8 ^
pLayerTableRecord->setName(_T(“结-1″));
2 M. y1 r0 t+ M& z6 r% Vcolor.setColorIndex(5);
2 N9 R2 s$ I' t+ h/ A& I. ~pLayerTableRecord->setColor(color);
* }4 u% A/ e/ P: xpLayerTable->add(pLayerId,pLayerTableRecord);) a" U* [* Y, J( n g' o% _
pLayerTableRecord->close();
* Z5 M6 b7 k2 b0 z, Y1 k$ h8 e9 D//设定图层名称“结-2”) F2 i" l$ K. W! w1 {! }1 n
pLayerTableRecord = new AcDbLayerTableRecord;- F. E9 }" q W$ b/ i3 V
pLayerTableRecord->setName(_T(“结-2″));
, }$ j9 e7 {" P5 {color.setColorIndex(1);
3 Y( p. Z U1 b+ G0 h! x- H2 l6 [pLayerTableRecord->setColor(color);
' b, k' f! H7 J+ C+ opLayerTable->add(pLayerId,pLayerTableRecord);- S9 K- w5 l* R& y+ V% ]0 r0 {
pLayerTableRecord->close();( s! O3 D* Z' m! g
pLayerTable->close();
* G$ m" Z6 B7 X+ t6 C: P参考:http://www.colinchou.com/archives/2366 f! N" H4 h" ?! O2 N- {
|