Results 1 to 2 of 2

Thread: Enabling ObjectDBX for more actions?

  1. #1
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Enabling ObjectDBX for more actions?

    Hi to all, recently I was experimenting with ObjectDBX and I've found out that I can't enable it for some extra simple tasks :
    So here is the problem, I want to set current layer in all dozen of dwgs to "0" layer and then make line pt1-pt2...

    Code:
    (defun CLAYTO0+LIN ( doc adoc / 0lay msp pt1 pt2 ) (vl-load-com)
      (setq *lay (vla-get-layers adoc))
      (vlax-for lay *lay
        (if (= (vla-get-name lay) "0") (setq 0lay lay))
      )
      (vla-put-activelayer adoc 0lay)
      (setq msp (vla-get-modelspace adoc))
      (setq pt1 '(0.0 0.0 0.0))
      (setq pt2 '(100.0 100.0 100.0))
      (vla-addline msp (vlax-3d-point pt1) (vlax-3d-point pt2))
      t ;; Success for layer 0
    )
    
    (defun C:TEST ( )
      (LOAD (findfile "ObjectDBX Wrapper.lsp"))
      (LM:ODBX 'CLAYTO0+LIN nil t)
    )
    Here are my changes to ObjectDBX Wrapper.lsp :
    Code:
    ;;------------------=={ ObjectDBX Wrapper }==-----------------;;
    ;;                                                            ;;
    ;;  Evaluates a function on all drawings in a supplied list   ;;
    ;;  or in a selected directory (and subdirectories)           ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  foo    - a function taking a two arguments                ;;
    ;;           (the ODBXDocument) and (the ActiveDocument)      ;;
    ;;                                                            ;;
    ;;  dwglst - [Optional] List of DWG Filenames, if nil,        ;;
    ;;           BrowseForFolder Dialog is displayed              ;;
    ;;                                                            ;;
    ;;  save   - Boolean flag determining whether drawings should ;;
    ;;           be saved after function evaluation (T=saved)     ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  List of ((<DWGFilename> . <FunctionResult>)...) ;;
    ;;                                                            ;;
    ;;  <DWGFilename>    is the drawing filename string           ;;
    ;;  <FunctionResult> is the result of evaluating the function ;;
    ;;  'foo' on the document object representing the drawing     ;;
    ;;   filename - note: this could be an Error Object           ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:ODBX ( foo dwglst save / *error* _ReleaseObject acapp acdoc acdocs dbx dbxx dbxdoc err path result ) (vl-load-com)
    
      (setq acapp  (vlax-get-acad-object)
            acdoc  (vla-get-ActiveDocument acapp)
            acdocs (vlax-for x (vla-get-documents acapp) (setq acdocs (cons (cons (strcase (vla-get-fullname x)) x) acdocs)))
            dbxdoc (LM:ObjectDBXDocument acapp)
      )
      
      (defun *error* ( msg )
        (mapcar '_ReleaseObject (list dbx dbxdoc))    
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))    
        (princ)
      )
    
      (defun _ReleaseObject ( obj )
        (and obj (eq 'VLA-OBJECT (type obj)) (not (vlax-object-released-p obj))
          (not
            (vl-catch-all-error-p
              (vl-catch-all-apply
                (function vlax-release-object) (list obj)
              )
            )
          )
        )
      )
    
      (if
        (setq dwgLst
          (cond
            ( dwgLst )
            ( (setq Path (LM:DirectoryDialog "Select Directory to Process" nil 832))
    
              (initget "Yes No")
              (LM:GetAllFiles Path (eq "Yes" (cond ( (getkword "\nProcess SubDirectories? <Yes> : ") ) ( "Yes" ))) "*.dwg")
            )
          )
        )
        (foreach dwg dwgLst
          (if
            (or (setq dbxx (cdr (assoc (strcase dwg) acdocs)))
              (progn
                (setq err
                  (vl-catch-all-apply 'vla-open (list dbxdoc dwg)) dbx dbxdoc
                ) 
                (not (vl-catch-all-error-p err))
              )
            )
            (progn
              (setq result (cons (cons dwg (vl-catch-all-apply foo (list dbx dbxx))) result))
              (if save (vla-saveas dbx dwg))
            )
            (princ (strcat "\n--> Error Opening File: " (vl-filename-base dwg) ".dwg"))
          )
        )
      )
    
      (mapcar '_ReleaseObject (list dbx dbxdoc))
      (reverse Result)
    )
    
    ;;-------------------=={ Directory Dialog }==-----------------;;
    ;;                                                            ;;
    ;;  Displays a dialog prompting the user to select a folder   ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  msg  - message to display at top of dialog                ;;
    ;;  dir  - root directory (or nil)                            ;;
    ;;  flag - bit coded flag specifying dialog display settings  ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  Selected folder filepath, else nil              ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:DirectoryDialog ( msg dir flag / Shell Fold Self Path )
      (vl-catch-all-apply
        (function
          (lambda ( / ac HWND )
            (if
              (setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application")
                    HWND  (vl-catch-all-apply 'vla-get-HWND (list ac))
                    Fold  (vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND) msg flag dir)
              )
              (setq Self (vlax-get-property Fold 'Self)
                    Path (vlax-get-property Self 'Path)
                    Path (vl-string-right-trim "\\" (vl-string-translate "/" "\\" Path))
              )
            )
          )
        )
      )
      (if Self  (vlax-release-object  Self))
      (if Fold  (vlax-release-object  Fold))
      (if Shell (vlax-release-object Shell))
      Path
    )
    
    ;;--------------------=={ Get All Files }==-------------------;;
    ;;                                                            ;;
    ;;  Retrieves all files or those of a specified filetype that ;;
    ;;  reside in a directory (and, optionally, subdirectories)   ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  Dir      - Directory to search                            ;;
    ;;  Subs     - Boolean, if T, subdirectories are included     ;;
    ;;  Filetype - (optional) Filter for filetype (DOS pattern)   ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  List of filenames, else nil if none are found   ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:GetAllFiles ( Dir Subs Filetype / _GetSubFolders )
      
      (defun _GetSubFolders ( folder )
        (apply 'append
          (mapcar
            (function
              (lambda ( f ) 
                (cons (setq f (strcat folder "\\" f)) (_GetSubFolders f))
              )
            )
            (vl-remove "." (vl-remove ".." (vl-directory-files folder nil -1)))
          )
        )
      )
    
      (apply 'append
        (mapcar
          (function
            (lambda ( Filepath )
              (mapcar
                (function
                  (lambda ( Filename ) (strcat Filepath "\\" Filename))
                )
                (vl-directory-files Filepath Filetype 1)
              )
            )
          )
          (cons Dir (if subs (_GetSubFolders Dir)))
        )
      )
    )
    
    ;;-----------------=={ ObjectDBX Document }==-----------------;;
    ;;                                                            ;;
    ;;  Retrieves a version specific ObjectDBX Document object    ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  _acad - AutoCAD VLA Application Object                    ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  VLA ObjectDBX Document object, else nil         ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:ObjectDBXDocument ( _acad / acVer )
      (vla-GetInterfaceObject _acad
        (if (< (setq acVer (atoi (getvar "ACADVER"))) 16)
          "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa acVer))
        )
      )
    )
    
    ;;------------------------------------------------------------;;
    ;;                         End of File                        ;;
    ;;------------------------------------------------------------;;
    I keep getting %catch-all-apply-error% and I don't quite understand why...
    If it is possible to do this simple tasks in other way or fix my error, please reply...
    Thanks, M.R.

  2. #2
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Enabling ObjectDBX for more actions?

    My question is answered :

    http://www.cadtutor.net/forum/showth...r-more-actions

    M.R.
    Sorry for duplicate posting...

Similar Threads

  1. Enabling worksharing on 2010 is slow
    By matt__w in forum Revit Structure - General
    Replies: 0
    Last Post: 2010-09-30, 03:26 PM
  2. Enabling Navisworks with TSI
    By Ron.Rico in forum NavisWorks - General
    Replies: 3
    Last Post: 2009-12-11, 11:25 PM
  3. project slow-down after enabling worksets
    By nora.112438 in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 3
    Last Post: 2009-12-04, 04:23 PM
  4. Enabling Lisp in AutoCAD LT
    By jsr13 in forum Software
    Replies: 9
    Last Post: 2005-12-07, 05:37 PM
  5. Error Enabling Worksets
    By iru69 in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 0
    Last Post: 2005-06-18, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •