QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

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

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

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

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

x

//打开图层表,打开方式为只写: L. B7 o3 x1 I: E- \6 o
AcDbLayerTable * pLayerTable;* I& l: i0 U4 R
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);

//初始化层表记录对象,并设定图层名称“NewLayer”
* `- L% @9 X5 W; N1 \AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;6 J% I, E, E# E% l* I. Y+ o
pLayerTableRecord->setName(L”NewLayer”);

//图层的其他属性(例如颜色、线形等)都用默认值. I4 a0 \" F: `% D& f# {: T3 P* F
//将新建的图层表记录添加到图层表中,并将图层表记录的ID' D9 ~! Y/ l9 t/ t6 y
//保存到pLayerId中,作为函数的返回值9 f2 d" Q6 _3 V% Z
AcCmColor color; // AcCmColor是ACAD颜色管理类) w0 H" l. a$ i. C6 t. v; i  }9 M2 W
color.setColorIndex(1); //红色$ y6 C  m4 x; S
(color.setRGB (0,0,0)% L9 a( P& h! N6 C8 }, o
pLayerTableRecord->setColor(color);
& R; I4 ], B# m1 |4 pAcDbObjectId pLayerId;+ C8 G; m7 O. U
pLayerTable->add(pLayerId,pLayerTableRecord);
+ V9 w" a$ y  ~: |5 q* ipLayerTable->close();
9 Q' ^7 w3 g# O- A; @7 e6 a9 YpLayerTableRecord->close();

示例:创建两个图层:
0 |  @8 e& a9 M' m# H//打开图层表,打开方式为只写
5 r$ ^9 Q. N4 I$ v0 sAcDbLayerTable * pLayerTable;5 C" }  V! Y. X" E$ K  D
AcDbLayerTableRecord * pLayerTableRecord ;3 C7 R3 t. }$ h, H  q8 ~6 w& i
AcCmColor color;// AcCmColor是ACAD颜色管理类* U0 R1 ^$ y: v1 u# k8 Y
AcDbObjectId pLayerId;
" }$ v* f8 N# }  N/ DacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
, [; J0 c$ h9 }. g3 Y//初始化层表记录对象,并设定图层名称“结-1”2 A: W, o% Q) c  j% l. N
pLayerTableRecord = new AcDbLayerTableRecord;- ]% E; J3 V; \3 z: y6 p6 f; n
pLayerTableRecord->setName(_T(“结-1″));
+ ?3 @, k) `9 W3 d" i' ?' b8 F$ Wcolor.setColorIndex(5);* j: D+ q5 x" ^1 h7 u
pLayerTableRecord->setColor(color);3 ?" o2 k! S9 _
pLayerTable->add(pLayerId,pLayerTableRecord);
2 |; n  O/ c8 Y: ?1 d1 |+ O. o9 N( hpLayerTableRecord->close();
6 i4 c2 |- A, _7 U6 o9 p//设定图层名称“结-2”3 p. S0 x* g3 k$ [3 n' L9 D% Z
pLayerTableRecord = new AcDbLayerTableRecord;
- I9 q, P# E' V1 d0 ypLayerTableRecord->setName(_T(“结-2″));+ |% u' @& e6 k5 L
color.setColorIndex(1);, ?3 t) J. I6 Z) T; A  B
pLayerTableRecord->setColor(color);( x! x1 D2 H# h1 _# l# U2 _/ N4 z. c
pLayerTable->add(pLayerId,pLayerTableRecord);
) v0 ~  L* E7 _2 C) PpLayerTableRecord->close();4 s( `6 E+ D5 K$ J$ @9 Y) [
pLayerTable->close();

8 H0 V/ \" e: G
参考:http://www.colinchou.com/archives/236
" j# {2 [5 B2 m- y: C" l
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


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

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

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