AcadX 'SaveAs "Automation Error. Description was not provided"

Discussion in 'AutoCAD' started by chris villanueva, Jun 23, 2004.

  1. Please see comments in code:

    (defun ProcTheDwg ()
    (vl-load-com)
    (arxload "AcadX16.arx")
    (setq HOLDLSP (getvar "ACADLSPASDOC"))
    (setvar "acadlspasdoc" 0)
    (setq APP (vlax-get-acad-object))
    (if (setq lcDwgs (dos_find "c:\\*.DWG") 0)
    ;
    ; Process all dwgs
    (progn
    (setq NN 0)
    (repeat (length lcDwgs)
    (setq cDwgName (strcase (nth NN lcDwgs)))
    ; Open the dwg.
    (setq
    ; 2000/2000i=AxDbDocument, 2004=AxDbDocument.16
    dbxdoc
    (vla-getInterfaceObject APP
    "ObjectDBX.AxDbDocument.16"
    )
    acadx
    (vla-getInterfaceObject APP
    "AcadX.Application"
    )
    ;---------------------------------------------------------------------------
    ----
    ; 6/7/04 5:10:50 PM
    ; (vla-open dbxdoc cDwgName) returns NIL.
    ; (vla-open (vla-get-documents APP) cDwgName) seems to work.
    ; But, (vlax-invoke-method AcadX 'SaveAs dbxdoc cDwgName) below
    ; returns: Automation Error. Description was not provided.
    ;---------------------------------------------------------------------------
    ----
    WW
    (vla-open dbxdoc cDwgName)
    ;(vla-open (vla-get-documents APP) cDwgName)
    )
    (cond
    ;
    ; If dwg can be written to...
    ((= 1 (vlax-variant-value (vla-getvariable WW "WriteStat")))
    ;
    ; Purge it.
    (repeat 3 (vla-purgeall WW))
    ;
    ; Save it.
    ;
    ; 6/7/04 2:52:48 PM -- (vla-save WW) doesn't save the thumbnail
    ;
    ; Use acadx instead
    (vlax-invoke-method acadx
    'MakePreviewImage
    dbxdoc
    :vlax-false
    )
    ;---------------------------------------------------------------------------
    ----
    ; 6/7/04 2:55:54 PM -- vlax-invoke-method returns: Automation Error.
    Description was not provided.
    ;---------------------------------------------------------------------------
    ----
    (vlax-invoke-method AcadX 'SaveAs dbxdoc cDwgName)
    ;
    (if dbxdoc
    (progn
    (vlax-invoke-method acadx 'FreeObject dbxdoc)
    (vlax-release-object dbxdoc)
    )
    )
    (vlax-release-object acadx)
    (vla-close WW :vlax-false)
    (vlax-release-object WW)
    )
    (t
    (prompt (strcat "\n" cDwgName " is read-only. Skipped."))
    )
    )
    (setq NN (1+ NN))
    ); repeat
    )
    ); if
    )
     
    chris villanueva, Jun 23, 2004
    #1
  2. Sorry for the delay, I've been working on fixing
    a bug in the class that you need to use.

    In short, you don't use this method to preserve
    thumbnails any longer. Instead, you use the
    AcadXDatabase class, and its PreservePreview
    property:

    (setq xdb
    (vla-getinterfaceobject
    (vlax-get-acad-object)
    "AcadX.Database"
    )
    )

    (setq dbxDoc
    (vla-getinterfaceobject
    (vlax-get-acad-object)
    "ObjectDBX.AxDbDocument.16"
    )
    )

    (vlax-invoke-method dbxDoc 'Open "SomeDrawing.dwg")

    ;; It is important that the following not
    ;; be called until *after* you call the
    ;; Open method of AxDbDocument.

    (vlax-put-property xdb 'Database
    (vlax-get-property dbxdoc 'Database)
    )

    (vlax-put-property xdb 'PreservePreview :vlax-true)

    After this, you can use any means to save the
    Drawing (e.g., AxDbDocument.SaveAs), and the
    thumbnail will be preserved.

    You can re-use the AcadXDatabase object and process
    multiple AxDbDocuments, but for each AxDbDocument,
    you must:

    1. Call the Open method of the AxDbDocument to
    load a .dwg file. This *must* be done before
    any of the following.

    2. Set the Database property of the AcadXDatabase
    object to the value of the AxDbDocument's
    Database property.

    3. Set the AcadXDatabase.PreservePreview property
    to :vlax-true.

    Unfortunately, a bug in the AcadXDatabase class
    was just fixed (in both the R15 and R16 versions),
    which may complicate your use of it, and the update
    for both versions is only available to licensees.



    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning
     
    Tony Tanzillo, Jun 24, 2004
    #2
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.