.NET

Reply
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 1 of 1 (192 Views)

Create new layer

192 Views, 0 Replies
01-25-2006 06:21 AM
Hi,

I'm developing an application to run inside AutoCAD 2006, so I'm using Object ARX 2006 and VB.NET. I've done the follwing code:

Public Function AddLayer()
Dim curdb As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = curdb.TransactionManager
Dim myT As Transaction = tm.StartTransaction()
Try
Dim lt As LayerTable = CType(tm.GetObject(curdb.LayerTableId, OpenMode.ForWrite), LayerTable)
Dim layer As New LayerTableRecord
With layer
.Name = "Layer created programmaticaly"
.IsOff = False
.IsFrozen = False
.IsLocked = False
.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 255, 255)
.LineWeight = LineWeight.ByLineWeightDefault
.IsPlottable = True
End With
lt.Add(layer)
myT.AddNewlyCreatedDBObject(layer, True)
layer.Description = "Layer 1"
myT.Commit()
Catch ex As Exception
myT.Abort()
MessageBox.Show("An error ocurred while trying to add a new layer")
Finally
myT.Dispose()
tm.Dispose()
curdb.Dispose()
End Try
End Function

All this code runs well. No errors catched and the especified layer is actually added to the drawing but, after this piece of code runs, I can't save the drawing. The following message appears when I try to save the drawing:

Document "Drawing1.dwg" has a command in progress.

Am I doing somthing wrong in my code? Does anything in my code hangs? Please help me on this.

Thanks in advance for your attention,
Filipe Marcelino
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!