Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Colors
Public Class class1
<CommandMethod("criarlayer")> _
Public Sub criarlayer()
Dim mydwg As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = mydwg.Database
Using Trans As Transaction = db.TransactionManager.StartTransaction()
Dim TabelaLayer As LayerTable
TabelaLayer = Trans.GetObject(db.LayerTableId, OpenMode.ForRead)
Dim NomeLayer(2) As String
NomeLayer(0) = InputBox("qual o nome da layer 1 ? ")
NomeLayer(1) = InputBox("qual o nome da layer 2 ? ")
NomeLayer(2) = InputBox("qual o nome da layer 3 ? ")
Dim CorLayer(2) As Integer
CorLayer(0) = InputBox("qual o nome da cor 1 ? ")
CorLayer(1) = InputBox("qual o nome da cor 2 ? ")
CorLayer(2) = InputBox("qual o nome da cor 3 ? ")
Dim nCnt As Integer = 0
For Each NovaLayer As String In NomeLayer
Dim TabelaLayerRec As LayerTableRecord
If TabelaLayer.Has(NovaLayer) = False Then
TabelaLayerRec = New LayerTableRecord()
TabelaLayerRec.Name = NovaLayer
If TabelaLayer.IsWriteEnabled = False Then TabelaLayer.UpgradeOpen()
TabelaLayer.Add(TabelaLayerRec)
Trans.AddNewlyCreatedDBObject(TabelaLayerRec, True)
Else
TabelaLayerRec = Trans.GetObject(TabelaLayer(NovaLayer),OpenMode.ForWrite)
End If
TabelaLayerRec.Color = Color.FromColorIndex(ColorMethod.ByAci, CorLayer(nCnt))
nCnt = nCnt + 1
Next
Trans.Commit()
End Using
End Sub
End Class
Sem comentários:
Enviar um comentário