Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am truely stuck, someone help me please.
As the subject states, I am trying to apply a plotstyle to a layer. I can create the layer and apply a plot style but as soon as I create another layer with a different plotstyle, the layers I previously created lose their plot style (it appears to be removed from the drawing)
I have tried workarounds such as placing an object and applying a plotstyle then deleting that plot style and that still doesnt seem to append it to the drawing.
this is my code so far:
Public Sub addPltStToLayer(ByVal id As ObjectId, ByVal pltsty As String)
Dim thisDrawing As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim thisDB As Database = thisDrawing.Database
Dim trans As Transaction = thisDB.TransactionManager.StartTransaction
Using locker As DocumentLock = thisDrawing.LockDocument
Dim dict As DictionaryWithDefaultDictionary = trans.GetObject(thisDB.PlotStyleNameDictionaryId, DatabaseServices.OpenMode.ForRead)
Dim ltr As LayerTableRecord = trans.GetObject(id, DatabaseServices.OpenMode.ForWrite)
ltr.PlotStyleNameId = dict.GetAt(pltsty)
End Using
trans.Commit()
trans.Dispose()
End Sub
Public Sub addPstyle()
Dim thisDrawing As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim thisDB As Database = thisDrawing.Database
Using trans As Transaction = thisDB.TransactionManager.StartTransaction
Using placeHold As PlaceHolder = New PlaceHolder
Dim dict As DictionaryWithDefaultDictionary = trans.GetObject(thisDB.PlotStyleNameDictionaryId, DatabaseServices.OpenMode.ForWrite)
If dict.Contains(PltStBut.Text) Then
'do nothing, its already here
Else
dict.SetAt(PltStBut.Text, thisDB.AcadDatabase)
End If
trans.Commit()
End Using
End Using
End Sub
Solved! Go to Solution.