How to change all the DOCUMENTS of the TileMode to 0.

How to change all the DOCUMENTS of the TileMode to 0.

classof
Contributor Contributor
1,680 Views
5 Replies
Message 1 of 6

How to change all the DOCUMENTS of the TileMode to 0.

classof
Contributor
Contributor

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

 

0 Likes
Accepted solutions (1)
1,681 Views
5 Replies
Replies (5)
Message 2 of 6

Hallex
Advisor
Advisor
Accepted 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

 

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 3 of 6

classof
Contributor
Contributor

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

 

 

0 Likes
Message 4 of 6

BlackBox_
Advisor
Advisor

@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."

Chris (BlackBox) Bradley
Managing Partner / Developer / Civil Designer
Quux Software | Sincpac C3D | Style Explorer

0 Likes
Message 5 of 6

classof
Contributor
Contributor

I have solved this problem. Smiley Happy

I have added the CommandFlags.Session.

thank you~

0 Likes
Message 6 of 6

BlackBox_
Advisor
Advisor

@classof wrote:

I have solved this problem. Smiley Happy

I have added the CommandFlags.Session.

thank you~


If only someone had suggested that before... Regardless, glad you got it sorted.

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Chris (BlackBox) Bradley
Managing Partner / Developer / Civil Designer
Quux Software | Sincpac C3D | Style Explorer

0 Likes