Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Does anyone know how to turn the grid off when you wblock to a new drawing created by code?
Here is my code. I know somewhere in here I need to do it, but I cannot find any variable other than viewport table records, which unfortunately are all dealt with in the active drawing.:
' Send out the new items
Using newDB As New Database
db.Wblock(newDB, oidC, New Point3d(0, 0, 0), DuplicateRecordCloning.Ignore)
newDB.SaveAs(wFile, DwgVersion.Current)
' turn the ****** grid off
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("SNAPMODE", 0)
Using tr As Transaction = newDB.TransactionManager.StartTransaction
Dim bt As BlockTable = DirectCast(tr.GetObject(newDB.BlockTableId, OpenMode.ForRead, True), BlockTable)
Dim btrMs As BlockTableRecord = bt(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)
Dim ids As ObjectIdCollection = New ObjectIdCollection()
For Each btrID In btrMs
Dim oBr = TryCast(tr.GetObject(btrID, OpenMode.ForRead), BlockReference)
If Not IsNothing(oBr) Then
Select Case UCase(oBr.Name)
Case "UG_LINK_NC", "UG_LINK_NO", "SCH_UNITID"
ids.Add(oBr.ObjectId)
End Select
End If
Next
tr.Commit()
End Using
End Using
Turns out I needed to iterate the viewport table records and set the snapEnabled variable to false, THEN save the database... Duh!
Sorry for wasting everyone's time.
Solved! Go to Solution.