Results 1 to 2 of 2

Thread: Layout settings

  1. #1
    Member
    Join Date
    2009-11
    Posts
    7
    Login to Give a bone
    0

    Default Layout settings

    Hi,

    I am new to .Net Api and I am using VB.Net. I am trying to set some layout properties for my drawing. But most of the properties are not getting updated to the layout.
    - Paper units not updated to millimeters.
    - Standard scale is not set. It always checks 'scale to fit'.
    - Plot type is not set to Layout. It always shows Extents.
    - Also how can I change orientation to Landscape or Portrait?

    I am not sure what I am doing wrong. The code I am using is listed below. Please give your suggesstions.

    Thanks,
    Bala

    Code:
        Public Sub SetLayout()
            Try
                MyBase.SetScaleFactor()
                Dim Doc As Document = Acad.DocumentManager.MdiActiveDocument
                Dim DB As Database = Doc.Database
                Dim TR As Transaction = Doc.TransactionManager.StartTransaction()
    
                Dim ObjLayoutManager As LayoutManager = LayoutManager.Current
                Dim LayoutID As ObjectId = ObjLayoutManager.GetLayoutId("Layout1")
                Dim ObjLayout As Layout = CType(TR.GetObject(LayoutID, OpenMode.ForRead), Layout)
    
                Dim PlInfo As PlotInfo = New PlotInfo()
                PlInfo.Layout = LayoutID
                Dim PlSet As PlotSettings = New PlotSettings(ObjLayout.ModelType)
                'PlSet.CopyFrom(ObjLayout)
                Dim PlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
    
                'PlSetVdr.RefreshLists(PlSet)
                PlSetVdr.SetPlotType(PlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout)
                PlSetVdr.SetPlotPaperUnits(PlSet, PlotPaperUnit.Millimeters)
                PlSetVdr.SetPlotConfigurationName(PlSet, "None", "ISO_A2_(594.00_x_420.00_MM)")
    
                PlSetVdr.SetUseStandardScale(PlSet, True)
                PlSetVdr.SetStdScaleType(PlSet, StdScaleType.StdScale1To1)
                'PlSetVdr.SetZoomToPaperOnUpdate(PlSet, True)
                'PlSetVdr.RefreshLists(PlSet)
    
                PlInfo.OverrideSettings = PlSet
                Dim pInfoValid As New PlotInfoValidator
                pInfoValid.Validate(PlInfo)
    
                ObjLayout.UpgradeOpen()
                ObjLayout.CopyFrom(PlSet)
    
                TR.Commit()
                TR.Dispose()
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    Last edited by RobertB; 2009-11-09 at 08:10 PM. Reason: Added [code] tags

  2. #2
    Member
    Join Date
    2009-11
    Posts
    7
    Login to Give a bone
    0

    Default Re: Layout settings

    The code works after doing the following modifications.
    - Setting 'Tilemode' to 0, before calling this function.
    - Changing the plot device to something other than 'None'. It did not accept 'None'.
    - Calling 'RefreshLists'.

    The modified code is listed below, so that it can be of useful to somebody

    Regards,
    Bala


    Code:
        Public Sub SetLayout()
            MyBase.SetScaleFactor()
            Try
                Dim Doc As Document = Acad.DocumentManager.MdiActiveDocument
                Dim DB As Database = Doc.Database
                Dim TR As Transaction = Doc.TransactionManager.StartTransaction()
    
                Dim ObjLayoutManager As LayoutManager = LayoutManager.Current
                Dim LayoutID As ObjectId = ObjLayoutManager.GetLayoutId("Layout1")
                Dim ObjLayout As Layout = CType(TR.GetObject(LayoutID, OpenMode.ForRead), Layout)
    
                Dim PlInfo As PlotInfo = New PlotInfo()
                PlInfo.Layout = LayoutID
                Dim PlSet As PlotSettings = New PlotSettings(ObjLayout.ModelType)
                Dim PlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
    
                PlSetVdr.RefreshLists(PlSet)
                PlSetVdr.SetPlotConfigurationName(PlSet, "DWG To PDF.pc3", "ISO_expand_A2_(594.00_x_420.00_MM)")
                PlSetVdr.SetPlotType(PlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout)
                PlSetVdr.SetPlotPaperUnits(PlSet, PlotPaperUnit.Millimeters)
                PlSetVdr.SetUseStandardScale(PlSet, True)
                PlSetVdr.SetStdScaleType(PlSet, StdScaleType.StdScale1To1)
    
                PlInfo.OverrideSettings = PlSet
                Dim pInfoValid As New PlotInfoValidator
                pInfoValid.Validate(PlInfo)
    
                ObjLayout.UpgradeOpen()
                ObjLayout.CopyFrom(PlSet)
    
                TR.Commit()
                TR.Dispose()
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                MsgBox(ex.Message)
            End Try
        End Sub

Similar Threads

  1. Replies: 3
    Last Post: 2015-08-30, 08:44 PM
  2. Sheet layout editor, and dimension lines layout
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2014-01-13, 12:51 PM
  3. Layout tabs names change when layout renamed in SSM
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-01-20, 05:07 AM
  4. Layout Path Settings
    By phil.pleiss in forum Revit MEP - General
    Replies: 1
    Last Post: 2008-05-05, 02:55 PM
  5. Replies: 3
    Last Post: 2008-01-17, 01:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •