Hi all,
I am new to this forum and to VBA, though i have used AutoCAD for long time. Using VBA i managed to make A new layer, in the process it also checks if layer already exists.
how can i alter this code to make more than one layer (set of floor plan layers or ceiling plan layer) at the same time checking if layers already exist. is there a way to read layer name, color and line type from a database? or is there an easier way. all help is appreciated. thank you
my code for making new layer
[VBA]Public Sub AddLayer()
Dim strLayerName As String
Dim objLayer As AcadLayer
strLayerName = InputBox("Name of Layer to add: ")
If "" = strLayerName Then Exit Sub ' exit if no name entered
On Error Resume Next ' handle exceptions inline
'check to see if layer already exists
Set objLayer = ThisDrawing.Layers(strLayerName)
If objLayer Is Nothing Then
Set objLayer = ThisDrawing.Layers.Add(strLayerName)
If objLayer Is Nothing Then ' check if obj has been set
MsgBox "Unable to Add '" & strLayerName & "'"
Else
MsgBox "Added Layer '" & objLayer.Name & "'"
End If
Else
MsgBox "Layer already existed"
End If
End Sub[/VBA]
EDIT: I added the VBA tags - Tommy