Set Penstyle for All Page Setups?

Discussion in 'AutoCAD' started by Don I, Dec 3, 2004.

  1. Don I

    Don I Guest

    I KNOW how to set the penstyle for the ACTIVE page setup--but I need to
    change the penstyle for ALL page setups. Does anyone know the best way to
    do this?

    TIA
     
    Don I, Dec 3, 2004
    #1
  2. Are you talking about setting a .ctb file for a given pagesetup?
     
    Jason Piercey, Dec 3, 2004
    #2
  3. Don I

    RDI Guest

    Yep

    In this instance, I've got a CTB file (0453.ctb) and 25 dwg files--each with
    2 page setups (one full size and one half size).
    The following will assign the CTB file to the ACTIVE plot settings--but not
    the page setup. I've got a routine that applies this CTB file upon opening
    the DWG file then saves and closes.the DWG file. This means that I can just
    open all the files and they're taken care of. I'd like to make it so that
    the CTB file is assigned to ALL pagesetups in the DWG file.

    Thx.

    (pstyle "0453.ctb")

    (defun PStyle (ctbFile / lay err)
    (vl-load-com)
    (setq lay (vla-get-activelayout
    (vla-get-activedocument
    (vlax-get-acad-object)
    )
    )
    )
    (setq err (vl-catch-all-apply
    'vla-put-stylesheet
    (list lay ctbFile)
    )
    )
    (if (vl-catch-all-error-p err)
    (princ (vl-catch-all-error-message err))
    )
    (princ)
    )
     
    RDI, Dec 3, 2004
    #3
  4. How about something like this?

    (putPlotConfigurationCTB
    (vla-get-activedocument
    (vlax-get-acad-object))
    "*"
    "my.ctb"
    )

    ; function to apply a ctb file to a plot configuration
    ; Arguments:
    ; [document] - vla-object, document object
    ; [plotConfigName] - string, pagesetup name (wildcards allowed)
    ; [ctbName] - string, ctb file to apply
    ; returns message if an error occured
    (defun putPlotConfigurationCTB (document plotConfigName ctbName / result)
    (if
    (vl-catch-all-error-p
    (setq
    result
    (vl-catch-all-apply
    '(lambda ()
    (setq plotConfigName (strcase plotConfigName))
    (vlax-for item (vla-get-plotconfigurations document)
    (if (wcmatch (strcase (vla-get-name item)) plotConfigName)
    (vla-put-stylesheet item ctbName)))
    )
    )
    )
    )
    (vl-catch-all-error-message result)
    )
    )
     
    Jason Piercey, Dec 3, 2004
    #4
  5. Don I

    RDI Guest

    U D Man! Thanks a BUNCH! That worked like a charm.

     
    RDI, Dec 3, 2004
    #5
  6. Glad it worked for you. Calling vla-refreshplotdeviceinfo
    might be required, just something keep in mind.
     
    Jason Piercey, Dec 3, 2004
    #6
  7. Don I

    RDI Guest

    What's that do?

    I ran your code on one my files--putting in a pentable I did NOT want to
    use--then checked the plot dialog box. Both setups were set to use that
    pentable. Then I ran your code again--this time putting in the pentable I
    DID want to use--and checked the plot dialog again. It showed the good CTB
    file this time around.
     
    RDI, Dec 3, 2004
    #7
  8. The couple of quick test I did when penning that
    function I noticed the pagesetup didn't always
    reflect the changes.

    Example:
    Pagesetup "ABC" was current, I ran the code and
    the new .ctb file wasn't listed until I applied that
    pagesetup again. Using vla-refreshplotdeviceinfo
    should take care of that problem.
     
    Jason Piercey, Dec 3, 2004
    #8
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.