QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
6天前
查看: 2031|回复: 0
收起左侧

[原创] 【ARX 一步一步开发CAD】01-新建图层

[复制链接]
发表于 2013-12-8 19:01:47 | 显示全部楼层 |阅读模式 来自: 中国江苏南京

马上注册,结识高手,享用更多资源,轻松玩转三维网社区。

您需要 登录 才可以下载或查看,没有帐号?注册

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- {
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


Licensed Copyright © 2016-2020 http://www.3dportal.cn/ All Rights Reserved 京 ICP备13008828号

小黑屋|手机版|Archiver|三维网 ( 京ICP备2023026364号-1 )

快速回复 返回顶部 返回列表