Plotting Nightmares From VBA! New Attempt!!!

Discussion in 'AutoCAD' started by Steven Craig Basham, Jan 6, 2004.

  1. After reading some past posts regarding plotting with VBA... I have the
    following code. However, it doesn't use the configuration I set up...

    Here's what I am trying to do.
    1. Setup a plot configuration
    2. Plot to a file using the previously setup plot configuration.

    Do I need to assign the plot configuration to the layout object before I try
    to print?

    Any help would be greatly appreciated!

    Public Sub PlotDrawing(layoutlist As Variant, mylayout As AcadLayout, myPLOT
    As PlotCfg)
    Dim oPlotConfig As AcadPlotConfiguration
    Dim oPlot As AcadPlot
    Set oPlotConfig = ThisDrawing.PlotConfigurations.Add("TempPC", False)
    With oPlotConfig
    .ConfigName = myPLOT.PlotDevice
    .GetPaperSize myPLOT.PaperSizeH, myPLOT.PaperSizeW
    .GetWindowToPlot myPLOT.WindowStart, myPLOT.WindowEnd
    .StandardScale = ac1_1
    .PlotRotation = myPLOT.BorderOrientation
    .ShowPlotStyles = False
    .ScaleLineweights = False
    .PlotWithPlotStyles = True
    .StyleSheet = myPLOT.StyleSheet
    .RefreshPlotDeviceInfo
    End With
    Set oPlot = ThisDrawing.Plot
    With oPlot
    .SetLayoutsToPlot (layoutlist)
    .NumberOfCopies = 1
    End With
    retVAL = oPlot.PlotToFile(myPLOT.Path) <<<--- I've tried adding
    oplotconfig.configname to no avail
    If retVAL Then
    Debug.Print "Plot was successful!"
    Else
    Debug.Print "Plot FAILED!"
    End If
    oPlotConfig.Delete
    End Sub


    One final note: I read something about a .RefreshPlotDeviceInfo and a regen
    before it would 'stick', but nothing I tried seemed to make a difference.

    Thank you so much for your help!!!
     
    Steven Craig Basham, Jan 6, 2004
    #1
  2. On problem is that you need to do the RefreshPlotDeviceInfo *after* you
    change the plot device, but *before* you make changes to the plot settings.


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    message | After reading some past posts regarding plotting with VBA... I have the
    | following code. However, it doesn't use the configuration I set up...
    |
    | Here's what I am trying to do.
    | 1. Setup a plot configuration
    | 2. Plot to a file using the previously setup plot configuration.
    |
    | Do I need to assign the plot configuration to the layout object before I
    try
    | to print?
    |
    | Any help would be greatly appreciated!
    |
    | Public Sub PlotDrawing(layoutlist As Variant, mylayout As AcadLayout,
    myPLOT
    | As PlotCfg)
    | Dim oPlotConfig As AcadPlotConfiguration
    | Dim oPlot As AcadPlot
    | Set oPlotConfig = ThisDrawing.PlotConfigurations.Add("TempPC", False)
    | With oPlotConfig
    | .ConfigName = myPLOT.PlotDevice
    | .GetPaperSize myPLOT.PaperSizeH, myPLOT.PaperSizeW
    | .GetWindowToPlot myPLOT.WindowStart, myPLOT.WindowEnd
    | .StandardScale = ac1_1
    | .PlotRotation = myPLOT.BorderOrientation
    | .ShowPlotStyles = False
    | .ScaleLineweights = False
    | .PlotWithPlotStyles = True
    | .StyleSheet = myPLOT.StyleSheet
    | .RefreshPlotDeviceInfo
    | End With
    | Set oPlot = ThisDrawing.Plot
    | With oPlot
    | .SetLayoutsToPlot (layoutlist)
    | .NumberOfCopies = 1
    | End With
    | retVAL = oPlot.PlotToFile(myPLOT.Path) <<<--- I've tried adding
    | oplotconfig.configname to no avail
    | If retVAL Then
    | Debug.Print "Plot was successful!"
    | Else
    | Debug.Print "Plot FAILED!"
    | End If
    | oPlotConfig.Delete
    | End Sub
    |
    |
    | One final note: I read something about a .RefreshPlotDeviceInfo and a
    regen
    | before it would 'stick', but nothing I tried seemed to make a difference.
    |
    | Thank you so much for your help!!!
    |
    |
     
    R. Robert Bell, Jan 6, 2004
    #2
  3. Steven Craig Basham

    Joe Sutphin Guest

    Steven,

    The RefreshPlotDeviceInfo method call is not necessary. However, what is
    necessary is that you assign your plot configuration to a Layout object.

    Joe
     
    Joe Sutphin, Jan 7, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.