Hello
I would like to change all the DOCUMENTS of the TileMode to 0.
But, the following code the ActiveDocument changes only.
How can I modify the code?
Dim acdc As DocumentCollection = Application.DocumentManager Dim acdoc As Document = acdc.MdiActiveDocument Dim acTile As Integer = Application.GetSystemVariable("TileMode") For Each acdoc In acdc If acTile = 1 Then Application.SetSystemVariable("TILEMODE", 0) End If Next End Sub
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
Take a look at the article
'See article here: 'http://adndevblog.typepad.com/autocad/2012/05/when-to-lock-the-document.html?cid=6a0167607c2431970b0... <CommandMethod("stile")> _ Public Sub switchTileMode() Try For Each doc As Document In Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager If doc <> Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Then ' switch the active document Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = doc ' If you do not lock the document ' then the below code just simply has no effect ' whereas "doc.Database.TileMode = ' !doc.Database.TileMode;" ' would even crash AutoCAD ' If you lock the document then both should work fine Using doc.LockDocument() Dim tm As Short = CShort(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("TILEMODE")) Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", (tm + 1) Mod 2) End Using Exit For End If Next Catch ex As Autodesk.AutoCAD.Runtime.Exception Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(("Exception: " + ex.Message)) Finally ' Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.CloseAll() 'to your needs End Try End Sub
Hallex
Thank you for your reply.
So, I made the following code.. but, Tilemod of all document does not change the value to 0.
Please help me..
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.ApplicationServices Public Class fsfaf <CommandMethod("ss")> _ Public Sub ypf() Dim acdc As DocumentCollection = Application.DocumentManager For Each acdoc As Document In acdc If acdoc <> acdc.MdiActiveDocument Then acdc.MdiActiveDocument = acdoc End If Using acdoc.LockDocument() Dim acTile As Short = Application.GetSystemVariable("TileMode") If acTile = 1 Then Application.SetSystemVariable("TILEMODE", 0) End If End Using Next End Sub End Class
@Hallex wrote:Take a look at the article
'See article here: 'http://adndevblog.typepad.com/autocad/2012/05/when-to-lock-the-document.html?cid=6a0167607c2431970b0... <CommandMethod("stile")> _ Public Sub switchTileMode() '' <snip> End Sub
Hallex,
Doesn't the article say that CommandFlags.Session is needed?
Example code snippet from the article you linked above:
// <snip>
[CommandMethod("MyTest", CommandFlags.Session)] public void MyTestNet() { // <snip> }
Cheers
"How we think determines what we do, and what we do determines what we get."
Can't find what you're looking for? Ask the community or share your knowledge.