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

UpdateCurrentPaper

4 REPLIES 4
Reply
Message 1 of 5
FRFR1426
744 Views, 4 Replies

UpdateCurrentPaper

I change the paper format on a layout with:

 

PlotSettingsValidator.SetPlotConfigurationName(layout, deviceName, media)

 But the paper doesn't update when I reduce the size (A0 to A1 for example). I've found that I have to call:

 

plSetVal.SetZoomToPaperOnUpdate(layout, true);
UpdateCurrentPaper(LayoutManager.Current.UnmanagedObject, true);

In order to force the update. AcApLayoutManager::updateCurrentPaper is not exposed in the .NET API, so I had to P/Invoke it. On AutoCAD 2013, I've found it in accore.dll, but I'm not able to found it on AutoCAD 2010. Someone knows where I can found it? Or a workaround? The doc says that the update may be triggered after the call to SetZoomToPaperOnUpdate by a notification, but how to force the sending of this kind of notification without updateCurrentPaper?

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Tags (2)
4 REPLIES 4
Message 2 of 5
hyperpics
in reply to: FRFR1426

Have you tried to call:

 

Editor.Regen()

 

Message 3 of 5
FRFR1426
in reply to: FRFR1426

Yes, and UpdateScreen too. Only UpdateCurrentPaper seems to work.
Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 4 of 5


@FRFR1426 wrote:
...AcApLayoutManager::updateCurrentPaper is not exposed in the .NET API, so I had to P/Invoke it. On AutoCAD 2013, I've found it in accore.dll, but I'm not able to found it on AutoCAD 2010. Someone knows where I can found it? Or a workaround?...

It is look like you have to write wrapper (with ObjectARX C++) for this method.

Š’Ń–Š“ŠæŠ¾Š²Ń–Š“ь ŠŗŠ¾Ń€ŠøсŠ½Š°? ŠšŠ»Ń–ŠŗŠ½Ń–Ń‚ŃŒ Š½Š° "Š’ŠŸŠžŠ”ŠžŠ‘ŠŠ™ŠšŠ£" ціŠ¼ ŠæŠ¾Š²Ń–Š“Š¾Š¼Š»ŠµŠ½Š½ŃŠ¼! | Do you find the posts helpful? "LIKE" these posts!
ŠŠ°Ń…Š¾Š“ŠøтŠµ сŠ¾Š¾Š±Ń‰ŠµŠ½Šøя ŠæŠ¾Š»ŠµŠ·Š½Ń‹Š¼Šø? ŠŸŠ¾ŃŃ‚Š°Š²ŃŒŃ‚Šµ "ŠŠ ŠŠ’Š˜Š¢Š”ŠÆ" этŠøŠ¼ сŠ¾Š¾Š±Ń‰ŠµŠ½ŠøяŠ¼!
ŠŠ° Š²Š°ŃˆŠµ Š·Š°ŠæŠøтŠ°Š½Š½Ń Š²Ń–Š“ŠæŠ¾Š²Ń–Š»Šø? ŠŠ°Ń‚ŠøсŠ½Ń–Ń‚ŃŒ ŠŗŠ½Š¾ŠæŠŗу "ŠŸŠ Š˜Š™ŠŠÆŠ¢Š˜ Š Š†ŠØŠ•ŠŠŠÆ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
ŠŠ° Š²Š°Ńˆ Š²Š¾ŠæрŠ¾Ń усŠæŠµŃˆŠ½Š¾ Š¾Ń‚Š²ŠµŃ‚ŠøŠ»Šø? ŠŠ°Š¶Š¼ŠøтŠµ ŠŗŠ½Š¾ŠæŠŗу "Š£Š¢Š’Š•Š Š”Š˜Š¢Š¬ Š Š•ŠØŠ•ŠŠ˜Š•"


Alexander Rivilis / ŠŠ»ŠµŠŗсŠ°Š½Š“р Š ŠøŠ²ŠøŠ»Šøс / ŠžŠ»ŠµŠŗсŠ°Š½Š“р Š Ń–Š²Ń–Š»Ń–с
Programmer & Teacher & Helper / ŠŸŃ€Š¾Š³Ń€Š°Š¼Š¼Šøст - Š£Ń‡ŠøтŠµŠ»ŃŒ - ŠŸŠ¾Š¼Š¾Ń‰Š½ŠøŠŗ / ŠŸŃ€Š¾Š³Ń€Š°Š¼Ń–ст - Š²Ń‡ŠøтŠµŠ»ŃŒ - ŠæŠ¾Š¼Ń–чŠ½ŠøŠŗ
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 5
hyperpics
in reply to: FRFR1426

I have used the following code to update the paper size and other properties of a plot settings object for a layout without any problems.  Maybe it will help you.  If not, then the only other option is to P/Invoke the method you mention.  I do remember having some strange issues with getting the paper size to display correctly when I was working on my AU handouts, but did manage to work around it though and did not need to P/Invoke any extra functions.

 

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.PlottingServices

' Creates a new page setup or edits the page set if it exists
<CommandMethod("CreateOrEditPageSetup")> _
Public Shared Sub CreateOrEditPageSetup()
    ' Get the current document and database, and start a transaction
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
    Dim acCurDb As Database = acDoc.Database

    Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

        Dim plSets As DBDictionary = _
            acTrans.GetObject(acCurDb.PlotSettingsDictionaryId, OpenMode.ForRead)
        Dim vStyles As DBDictionary = _
            acTrans.GetObject(acCurDb.VisualStyleDictionaryId, OpenMode.ForRead)

        Dim acPlSet As PlotSettings
        Dim createNew As Boolean = False

        ' Reference the Layout Manager
        Dim acLayoutMgr As LayoutManager = LayoutManager.Current

        ' Get the current layout and output its name in the Command Line window
        Dim acLayout As Layout = _
            acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), _
                              OpenMode.ForRead)

        ' Check to see if the page setup exists
        If plSets.Contains("MyPageSetup") = False Then
            createNew = True

            ' Create a new PlotSettings object: 
            '    True - model space, False - named layout
            acPlSet = New PlotSettings(acLayout.ModelType)
            acPlSet.CopyFrom(acLayout)

            acPlSet.PlotSettingsName = "MyPageSetup"
            acPlSet.AddToPlotSettingsDictionary(acCurDb)
            acTrans.AddNewlyCreatedDBObject(acPlSet, True)
        Else
            acPlSet = plSets.GetAt("MyPageSetup").GetObject(OpenMode.ForWrite)
        End If

        ' Update the PlotSettings object
        Try
            Dim acPlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current

            ' Set the Plotter and page size
            acPlSetVdr.SetPlotConfigurationName(acPlSet, _
                                                "DWF6 ePlot.pc3", _
                                                "ANSI_B_(17.00_x_11.00_Inches)")

            ' Set to plot to the current display
            If acLayout.ModelType = False Then
                acPlSetVdr.SetPlotType(acPlSet, _
                                       DatabaseServices.PlotType.Layout)
            Else
                acPlSetVdr.SetPlotType(acPlSet, _
                                       DatabaseServices.PlotType.Extents)

                acPlSetVdr.SetPlotCentered(acPlSet, True)
            End If

            ' Use SetPlotWindowArea with PlotType.Window
            'acPlSetVdr.SetPlotWindowArea(plSet, _
            '                             New Extents2d(New Point2d(0.0, 0.0), _
            '                             New Point2d(9.0, 12.0)))

            ' Use SetPlotViewName with PlotType.View
            'acPlSetVdr.SetPlotViewName(plSet, "MyView")

            ' Set the plot offset
            acPlSetVdr.SetPlotOrigin(acPlSet, _
                                     New Point2d(0, 0))

            ' Set the plot scale
            acPlSetVdr.SetUseStandardScale(acPlSet, True)
            acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit)
            acPlSetVdr.SetPlotPaperUnits(acPlSet, PlotPaperUnit.Inches)
            acPlSet.ScaleLineweights = True

            ' Specify if plot styles should be displayed on the layout
            acPlSet.ShowPlotStyles = True

            ' Rebuild plotter, plot style, and canonical media lists 
            ' (must be called before setting the plot style)
            acPlSetVdr.RefreshLists(acPlSet)

            ' Specify the shaded viewport options
            acPlSet.ShadePlot = PlotSettingsShadePlotType.AsDisplayed

            acPlSet.ShadePlotResLevel = ShadePlotResLevel.Normal

            ' Specify the plot options
            acPlSet.PrintLineweights = True
            acPlSet.PlotTransparency = False
            acPlSet.PlotPlotStyles = True
            acPlSet.DrawViewportsFirst = True

            ' Use only on named layouts - Hide paperspace objects option
            ' plSet.PlotHidden = True

            ' Specify the plot orientation
            acPlSetVdr.SetPlotRotation(acPlSet, PlotRotation.Degrees000)

            ' Set the plot style
            If acCurDb.PlotStyleMode = True Then
                acPlSetVdr.SetCurrentStyleSheet(acPlSet, "acad.ctb")
            Else
                acPlSetVdr.SetCurrentStyleSheet(acPlSet, "acad.stb")
            End If

            ' Zoom to show the whole paper
            acPlSetVdr.SetZoomToPaperOnUpdate(acPlSet, True)
        Catch es As Autodesk.AutoCAD.Runtime.Exception
            MsgBox(es.Message)
        End Try

        ' Save the changes made
        acTrans.Commit()

        If createNew = True Then
            acPlSet.Dispose()
        End If
    End Using
End Sub

 

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