vla-get-documents

Discussion in 'AutoCAD' started by rewilson, Feb 12, 2004.

  1. rewilson

    rewilson Guest

    Yes it did Rudy........a very wild tangent. Sorry about that. But in reply to your post, you're much more educated in these
    matters than I, so you're probably right. However, I know nothing of DBX. How would it work, because what I'm doing now isn't going so well. Can you fill me in? TIA
     
    rewilson, Feb 13, 2004
    #21
  2. rewilson

    Jeff Mishler Guest

    Rudy's idea won't work because ObjectDBX requires that the drawing it is
    getting data from not be open in acad.
    I think that Robert Bell's suggestion of unloading if no raster commands
    have been used in a certain time period would be a good way to go.

    Jeff

    reply to your post, you're much more educated in these
    DBX. How would it work, because what I'm doing now isn't going so well.
    Can you fill me in? TIA
     
    Jeff Mishler, Feb 13, 2004
    #22
  3. rewilson

    Doug Broad Guest

    Robert's Idea? ;-)

    Everyone have a "Happy Valentines Day!"
     
    Doug Broad, Feb 13, 2004
    #23
  4. Well, Doug, you and I look so much alike. 8^)

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    Robert's Idea? ;-)

    Everyone have a "Happy Valentines Day!"
     
    R. Robert Bell, Feb 13, 2004
    #24
  5. rewilson

    Rudy Tovar Guest

    From the Vlisp developers bible - 2003 edition, and for 2000+ I believe.

    Let's suppose for example, that you would like to be able to search a
    directory of files to find those contain a specific block insertion. While
    you could open drawing and fetch the blocks table or do a (ssget) search,
    there is another way to do this without ever opening the drawing in a the
    AutoCAD editor: ObjectDBX.

    (defun DLLRegister (dll) (startapp "regsvr32.exe" (strcat "/s \"" dll
    "\"")))
    (defun DLLUnRegister (dll) (startapp "regsvr32.exe" (strcat "/u /s \"" dll
    "\"")))
    (defun ProgID->Classid (ProgID)(vl-registry-read (strcat
    "HKEY_CLASSES_ROOT\\" progid \\CLSID")))

    (defun DBX-Register ( / classname)
    (setq classname "ObjectDBX.AxDbDocument")
    (cond
    ((ProgID->Class classname))
    ((and
    (setq server (findfile "AxDb15.dll"))
    (DLLRegister server)
    (ProgID->ClassID classname)
    )
    (ProgID->ClassID classname)
    )
    ((not (setq server (findfile "AxDb15.dll")))
    (alert "Error: Cannot located ObjectDBX Type Library (AxDb15.dll)...")
    )
    (T
    (DLLRegister "ObjectDBX.AxDbDocument")
    (or
    (ProgID->ClassID "ObjectDBX.AxDbDocument")
    (alert "Error: Failed to register ObjectDBX ActiveX services...")
    )
    )
    )
    )

    The (dllregister) function is a general-purpose tool you can use to perform
    a Windows DLL registration on a client using the REGSVR32 command through a
    shell operation. The /S parameter denotes a silent registration which
    suppresses any notifications durring the registration process.

    The (dllunregister) function performs the opposite of (dllregister), whereby
    it removes a DLL's registration from a local machine. This is often useful
    for removing a DLL when you need to register an updated version of the same
    DLL.

    The (progid->classid) function performs a look-up of a given class
    registration in the Windows Registry and returns the GUID, which is a
    lengthy encoded unique identifier for a given ActiveX component. No two GUID
    values are the same as they are generated by a complex hashing algorithm
    during compilation. This particular function verifies that a given DLL has
    been registered by checking for its GUID in the registry. If no GUID is
    found, the DLL has not been registered yet, and this returns nil. Then you
    can use (dllregister) to register the DLL on the client machine.

    The following function opens a remote drawing document and returns the DBX
    document object if successful, otherwise it returns nil. You can use this
    function to take care of the messy stuff and simply use the returned
    document object to perform any operations you desire.

    (defun DBX-doc-open (filename / dbxdoc)
    (cond
    ((findfile filename)
    (if (not (DBX-register))
    (exit)
    )
    (setq dbxdoc
    (vla-getinterfaceobject
    (vlax-get-acad-object) "ObjectDBX.AxDbDocument"))
    (cond
    ((vl-catch-all-error-p
    (vl-catch-all-apply
    'vla-Open (list dbxdoc (findfile filename))
    )
    )
    (princ "\nUnable to open drawing. ")
    (exit)
    )
    ( T dbxdoc )
    )
    )
    )
    )

    Now you have nice little black-box function to open drawings remotely, so
    you can move on to wrapping inside bigger and better things, like returning
    table lists and so forth. You can also modify certain properties of remove
    drawings throught DBX.

    (defun DBX-Get-TableList
    (filename tblname / dbxdoc out name)
    (cond
    ((setq dbxdoc (DBX-doc-open filename))
    (vlax-For tblitem (DBX-TableGet tblName dbxdoc)
    (setq name (vla-get-Name tblItem))
    (if (/= (substr name 1 1) "*")
    (setq out (cons name out))
    )
    )
    (vlax-release-object dbxdoc)
    )
    (T
    (strcat (princ "\nUnable to open file: " filename))
    )
    )
    (if out (reverse out))
    )

    (defun DBX-TableGet (tName object)
    (cond
    ((= (strcase tName) "BLOCKS") (vla-get-Blocks
    object))
    ((= (strcase tName) "LAYERS") (vla-get-Layers
    object))
    ((= (strcase tName) "TEXTSTYLES") (vla-get-textstyles
    object))
    ((= (strcase tName) "DIMSTYLES") (vla-get-dimstyles
    object))
    ((= (strcase tName) "LINETYPES") (vla-get-linetypes
    object))
    ((or
    (= (strcase tName) "PLOTCONFIGURATIONS")
    (= (strcase tName) "PAGESETUPS")
    )
    (vla-get-plotconfigurations object)
    )
    ((= (strcase tName) "LAYOUTS") (vla-get-Layouts object))
    ((= (strcase tName) "GROUPS") (vla-get-Groups object))
    (T
    (vl-exit-with-error "\n(dbx-dwgscan error): Invalid table name specified.")
    )
    )
    )

    The function shown use the ObjectDBX "Open" method to access a given drawing
    file and access a given table collection within it. Among the limitations of
    using ObjectDBX is that you cannot access tables within any drawings you
    have opened in your AutoCAD Documents collection, as this will generate an
    error. ObjectDBX enables access even if a drawing is opened by another user,
    as long as it is not opened by the user that is requesting the open the
    drawing through an Object DBX interface.

    (defun DWGSCAN
    ($table $name $dwgfiles / $files $dwgs $path $collection n out)
    (cond
    ((and $table $name $dwgfiles
    (princ
    (strcat
    "\nScanning "
    (itoa (length $dwgfiles))
    " drawings for "
    (strcase (sbustr $table 1 (1- (strlen $table))) t)
    " [" $name "]..."
    )
    )
    (foreach n $dwgfiles
    (cond
    ((setq $collections (DBX-GetTableList n $table))
    (cond
    ((member (strcase sname) (mapcar 'strcase $collection))
    (setq out (cons n out))
    )
    )
    (setq $collection nil)
    )
    (T (princ "\nUnable to query table collection in target drawing. "))
    )
    )
    )
    (T (princ "\nUsage: (DWGSCAN tablename itemname drawingfiles) "))
    )
    (if out (reverse out))
    )

    If you load the example file dbx-dwgscan.lsp into your AutoCAD session, you
    can use the (dwgscan) function to search for a items in other drawings. The
    example below demonstrates using (dwgscan) to search a list of drawings for
    a block named "Chair123".

    Command: (dwgscan "blocks" "Chair12" dwgfiles)

    Scanning 51 drawings for block [Chair123]...

    ("c:\\drawing\\plan003.dwg"
    "c:\\drawing\\plan004"
    )

    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi





    to your post, you're much more educated in these
    How would it work, because what I'm doing now isn't going so well. Can you
    fill me in? TIA
     
    Rudy Tovar, Feb 13, 2004
    #25
  6. rewilson

    Rudy Tovar Guest

    Are you sure?

    Read on...

     
    Rudy Tovar, Feb 13, 2004
    #26
  7. rewilson

    Rudy Tovar Guest

    Proof read the code, I may have made a typing mistake.

     
    Rudy Tovar, Feb 13, 2004
    #27
  8. rewilson

    Jeff Mishler Guest

    OOPS!!! Sorry Doug, I knew my memory was slipping but to have it go away
    after only a few minutes is worrisome.

    Jeff ...... I think
     
    Jeff Mishler, Feb 13, 2004
    #28
  9. rewilson

    Jeff Mishler Guest

    Rudy, you are correct, sort of........the part that would make us both
    right is:
    If the OP were to scan OTHER peoples machines , then ObjectDBX would
    work. But, the way the question was worded, he/she is looping through
    the ACAD.documents collection on the machine which is initiating the
    code, meaning ObjectDBX wouldn't be able to work with them.....

    Jeff
     
    Jeff Mishler, Feb 13, 2004
    #29
  10. rewilson

    Doug Broad Guest

    I'll take that as a compliment. ;-)
     
    Doug Broad, Feb 15, 2004
    #30
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.