- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All, I do not know programming but through the help of samples I am able to pull together what I need to get many things to work. However, I am lost on this one and could really use some help. I know in VBA the code is similar where you list all the layers you want to create then it adds them to the collection. I was thinking that in .NET it would work kind of the same way, lol nope. This is my code could one of you very talented programmers please tell me what is missing from this code to make it work. Thank you in advance.
<CommandMethod("ADDPNL")>
Private Sub ADDPNL()
'On Error Resume Next
Dim acDoc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using m_tm As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Layer table for read
Dim acLyrTbl As LayerTable
acLyrTbl = m_tm.GetObject(acCurDb.LayerTableId,
OpenMode.ForRead)
Dim sLayerName As String
sLayerName = "TEST1"
sLayerName = "TEST2"
sLayerName = "TEST3"
sLayerName = "TEST4"
Using acLyrTblRec As LayerTableRecord = New LayerTableRecord()
'' Assign the layer the ACI color 3 and a name
acLyrTblRec.Name = sLayerName
'' Upgrade the Layer table for write
acLyrTbl.UpgradeOpen()
'' Append the new layer to the Layer table and the transaction
acLyrTbl.Add(acLyrTblRec)
m_tm.AddNewlyCreatedDBObject(acLyrTblRec, True)
'' Save the changes and dispose of the transaction
m_tm.Commit()
End Using
If True Then Resume Next
End Using
End Sub
Solved! Go to Solution.