Trying to rotate a plotted drawing

Trying to rotate a plotted drawing

Anonymous
Not applicable
1,593 Views
4 Replies
Message 1 of 5

Trying to rotate a plotted drawing

Anonymous
Not applicable

I am trying to rotate a drawing that is suppose to be plotted on ANSI_full_bleed_D_(34.00_x_22.00_Inches). The current code works, except that it keeps plotting on a portrait landscape. I have tried the .PlotRotation = ac90degrees command but with no luck.

 

Private Sub PlotToPdf(CurrentCADfile As AcadDocument, pdfFile As String)

    Dim ACADLayout      As ACADLayout
        
    'Create a new plot configuration with all needed parameters
'    Set ptObj = dwg.Plot
'    Set ptConfigs = dwg.PlotConfigurations

    Set ACADLayout = CurrentCADfile.ModelSpace.Layout
    
            ACADLayout.StyleSheet = "monochrome.ctb"                                      'Print in Black and White
            ACADLayout.PlotRotation = ac90degrees ' " landscape" 'Not working
            ACADLayout.ConfigName = "DWG To PDF.pc3"                                      'Using this printer
            ACADLayout.CanonicalMediaName = "ANSI_full_bleed_D_(34.00_x_22.00_Inches)"    'PDF format using this size
            ACADLayout.StandardScale = acScaleToFit
            ACADLayout.PlotType = acExtents                                               'If your drawing has no objects, ZoomExtents displays the drawing limits
            ACADLayout.CenterPlot = True                                                  'Center the plot
    
    Set currentplot = CurrentCADfile.Plot
        ''Convertion step
        currentplot.PlotToFile pdfFile 'Plots to a file. PlotToDevice  - Plots to a plotter or printer.
'        currentplot.DisplayPlotPreview
'        ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
'        ThisDrawing.SetVariable "BACKGROUNDPLOT", backPlot '
        
    Debug.Print pdfFile
    
'    If currentplot.Plot.PlotToDevice Then
'        MsgBox "Layouts successfully plotted." 'Acad Quit here
'    End If
    
End Sub
0 Likes
Accepted solutions (1)
1,594 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

Are you saying that with or without this line

ACADLayout.PlotRotation = ac90degrees

the output is the same. Or, have you tried ac0degree or ac180degress?

 

But, IMO, you should try to set PlotRotation AFTER setting ConfigName and CononicalMediaName properties. That is:

 

            ACADLayout.StyleSheet = "monochrome.ctb"                                      
            '' ACADLayout.PlotRotation = ac90degrees ' comment this out
            ACADLayout.ConfigName = "DWG To PDF.pc3"                                      
            ACADLayout.CanonicalMediaName = "ANSI_full_bleed_D_(34.00_x_22.00_Inches)"    
ACDDLayout.PlotRotation = ac90degree ACADLayout.StandardScale = acScaleToFit ACADLayout.PlotType = acExtents ACADLayout.CenterPlot = True  

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

Anonymous
Not applicable

Just tried that now. Unfortunately, that didn't solve it. I also tried adding the "Regen" command afterwards to see if that might help, but it didn't. Here's my latest code so far. Thanks for helping out!

 

    Set ACADLayout = CurrentCADfile.ModelSpace.Layout
    
            ACADLayout.StyleSheet = "monochrome.ctb"                                      'Print in Black and White
            ACADLayout.ConfigName = "DWG To PDF.pc3"                                      'Using this printer
            ACADLayout.CanonicalMediaName = "ANSI_full_bleed_D_(34.00_x_22.00_Inches)"    'PDF format using this size
            ACADLayout.PlotRotation = ac90degrees ' " landscape" 'Not working
            ACADLayout.StandardScale = acScaleToFit
            ACADLayout.PlotType = acExtents                                               'If your drawing has no objects, ZoomExtents displays the drawing limits
            ACADLayout.CenterPlot = True                                                  'Center the plot
    
    CurrentCADfile.Regen acActiveViewport
    Set currentplot = CurrentCADfile.Plot
0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor
Accepted solution

Well, I tried this code that worked perfectly (i.e. changed the plot rotation as expected):

Option Explicit

Public Sub PlotTest()

    Dim backPlot As Integer
    backPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT")
    ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
    
    On Error Resume Next
    
    PlotToPdf ThisDrawing, "D:\Temp\TestDwgPlot1.pdf", ac0degrees
    PlotToPdf ThisDrawing, "D:\Temp\TestDwgPlot2.pdf", ac90degrees
    
    ThisDrawing.SetVariable "BACKGROUNDPLOT", backPlot
    
End Sub

Private Sub PlotToPdf(currentDwg As AcadDocument, pdfFile As String, plotRotation As AcPlotRotation)

    Dim myLayout As ACADLayout
    Dim currentPlot As AcadPlot
 
    Set myLayout = currentDwg.ModelSpace.Layout
    
    myLayout.StyleSheet = "monochrome.ctb"
    myLayout.plotRotation = plotRotation
    myLayout.ConfigName = "DWG To PDF.pc3"
    myLayout.CanonicalMediaName = "ANSI_full_bleed_D_(34.00_x_22.00_Inches)"
    
    myLayout.StandardScale = acScaleToFit
    myLayout.PlotType = acExtents
    myLayout.CenterPlot = True
    
    Set currentPlot = currentDwg.Plot
    currentPlot.DisplayPlotPreview acFullPreview
    If currentPlot.PlotToFile(pdfFile) Then
        MsgBox pdfFile & " generated successfully."
    End If

End Sub

The code is almost the same as yours. HOWEVER, I did rename the variables, such as ACADLayout, which might be problematic because of being the same as class AcadLayout

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 5

Anonymous
Not applicable

That will do it!

0 Likes