03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-3)
来源:互联网 发布:数据库关系表 编辑:程序博客网 时间:2024/05/16 18:04
1.3、Make a Layer Current将图层设为当前图层
You are always drawing on the active layer. When you make a layer active, you create new objects on that layer. If you make a different layer active, any new objects you create is assigned that new active layer and uses its color and linetype. You cannot make a layer active if it is frozen.
我们总是在活动图层绘制图形。当将某个图层设为活动图层后,新创建的对象就在这个图层上。如果又将别的图层设为活动图层,之后创建的新对象就在这个新活动图层上并使用该图层的颜色和线型。不能将冻结的图层设为活动图层。
To make a layer active, use the Clayer property of the Database object or the CLAYER system variable. For example:
将图层设为活动图层,使用Database对象的Clayer属性,或者使用系统变量CLAYER。详见下面的示例代码:
Make a layer current through the database 通过数据库将图层设为当前图层
This example sets a layer current through the Database object with the Clayer property.
本例使用Database对象的Clayer属性将图层设为当前图层。
VB.NET
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
<CommandMethod("SetLayerCurrent")> _
Public Sub SetLayerCurrent()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Layer table for read
Dim acLyrTbl As LayerTable
acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, _
OpenMode.ForRead)
Dim sLayerName As String = "Center"
If acLyrTbl.Has(sLayerName) = True Then
'' Set the layer Center current
acCurDb.Clayer = acLyrTbl(sLayerName)
'' Save the changes
acTrans.Commit()
End If
'' Dispose of the transaction
End Using
End Sub
C#
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[CommandMethod("SetLayerCurrent")]
public static void SetLayerCurrent()
{
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Layer table for read
LayerTable acLyrTbl;
acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead) as LayerTable;
string sLayerName = "Center";
if (acLyrTbl.Has(sLayerName) == true)
{
// Set the layer Center current
acCurDb.Clayer = acLyrTbl[sLayerName];
// Save the changes
acTrans.Commit();
}
// Dispose of the transaction
}
}
VBA/ActiveX Code Reference
ThisDrawing.ActiveLayer = ThisDrawing.Layers("Center")
Make a layer current with the CLAYER system variable 使用系统变量CLAYER设置当前图层
This example sets a layer current with the CLAYER system variable.
本例使用CLAYER系统变量设置当前图层。
VB.NET
Application.SetSystemVariable("CLAYER", "Center")
C#
Application.SetSystemVariable("CLAYER", "Center");
VBA/ActiveX Code Reference
ThisDrawing.SetVariable "CLAYER", "Center"
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(3)使用线型
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-3)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(2)使用颜色
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-1)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-2)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-4)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-5)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-6)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-7)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-8)
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-9)
- 03-06 创建和编辑AutoCAD实体(六) 保存和恢复图层状态
- 03-03 创建和编辑AutoCAD实体(三) 使用选择集(1)
- 03-07 创建和编辑AutoCAD实体(七) 向图形中添加文字(1)使用文字样式
- 03-03 创建和编辑AutoCAD实体(三) 使用选择集(2)
- 03-04 创建和编辑AutoCAD实体(四) 编辑二维命名对象 (1)
- 03-07 创建和编辑AutoCAD实体(七) 向图形中添加文字(3)使用多行文字
- 03-02 创建和编辑AutoCAD实体(二) 创建对象(1)
- VC 常用数据类型使用转换详解
- (*((volatile unsigned long *) 0xE0028000)) 作用小解
- PB中用SetFilter和Filter实现简单的查询功能
- ubuntu手动安装jdk
- PB中游标的使用 DECLARE CURSOR FETCH
- 03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-3)
- PB 数据窗口datawindow中的数据隔行换颜色
- MeeGo编译步骤参考
- EPL语言通过USB打印条码
- XAML揭秘
- 获取未安装的APK图标
- 真正实现TextView跑马灯效果
- ADB命令大全
- vs2008 tr1 正则表达式 找出所有匹配项