QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
10天前
查看: 1973|回复: 0
收起左侧

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

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

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

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

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

本版积分规则

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

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

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