Public Class class18
<CommandMethod("CreateGangJinLayer")> _
Public Sub CreateGangJinLayer()
CreateLayer("钢筋", 2, "center", LineWeight.LineWeight030, True)
End Sub
Function CreateLayer(ByVal sLayerName As String, ByVal ColorIndex As Int16, ByVal LineType As String, ByVal LineW As LineWeight, ByVal CLayer As Boolean) As Int16
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acLyrTbl As LayerTable
acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, _
OpenMode.ForRead)
'创建图层
If acLyrTbl.Has(sLayerName) = False Then
Dim acLyrTblRec As LayerTableRecord = New LayerTableRecord()
acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, ColorIndex)
acLyrTblRec.Name = sLayerName
acLyrTblRec.LineWeight = LineW
acLyrTbl.UpgradeOpen()
acLyrTbl.Add(acLyrTblRec)
acTrans.AddNewlyCreatedDBObject(acLyrTblRec, True)
End If
'设置为当前图层
If CLayer = True Then
acCurDb.Clayer = acLyrTbl(sLayerName)
End If
'设置线型
Dim acLinTbl As LinetypeTable
acLinTbl = acTrans.GetObject(acCurDb.LinetypeTableId, _
OpenMode.ForRead)
If acLinTbl.Has(LineType) = True Then
Dim acLyrTblRec As LayerTableRecord = New LayerTableRecord()
acLyrTblRec.UpgradeOpen()
acLyrTblRec.LinetypeObjectId = acLinTbl(LineType)
End If
acTrans.Commit()
End Using
End Function
End Class
<CommandMethod("CreateGangJinLayer")> _
Public Sub CreateGangJinLayer()
CreateLayer("钢筋", 2, "center", LineWeight.LineWeight030, True)
End Sub
Function CreateLayer(ByVal sLayerName As String, ByVal ColorIndex As Int16, ByVal LineType As String, ByVal LineW As LineWeight, ByVal CLayer As Boolean) As Int16
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acLyrTbl As LayerTable
acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, _
OpenMode.ForRead)
'创建图层
If acLyrTbl.Has(sLayerName) = False Then
Dim acLyrTblRec As LayerTableRecord = New LayerTableRecord()
acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, ColorIndex)
acLyrTblRec.Name = sLayerName
acLyrTblRec.LineWeight = LineW
acLyrTbl.UpgradeOpen()
acLyrTbl.Add(acLyrTblRec)
acTrans.AddNewlyCreatedDBObject(acLyrTblRec, True)
End If
'设置为当前图层
If CLayer = True Then
acCurDb.Clayer = acLyrTbl(sLayerName)
End If
'设置线型
Dim acLinTbl As LinetypeTable
acLinTbl = acTrans.GetObject(acCurDb.LinetypeTableId, _
OpenMode.ForRead)
If acLinTbl.Has(LineType) = True Then
Dim acLyrTblRec As LayerTableRecord = New LayerTableRecord()
acLyrTblRec.UpgradeOpen()
acLyrTblRec.LinetypeObjectId = acLinTbl(LineType)
End If
acTrans.Commit()
End Using
End Function
End Class
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |