Message 1 of 5
Not applicable
01-09-2007
06:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I am using AutoCAD 2006 and Visual Studio 2005 with VB.Net. I have a subroutine to create a layer, it works fine except that for some reason the description field does not work. Whatever value I pass in on description it fails to be applied to the layer, here is my code:
Public Sub MakeLayer(ByVal LayerName As String, ByVal Colour As Int16, _
ByVal LineType As String, Optional ByVal Description As String = "")
Dim layerId As ObjectId 'the return value for this function
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()
'Get the layer table first...
Try
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForWrite)
'Check if Layer exists...
If lt.Has(LayerName) Then
layerId = lt.Item(LayerName)
Else
'If not, create the layer here.
Dim ltr As LayerTableRecord = New LayerTableRecord()
ltr.Name = LayerName
ltr.Color = Color.FromColorIndex(ColorMethod.ByAci, Colour)
If LineType <> "Continuous" Then
ltr.LinetypeObjectId = CheckForLineType(LineType)
End If
ltr.Description = Description
layerId = lt.Add(ltr)
trans.AddNewlyCreatedDBObject(ltr, True)
End If
trans.Commit()
Catch aex As Autodesk.AutoCAD.Runtime.Exception
MsgBox("AutoCAD Exception (MAKELAYER): " & aex.Message, MsgBoxStyle.Exclamation)
Catch ex As System.Exception
MsgBox("System Exception: " & ex.Message, MsgBoxStyle.Exclamation)
Finally
trans.Dispose()
End Try
End Sub
Can anybody please explain what is going on here, thanks in advance for any advice you can offer.
Kind Regards,
Martin.
I am using AutoCAD 2006 and Visual Studio 2005 with VB.Net. I have a subroutine to create a layer, it works fine except that for some reason the description field does not work. Whatever value I pass in on description it fails to be applied to the layer, here is my code:
Public Sub MakeLayer(ByVal LayerName As String, ByVal Colour As Int16, _
ByVal LineType As String, Optional ByVal Description As String = "")
Dim layerId As ObjectId 'the return value for this function
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()
'Get the layer table first...
Try
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForWrite)
'Check if Layer exists...
If lt.Has(LayerName) Then
layerId = lt.Item(LayerName)
Else
'If not, create the layer here.
Dim ltr As LayerTableRecord = New LayerTableRecord()
ltr.Name = LayerName
ltr.Color = Color.FromColorIndex(ColorMethod.ByAci, Colour)
If LineType <> "Continuous" Then
ltr.LinetypeObjectId = CheckForLineType(LineType)
End If
ltr.Description = Description
layerId = lt.Add(ltr)
trans.AddNewlyCreatedDBObject(ltr, True)
End If
trans.Commit()
Catch aex As Autodesk.AutoCAD.Runtime.Exception
MsgBox("AutoCAD Exception (MAKELAYER): " & aex.Message, MsgBoxStyle.Exclamation)
Catch ex As System.Exception
MsgBox("System Exception: " & ex.Message, MsgBoxStyle.Exclamation)
Finally
trans.Dispose()
End Try
End Sub
Can anybody please explain what is going on here, thanks in advance for any advice you can offer.
Kind Regards,
Martin.
Solved! Go to Solution.
|