加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)

发布时间:2020-12-16 22:50:19 所属栏目:大数据 来源:网络整理
导读: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

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"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读