.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
classof
974 Views, 5 Replies

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

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

 

5 REPLIES 5
Message 2 of 6
Hallex
in reply to: classof

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
Message 3 of 6
classof
in reply to: Hallex

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

 

 

Message 4 of 6
BlackBox_
in reply to: Hallex


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

Message 5 of 6
classof
in reply to: classof

I have solved this problem. Smiley Happy

I have added the CommandFlags.Session.

thank you~

Message 6 of 6
BlackBox_
in reply to: classof


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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost