Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I'm having trouble getting a script to paste the collected lines from the "SS_GRID" layer, but I'm having a devil of a time getting the script to paste the the lines in the Model Space but it's pasting it in the Paper Space. I know I HAVE to be missing something obvious but for some reason after all the looking I'm still having a lot of trouble getting this to work, perhaps because I don't know a better way to word the situation other than
the description in the title of this post.
Public Sub ExplodeEntities()
Dim doc As Document = DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim pso As PromptSelectionOptions = New PromptSelectionOptions()
pso.AllowDuplicates = False
pso.AllowSubSelections = True
pso.RejectObjectsFromNonCurrentSpace = True
pso.RejectObjectsOnLockedLayers = False
Dim gridEnts As ObjectIdCollection = GetEntitiesOnLayer("SS_GRID")
Dim psr As PromptSelectionResult = ed.SelectAll()
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Using tr
Dim objs3 As Autodesk.AutoCAD.DatabaseServices.DBObjectCollection = New Autodesk.AutoCAD.DatabaseServices.DBObjectCollection()
For Each so As SelectedObject In psr.Value
Dim ent As Entity = CType(tr.GetObject(so.ObjectId, OpenMode.ForRead), Entity)
If ent.Layer = "SS_GRID" Then
ent.Explode(objs3)
ent.UpgradeOpen()
ent.[Erase]()
End If
Next
Dim btr As BlockTableRecord = TryCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
For Each obj As DBObject In objs3
Dim ent As Entity = CType(obj, Entity)
If ent.Layer = "SS_GRID" Then
btr.AppendEntity(ent)
tr.AddNewlyCreatedDBObject(ent, True)
End If
Next
tr.Commit()
End Using
End Sub
Solved! Go to Solution.