Can't Set Plotstyle

Discussion in 'AutoCAD' started by Robert Plummer, Apr 26, 2004.

  1. Hey, I am a newbie at this. I cobbled together a routine to

    1) Go through a drawing
    2) Retrieve all the block definitions
    3) For each block definition, search for raster images
    4) If it finds raster images, check for layer <A-ANNO-MASK>
    5) Create layer <A-ANNO-MASK> if it doesn't exist
    6) Set the plotstyle for <A-ANNO-MASK> to "0% Shade"
    7) Place the raster image on layer <A-ANNO-MASK>
    8) Updated the block

    I am doing this because we have a series of blocks in our library with
    masking backgrounds. We want to be able to turn them on and to set them to
    a plotstyle that will work with our PDF writer.

    Anwyay, I am unable to set the plotstyle to "0% Shade". I used:

    strLayerName = "A-ANNO-MASK"
    pStyleName = "0% Screen"
    On Error Resume Next
    Set wptLayer = ThisDrawing.Layers(strLayerName)

    If wptLayer Is Nothing Then
    Set wptLayer = ThisDrawing.Layers.Add(strLayerName)
    wptLayer.PlotStyleName = pStyleName
    End If

    I have tried different combinations. I can set the plotstylename to Black
    or Normal, etc., but it doesn't recognize the "0% Shade" name. Any ideas?
    Do I need to retrieve the plotsyles in the drawing first?
     
    Robert Plummer, Apr 26, 2004
    #1
  2. So far all I could do was

    ThisDrawing.SendCommand "-layer" & vbCr & "PStyle" & vbCr & "0% Screen" &
    vbCr & "A-ANNO-MASK" & vbCr & vbCr
     
    Robert Plummer, Apr 27, 2004
    #2
  3. You shouldn't need the sendcommand. Try renaming your plotstyle to
    something that does not include a space and no "%" - just try naming it
    ZERO and see what happens. Here is how it should work [modified straight
    from the help file]:

    Sub Example_DefaultPlotStyleForLayer()
    ' This example reads and modifies the preference value which controls
    ' the default plot style assigned to layers.
    ' When finished, this example resets the preference value back to
    ' it's original value.

    Dim ACADPref As AcadPreferencesOutput
    Dim originalValue As Variant, newValue As Variant

    ' Get the output preferences object
    Set ACADPref = ThisDrawing.Application.preferences.Output

    ' Read and display the original value
    originalValue = ACADPref.DefaultPlotStyleForLayer
    MsgBox "The DefaultPlotStyleForLayer preference is: " & originalValue

    ' Toggle and display the DefaultPlotStyleForLayer preference
    ACADPref.DefaultPlotStyleForLayer = "ZERO"
    newValue = ACADPref.DefaultPlotStyleForLayer
    MsgBox "The DefaultPlotStyleForLayer preference has been set to: " &
    newValue
    '
    Dim wptLayer As AcadLayer
    Set wptLayer = ThisDrawing.Layers("A-ANNO-MASK")
    If wptLayer Is Nothing Then
    Set wptLayer = ThisDrawing.Layers.Add("A-ANNO-MASK")
    wptLayer.PlotStyleName = "ZERO"
    End If

    ' Reset the preference back to it's original value
    '
    ' * Note: Comment out this last section to leave the change to
    ' this preference in effect
    ACADPref.DefaultPlotStyleForLayer = originalValue
    MsgBox "The DefaultPlotStyleForLayer preference was reset back to: " &
    originalValue
    End Sub

    Watch for wordwrap and you should add code to check to see if ZERO exists.
     
    Mike Tuersley, Apr 27, 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.