copyobjects and plotconfigurations

Discussion in 'AutoCAD' started by Jason Piercey, Jun 24, 2004.

  1. Seems I am drawing a blank here.

    (defun importPlotconfiguration (document pattern / lst)
    (setq pattern (strcase pattern))
    (vlax-for item (vla-get-plotconfigurations document)
    (if (wcmatch (strcase (vla-get-name item)) pattern)
    (setq lst (cons item lst))))

    (foreach item lst
    (vlax-invoke
    document
    'copyobjects
    (list item)
    (vla-get-plotconfigurations
    (vla-get-activedocument
    (vlax-get-acad-object)))
    )
    )
    )

    which returns
    (#<VLA-OBJECT IAcadPlotConfiguration 15053254>)

    but does not get imported. Anyone see where my error is?
     
    Jason Piercey, Jun 24, 2004
    #1
  2. I realize now that I should have skipped the foreach
    but it still doesn't import any plotconfigurations (of
    course)

    (defun importPlotconfiguration (document pattern / lst)
    (setq pattern (strcase pattern))
    (vlax-for item (vla-get-plotconfigurations document)
    (if (wcmatch (strcase (vla-get-name item)) pattern)
    (setq lst (cons item lst))))

    (vlax-invoke
    document
    'copyobjects
    lst
    (vla-get-plotconfigurations
    (vla-get-activedocument
    (vlax-get-acad-object)))
    )
    )


    (importPlotconfiguration sourceDocument "*")

    returns a list of plotconfiguration objects
     
    Jason Piercey, Jun 24, 2004
    #2
  3. Jason Piercey

    John Uhden Guest

    Code looks sound, though lacking any catch-alls. Might the same name be
    existent in the ActiveDocument, thereby giving you the perception that nothing
    got copied? Is the source an Xref? If so, you may need to copy from source's
    DataBase.

    Add in a (print lst) or even (print (mapcar 'vla-get-name lst)) to see what it
    found.

    Just groping along with you.
     
    John Uhden, Jun 24, 2004
    #3
  4. Jason,

    I think that the copyobjects method requires a vbObject safearray for the object that you want to copy. You may also need to update the acad object after copying.

    here is part of the function that I use - from various sources in this newsgroup:

    ;;copies an object from an external document's table
    ;;usage (f:dbx_table_copy f 'Dimstyles "SPP100")

    (defun f:dbx_table_copy (f tbl nam tag / dbxdoc lst tb info va tbx ret)
    (if (setq ret (f:vltblobjname tbl nam nil))
    (if tag (princ (strcat nam " is already defined")))
    (progn
    (if (not (setq dbxdoc (f:vlerr 'vla-GetInterfaceObject (list (vlax-get-acad-object) "ObjectDBX.AxDbDocument") nil)))
    (alert "ObjectDBX not registered")
    );if
    (if (and
    dbxdoc
    (findfile f)
    (f:dbx_open_file dbxdoc f tag)
    (setq tb (f:vlerr 'vla-Item (list (f:vlerr 'vlax-get-property (list dbxdoc tbl) nil) nam) T))
    (setq va (f:vlerr 'vlax-safearray-fill (list (vlax-make-safearray vlax-vbObject '(0 . 0)) (list tb)) T))
    (setq tbx (f:vlerr 'vlax-get-property (list (fx:doc) tbl) T))
    );and
    (f:vlerr 'vla-CopyObjects (list dbxdoc va tbx 'info) T)
    );if
    (f:vl-release (list dbxdoc tbx))
    (vla-Update (fx:acad))
    (setq ret (f:vltblobjname tbl nam nil))
    );progn
    );if
    ret
    )

    f:dbx_open_file essentially checks whether the file can be opened and if not - copies it to a temporary directory.
    f:vlerr is a error catching function

    You can also add new plotconfiguration object in your file, get the configuration object that you want to import from the dbx doc then invoke the CopyFrom method.

    Peter
     
    petersciganek, Jun 24, 2004
    #4
  5. Hi John,

    Catch-alls yes, they need to be added. Same name
    is not of concern on this one, the activedocument is
    blank in reagards to plotfonfigurations. Source is not
    an xref. Thanks for suggestions. I'll try this a bit more
    later, now I've got some of that nasty 'ole work to do.
     
    Jason Piercey, Jun 24, 2004
    #5
  6. Thanks for the response, Peter. I'll have to
    look at this a bit later. Work is calling.

    --
    Autodesk Discussion Group Facilitator


    object that you want to copy. You may also need to update the acad object
    after copying.
    (vlax-get-acad-object) "ObjectDBX.AxDbDocument") nil)))
    vlax-vbObject '(0 . 0)) (list tb)) T))
    not - copies it to a temporary directory.
    configuration object that you want to import from the dbx doc then invoke
    the CopyFrom method.
     
    Jason Piercey, Jun 24, 2004
    #6
  7. Jason Piercey

    Joe Burke Guest

    Hi Jason,

    A shot in the dark... maybe the CopyFrom method in lieu of CopyObjects?

    Joe Burke
     
    Joe Burke, Jun 24, 2004
    #7
  8. Hi Joe,

    I tried that one first before going to copyObjects.

    ; error: ActiveX Server returned the error: unknown name: "COPYFROM"

    Thanks for the suggestion.
     
    Jason Piercey, Jun 24, 2004
    #8
  9. Jason Piercey

    Joe Burke Guest

    Jason,

    I wonder, what do you think that error message indicates? To me it sounds like
    inappropriate values passed to the CopyFrom function.

    I think help is fairly clear on the fact the CopyFrom method applies to
    PlotConfiguration objects. While there's no indication PlotConfigs can be copied
    between documents using the CopyObjects method.

    Of course... I might be all wet. ;-)

    Regards
    Joe
     
    Joe Burke, Jun 24, 2004
    #9
  10. I noticed that as well when dumping a plotconfig
    object. Back to the drawing board.....
     
    Jason Piercey, Jun 24, 2004
    #10
  11. Jason,

    Determine the name you want in the current drawing.
    Add the plot config of that name to the PlotConfigurations collection.
    Use the CopyFrom method for the new object, targeting the object from the
    other drawing.


    --
    R. Robert Bell


    "Jason Piercey" <JasonATatrengDOTcom> wrote in message
    I noticed that as well when dumping a plotconfig
    object. Back to the drawing board.....
     
    R. Robert Bell, Jun 24, 2004
    #11
  12. I have been using the copyfrom method to update/export/import plotconfigurations between files with ObjectDBX. I just noticed, though, that plotconfigs saved in modelspace are causing errors in my routine so these may have to be handled differently. For plotconfigs saved in paperspace, you can copy to and from external files as expected.

    Peter
     
    petersciganek, Jun 24, 2004
    #12
  13. I'll give it a shot here after while.... this work
    thing is getting in the way of doing it now.

    Thanks.
     
    Jason Piercey, Jun 24, 2004
    #13
  14. Robert,

    Are you saying

    (vla-copyfrom <new-plotconfig-object> <existing-plotconfig-objet>)

    I've tried about every variation I can think of and
    none seem to work.
     
    Jason Piercey, Jun 25, 2004
    #14
  15. (defun C:Test (/ app srcDoc desDoc srcCfg desCfg)
    (vl-load-com)
    (setq app (vlax-Get-Acad-Object)
    srcDoc (vla-Item (vla-Get-Documents app) "Drawing1.dwg")
    desDoc (vla-Get-ActiveDocument app)
    srcCfg (vla-Item (vla-Get-PlotConfigurations srcDoc) "Original")
    desCfg (vla-Add (vla-Get-PlotConfigurations desDoc) "Copy"))
    (vla-CopyFrom desCfg srcCfg)
    (alert (vla-Get-Name desCfg)))

    This worked for me. I opened AutoCAD, and created the "Original" page setup
    in a layout on Drawing1. Then I opened a new drawing, and ran the above
    code, which alerted me that "Original" was copied to Drawing2.

    --
    R. Robert Bell


    "Jason Piercey" <Jason AT atreng DOT com> wrote in message
    I've got 1 pagesetup in the source document,
    plotter set to 'none' (I've tried others as well)
    and with the following I get the attached.

    (defun importPlotconfiguration (document pattern / plotCfgs name)
    (setq pattern (strcase pattern))
    (setq
    plotCfgs
    (vla-get-plotconfigurations
    (vla-get-activedocument
    (vlax-get-acad-object))))

    (vlax-for item (vla-get-plotconfigurations document)
    (setq name (vla-get-name item))
    (if (wcmatch (strcase name) pattern)
    (vla-copyfrom (vla-add plotCfgs name) item)
    )
    )
    )

    --
    Autodesk Discussion Group Facilitator


    "Jason Piercey" <Jason AT atreng DOT com> wrote in message
    <snip>
     
    R. Robert Bell, Jun 25, 2004
    #15
  16. <groan>

    It is amazing how pagesetups defined in a layout
    show up much better if you are not in the model
    tab when issuing the pagesetup command.


    --
    Autodesk Discussion Group Facilitator



    <snip>
     
    Jason Piercey, Jun 25, 2004
    #16
  17. <snicker> ;^)

    Glad I could help!

    --
    R. Robert Bell


    "Jason Piercey" <Jason AT atreng DOT com> wrote in message
    <groan>

    It is amazing how pagesetups defined in a layout
    show up much better if you are not in the model
    tab when issuing the pagesetup command.
     
    R. Robert Bell, Jun 25, 2004
    #17
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.