Good Suggestion, I had actually already added this to the program. Below is the current code that I am using to add the layers.
'This sub will accept a layername, a color number, a lineweight and then create the layer. Public Sub CreateTrimbleLayer(layerName As String, colorNum As Short, LineWeightNum As LineWeight) 'Get the editor object Dim doc = AcApp.DocumentManager.MdiActiveDocument Dim db = doc.Database Dim ed = doc.Editor 'Create the layer. If there is an error then catch it. Try 'Start the database transaction Using tr As Transaction = db.TransactionManager.StartTransaction() 'Open the LayerTable for write Dim lt = DirectCast(db.LayerTableId.GetObject(OpenMode.ForW
rite), LayerTable) 'If the layer is already in the database then write a message to the command 'line and return If lt.Has(layerName) Then ed.WriteMessage(layerName & " exists..." & vbLf) Return End If 'Create a new LayerTableRecord and set the name, color, and lineweight Dim ltr = New LayerTableRecord() ltr.Name = layerName ltr.Color = AcColors.Color.FromColorIndex(ColorMethod.ByAci, colorNum) ltr.LineWeight = LineWeightNum 'Add the LayerTableRecord to the LayerTable lt.Add(ltr) 'Set the Layer Description equal to the Layer Name ltr.Description = layerName 'Add the created object to the database and commit the transaction tr.AddNewlyCreatedDBObject(ltr, True) tr.Commit() 'The layer has been successfully created so write a message to the commandline ed.WriteMessage(layerName & " layer created..." & vbLf) End Using 'There was an unknown error when creating the layer so write a message to the commandline Catch generatedExceptionName As Autodesk.AutoCAD.Runtime.Exception ed.WriteMessage(layerName & " Ooooops ; not created..." & vbLf) End Try End Sub
I see that you also post alot on theswamp.org. Do you have any suggestions on the problems I have encountered in this thread? Thanks in advance!
Yeah, I feel at home @ theSwamp
I 'normally' stick with C# code. I just happened to scan your code and couldn't see an obvious reason it should act as you described ... so I hacked out the C# to see how I'd have attacked it.
Your code seems to be layed out well (modular) and should lend itself to debugging and expansion ... which is important as I see it.
Sugestions ? just keep bashing keys.
class keyThumper<T> : Lazy<T>; another Swamper
Access a broad range of knowledge to help get the most out of your products and services.
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.
Upgrading to a 2015 product? Make sure to check these out 1st!