dbx Copy Layer

Discussion in 'AutoCAD' started by rgood, Jan 4, 2005.

  1. rgood

    rgood Guest

    I am writing a routine that will copy layers to the active dwg from another dwg.

    Is there a method that will copy a layer object from one drawing layers dictionary to the current drawing layers dictionary

    I have rulled out:
    vla-copyfrom (dimstyles and plot configs)
    vla-copyobjects
    vla-copy

    vla-add
    Im thinking I will have to use vla-add and just set the new layer properties per the original layer properties.
    (which 'I feel' is the long way to get there)

    there must be a method that can copy a layer object.
    mustn't there??

    Robert Good.
     
    rgood, Jan 4, 2005
    #1
  2. If you're writing a routine to do this, I assume maybe you're copying some
    standard known set of layers from some standard base/source drawing. If so,
    you could just have the routine make those layers in the active drawing,
    instead of copying them from another. That can be as simple as a script, or
    a macro routine, much more direct and obvious than vla-whatever. Or you
    could just insert an empty drawing that contains those layers.

    If it's not something as standardized as that, and requires some kind of
    user input or selection or something, does importing layers through the
    Design Center not do what you want?
     
    Kent Cooper, AIA, Jan 4, 2005
    #2
  3. rgood

    rgood Guest

    kent,
    I already have a routine that creates layers with vla functions.
    I just want to tinker with the possiblity of copying the layers from another dwg.

    Thanks for the repy.
    Robert Good.
     
    rgood, Jan 4, 2005
    #3
  4. Why did you rule out CopyObjects?

    (The sample below does not include my DBX class.)

    Sub Test()
    Dim iDBX As MWObjectDBX.DBX
    Set iDBX = MWObjectDBX.Init
    iDBX.OpenDocument "C:\Temp\Original.dwg"

    Dim orgLayers(0) As Object
    Set orgLayers(0) = iDBX.Document.Layers.Item("Sample")
    iDBX.Document.CopyObjects orgLayers, ThisDrawing.Layers
    End Sub


    --
    R. Robert Bell


    I am writing a routine that will copy layers to the active dwg from another
    dwg.

    Is there a method that will copy a layer object from one drawing layers
    dictionary to the current drawing layers dictionary

    I have rulled out:
    vla-copyfrom (dimstyles and plot configs)
    vla-copyobjects
    vla-copy

    vla-add
    Im thinking I will have to use vla-add and just set the new layer properties
    per the original layer properties.
    (which 'I feel' is the long way to get there)

    there must be a method that can copy a layer object.
    mustn't there??

    Robert Good.
     
    R. Robert Bell, Jan 4, 2005
    #4
  5. rgood

    j buzbee Guest

    Hey r,

    I think I posted my jbImportLayers routine awhile back in the CF NG. It
    does exactly what you want. It was an ObjectDCL programing example for
    everyone but I also included Vlisp Source code similar to what R. Robert
    posted.

    Let me know if you can't find it.

    jb
     
    j buzbee, Jan 4, 2005
    #5
  6. What's the purpose of posting code that uses
    '(your) DBX class' (whatever the #&*@ that is) ?
     
    Tony Tanzillo, Jan 4, 2005
    #6
  7. <shrug> Why bother posting the support code that eventually opens a
    ObjectDBX document? I simply posted the test procedure that, given a valid
    ObjectDBX document, copied a layer from said document into the current one.
    Anyone with the talent to open an ObjectDBX document in the first place can
    see that the important bit of code is this:

    Dim orgLayers(0) As Object
    Set orgLayers(0) = iDBX.Document.Layers.Item("Sample")
    iDBX.Document.CopyObjects orgLayers, ThisDrawing.Layers

    --
    R. Robert Bell


    What's the purpose of posting code that uses
    '(your) DBX class' (whatever the #&*@ that is) ?
     
    R. Robert Bell, Jan 4, 2005
    #7
  8. rgood

    rgood Guest

    jb,
    I have been thru the Autodesk ng's with no luck finding the jbImportLayers lisp. (what is the CF ng?)

    Robert Good.
     
    rgood, Jan 4, 2005
    #8
  9. rgood

    j buzbee Guest

    j buzbee, Jan 4, 2005
    #9
  10. rgood

    rgood Guest

    thanks again, jb.
     
    rgood, Jan 4, 2005
    #10
  11. rgood

    rgood Guest

    I got it. Thanks JB.

    This is what I ended up with:

    ;; Global Variables
    ;; gActiveDoc - defined in acad.lsp
    ;; gDocLayers - defined in acad.lsp



    (defun c:copylayers (/ dbxDoc vDBXLayers)
    (setq dbxDoc (vla-getinterfaceobject gAcadObject "ObjectDBX.AxDbDocument.16"))

    ;;Open File
    (vla-open dbxDoc (findfile "Layers_Master.dwg"));_open file
    (setq vDBXLayers (vla-get-layers dbxDoc))
    (vlax-for vLayer vDBXLayers
    (if (not (g:Exist gDocLayers (vla-get-name vLayer)))
    (vla-copyobjects
    dbxDoc
    (vlax-safearray-fill
    (vlax-make-safearray vlax-vbobject '(0 . 0))
    (list (vla-item vDBXLayers (vla-get-name vLayer)))
    ) ;_ end of vlax-safearray-fill
    gDocLayers
    ) ;_end copyobjects

    ) ;_end if
    ) ;_ end of vlax-for
    (vlax-release-object dbxDoc)

    (princ)
    (princ);_end clean
    ) ;_end defun

    (defun g:exist (collection item / rslt)
    (if
    (not (vl-catch-all-error-p (setq rslt (vl-catch-all-apply 'vla-item (list collection item)))))
    rslt
    ) ;_ end of if
    ) ;_ end of defun


    Robert Good.
     
    rgood, Jan 4, 2005
    #11
  12. rgood

    Anne Brown Guest

    Robert -

    Customer Files (CF) is an area for upload of problem files for
    review or sharing. Users are asked to zip any files prior to
    uploading to conserve download time and server space.

    The File Attachments discussion group can be accessed in either
    of the
    following ways:
    By NNTP discussion group reader at
    news://discussion.autodesk.com/autodesk.autocad.customer-files
    By HTTP (web-based) interface at
    http://discussion.autodesk.com/forum.jspa?forumID=126
     
    Anne Brown, Jan 4, 2005
    #12
  13. rgood

    rgood Guest

    Thanks Ann.
     
    rgood, Jan 4, 2005
    #13
  14. I don't know why. I've posted plenty of examples that
    show the usage of an AxDbDocument, without the code
    that creates it, and opens a drawing with it.

    But _WHAT_ does that have to do with 'your DBX class' ?
     
    Tony Tanzillo, Jan 5, 2005
    #14
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.