.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Write to command line more than once during a command using editor.wri teline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
Re: Write to command line more than once during a command using editor.wri teline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Kerry,
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!
Re: Write to command line more than once during a command using editor.wri teline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Regards
class keyThumper<T> : Lazy<T>; another Swamper
I do not endorse the social media app links below![]()




