VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Monochrome.ctb Plots Grayscale Not Black And White

1 REPLY 1
Reply
Message 1 of 2
cascadtx
716 Views, 1 Reply

Monochrome.ctb Plots Grayscale Not Black And White

I am setting a paper space layout tab to plot PostScript to a file with the monochrome.ctb plot style, and the setting seems to be 'taking', but the plots come out gray scale rather than monochrome or even color.  Plotting through the PLOT command dialog using monochrome.ctb yields the desired result.  Below is the relevant code and comments.

 

  ' objStartDoc is an empty drawing used simply to create the PlotConfiguration to be copied

  objStartDoc.ActiveSpace = acPaperSpace
  objStartDoc.ActiveLayout.RefreshPlotDeviceInfo
  Set objPlotCfgA4 = objStartDoc.PlotConfigurations.Add("A4", False)
  With objPlotCfgA4
    .RefreshPlotDeviceInfo
    .ConfigName = "Xerox 6204 Wide Format PS3 File"
    .CanonicalMediaName = "A4"
    .PlotType = acLayout
    .GetPlotDeviceNames
    '.CenterPlot = True
    .PaperUnits = acInches
    .SetCustomScale 1#, 1#
    .GetPlotDeviceNames
    .PlotRotation = ac270degrees
    .PlotViewportBorders = False
    .PlotWithLineweights = True
    .PlotWithPlotStyles = False
    .ScaleLineweights = False
    .StyleSheet = "monochrome.ctb"
    .GetPlotStyleTableNames
  End With    ' objPlotCfgA4

  ' I don't remember why I did this or if it is even necessary

  objStartDoc.ActiveLayout.CopyFrom objPlotCfgA4
  objStartDoc.Regen acAllViewports

    ' vntName is the fully qualified path to the drawing file I want to plot

    Set objDoc = _
        Application.Documents.Open(VBA.CStr(vntName), True)
    If Not (Application.ActiveDocument Is objDoc) Then
      Application.ActiveDocument = objDoc
    End If
    objDoc.ActiveLayout.RefreshPlotDeviceInfo

    '  strLOName is the name of a paperspace layout in the drawing

      Set objLO = objDoc.Layouts.Item(strLOName)
      objDoc.ActiveLayout = objLO
      strPgSize = objLO.CanonicalMediaName
      LL = objDoc.GetVariable("LIMMIN")
      ReDim Preserve LL(0 To 1)
      UR = objDoc.GetVariable("LIMMAX")
      ReDim Preserve UR(0 To 1)

        With objPlotCfgA3
          .SetWindowToPlot LL, UR
          .PlotType = acWindow
          .CenterPlot = True
          objLO.CopyFrom objPlotCfgA3

          ' I don't know why I thought I needed to set plot to window above, then back to layout here
          .PlotType = acLayout
        End With

      objDoc.ActiveLayout = objDoc.Layouts.Item("Model")
      objDoc.ActiveLayout = objLO

      objDoc.SetVariable "BACKGROUNDPLOT", 0
      Set objPlot = objDoc.Plot

      ' Debug mode indicates objDoc.ActiveLayout.StyleSheet = monochrome.ctb at this point
      With objPlot
        .NumberOfCopies = 1
        strTmp = "Blah"  ' The output name for the 'Print To File' PostScript .plt file
        On Error Resume Next
        blnPlotSucc = .PlotToFile(strTmp)
        On Error GoTo 0
      End With

 

Tags (1)
1 REPLY 1
Message 2 of 2
cascadtx
in reply to: cascadtx

The problem was the following line:

 

.PlotWithPlotStyles = False

 

needs to be

 

.PlotWithPlotStyles = True

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost