Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - rom1

Pages: 1 [2]
16
Layouts and printing / Re: Check Paper/Model Space
« on: November 23, 2010, 07:50:32 AM »

Thanks for this advice :clinoeil:, we don't think enough to that way of coding when we come from vba...

Also, in my case, i used an 'if ... else' statement because i had some other instructions into the false statement.

17
Layouts and printing / Create and copy Layouts?
« on: November 23, 2010, 07:48:26 AM »

Hi,

If you had some examples in order to create a new layout and insert some elements into or in order to copy an existing layout, that would be great since i have some difficulties in order to find good examples.

Thanks!

target audience:{advanced}

18
Layouts and printing / Get the current layout
« on: November 23, 2010, 07:45:21 AM »
Hi,

Here is a sample function in order to get back the current layout:

Code: [Select]

    Function F_GetCurrentLayout() As Layout
        ' Get the current document and database, and start a transaction '
        Dim acCurDb As Database = AcadAp.DocumentManager.MdiActiveDocument.Database
        Dim acLayoutMgr As LayoutManager
        Dim acLayout As Layout = Nothing

        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Try
                acLayoutMgr = LayoutManager.Current ' Reference the Layout Manager
                ' Get the current layout
                acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForRead)

            Catch ex As Exception
                Dim Msg As String = "Error in function F_GetCurrentLayout"
                Dim Titre As String = "Operation cancelled"
                MessageBox.Show(Msg, Titre, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
                acTrans.Abort()

            Finally
                ' Close transaction '
                acTrans.Dispose()
            End Try
        End Using

        Return acLayout
    End Function

Thanks for your remarks.


target audience:{intermediate}

19
Layers / Activate/Unfreeze Layers
« on: November 18, 2010, 10:49:15 AM »
Hi,

A little function in vb in order to make a layer active and not frozen:

Code: [Select]

    Sub LayerActiveUnfreeze(ByVal LayerName As String)

        Dim DocBd As Database = ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database

        Using myTrans As Transaction = DocBd.TransactionManager.StartTransaction
            Try
                Dim myLayerTable As LayerTable = DocBd.LayerTableId.GetObject(OpenMode.ForRead)
                For Each myLTRid As ObjectId In myLayerTable
                    Dim myLayer As LayerTableRecord = myLTRid.GetObject(OpenMode.ForRead)
                    If myLayer.Name Like LayerName Then
                        If myLayer.IsFrozen Then
                            myLayer.UpgradeOpen()
                            myLayer.IsFrozen = False
                        End If
                        If myLayer.IsLocked Then
                            myLayer.UpgradeOpen()
                            myLayer.IsLocked = False
                        End If
                    End If
                Next
            Catch ex As Exception
                myTrans.Abort()
            Finally
                myTrans.Commit()
            End Try
        End Using
    End Sub

target audience:{intermediate}

20
This site / Re: Welcome on the AutoCAD .NET developpers forums
« on: November 18, 2010, 10:43:53 AM »

Hi,

My name is Romain and I work with Patrick on Vb.Net programming.

Thanks Patrick for this very good forum!

21
Layouts and printing / Check Paper/Model Space
« on: November 18, 2010, 10:40:12 AM »
Hi,

My 1st little contribution

A function to check which of Paper/Model Space is active:

Code: [Select]

    Function F_TestPaperSpace() As Boolean

        If LayoutManager.Current.CurrentLayout = "Model" Then
            F_TestPaperSpace = False
        Else
            F_TestPaperSpace = True
        End If
    End Function

target audience:{beginner}

Pages: 1 [2]