CopyFrom question for Jason Piercey

Discussion in 'AutoCAD' started by Gordon Price, Apr 26, 2004.

  1. Gordon Price

    Gordon Price Guest

    Jason,
    in an earlier post you said 'To set a one current use vla-copyfrom' with
    regards to named page setups. I am looking at the examples, and thinking I
    really don't understand this VLA access to VBA functions. It looks to me
    like CopyFrom would allow me to import a named page setup from a DWG (which
    might actually be better than psetupin) but I don't see how I take a named
    page setup I already have in the DWG and apply it to a specific layout. Or
    do I need to skip psetupin and the last CopyFrom will leave the named page
    setup being copied as the current one? Based on which Layout is current when
    I do it?

    Thanks,
    Gordon
     
    Gordon Price, Apr 26, 2004
    #1
  2. Gordon,

    The named page setups reside in a collection of page setups. So you need to
    copy the information that resides one of the items in the collection to the
    layout object that you want to apply the setup to.

    This sample (no error checking) assumes you have a named page setup called
    "11x17".

    (defun C:Sample (/ thisDoc plotConfig)
    (vl-load-com)
    (setq thisDoc (vla-Get-ActiveDocument (vlax-Get-Acad-Object))
    plotConfig (vla-Item (vla-Get-PlotConfigurations thisDoc) "11x17"))
    (vla-CopyFrom (vla-Get-ActiveLayout thisDoc) plotConfig)
    (princ))


    --
    R. Robert Bell


    Jason,
    in an earlier post you said 'To set a one current use vla-copyfrom' with
    regards to named page setups. I am looking at the examples, and thinking I
    really don't understand this VLA access to VBA functions. It looks to me
    like CopyFrom would allow me to import a named page setup from a DWG (which
    might actually be better than psetupin) but I don't see how I take a named
    page setup I already have in the DWG and apply it to a specific layout. Or
    do I need to skip psetupin and the last CopyFrom will leave the named page
    setup being copied as the current one? Based on which Layout is current when
    I do it?

    Thanks,
    Gordon
     
    R. Robert Bell, Apr 26, 2004
    #2
  3. Hi Gordon,

    Try something like this

    ; get the active document
    (setq document (vla-get-activedocument (vlax-get-acad-object)))

    ; get the layout you want to set current
    (setq layout (vla-item (vla-get-layouts document) "LayoutName"))

    ; get the pagesetup you want to set current
    (setq page (vla-item (vla-get-plotconfigurations document) "PageName"))

    ; make it current
    (vla-copyfrom layout page)


    --
    Autodesk Discussion Group Facilitator


    <snip>
     
    Jason Piercey, Apr 26, 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.