+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Full Member vasqrainier's Avatar
    Using
    not applicable
    Join Date
    Sep 2006
    Posts
    63

    Default How to view and open a Dwg Files in a Folder...???

    Registered forum members do not see this ad.

    How to view and open a Dwg files in a Folder .. Folder Location is based on the DWGPREFIX... in Lisp programing..

  2. #2
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    I think you can only open dwg files through lisp, but not to view them. Try somethink like this:
    Code:
    (defun c:autoload (/ z-files-in-directory)
      ;; Returns file list in "directory" folder by mask
      ;; Author: Zuenko Vitaly aka ZZZ
      (defun z-files-in-directory (directory pattern nested /)
        (if	(not (listp pattern))
          (setq pattern (list pattern))
          ) ;_ if
        (if	nested
          (apply
    	'append
    	(append
    	  (mapcar '(lambda (_pattern)
    		     (mapcar '(lambda (f) (strcat directory "\\" f))
    			     (vl-directory-files directory _pattern 1)
    			     ) ;_ list
    		     ) ;_ lambda
    		  pattern
    		  ) ;_ mapcar
    	  (mapcar
    	    '(lambda (d)
    	       (z-files-in-directory
    		 (strcat directory "\\" d)
    		 pattern
    		 nested
    		 ) ;_ z-files-in-directory
    	       ) ;_ lambda
    	    (vl-remove
    	      "."
    	      (vl-remove ".."
    			 (vl-directory-files directory nil -1)
    			 ) ;_ end of vl-remove
    	      ) ;_ vl-remove
    	    ) ;_ mapcar
    	  ) ;_ append
    	) ;_ append
          (apply
    	'append
    	(mapcar	'(lambda (_pattern)
    		   (mapcar '(lambda (f) (strcat directory "\\" f))
    			   (vl-directory-files directory _pattern 1)
    			   ) ;_ list
    		   ) ;_ lambda
    		pattern
    		) ;_ end of mapcar
    	) ;_ end of apply
          ) ;_ end of if
        ) ;_ end of defun
    
      (foreach file	(z-files-in-directory
    		  (vl-string-right-trim "\\" (getvar "dwgprefix"))
    		  "*.dwg"
    		  nil
    		  ) ;_ end of z-files-in-directory
        ;; with subfolders
        (vla-open (vla-get-documents (vlax-get-acad-object)) file)
        ;;(command "_.-open" file)
        ) ;_ end of foreach
      ) ;_ end of defun
    All I say is only my opinion.

  3. #3
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Default

    Hi

    Code:
    (if (setq file (getfiled "Title" "" "dwg" 16))
      (progn
        (setq file (vla-open (vla-get-documents (vlax-get-acad-object)) file))
        (vla-activate file)
      )
    )
    @+

  4. #4
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    In this case:
    1. You're opening only 1 file
    2. You're activating it right now. But! LISP execution could be terminated!
    All I say is only my opinion.

  5. #5
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Default

    1. You're opening only 1 file
    Yes, it's only for one file
    If you want all files in a directory and you have installed express tools, try

    Code:
    (if (setq files (acet-ui-pickdir))
      (mapcar '(lambda (x) (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat files "\\" x))) (vl-directory-files files "*.dwg" 1))
    )
    You're activating it right now. But! LISP execution could be terminated!
    Yes, because i have activated the drawing. If i don't use (vla-activate file), the lisp continued and you can work with the variable file

  6. #6
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    Well, there is no guarantee to be Express Tools installed.
    the lisp continued
    I didn't knew it because I never open files for working with them through lisp.
    All I say is only my opinion.

  7. #7
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Default

    To know if the express tools are installed, it's enough to make (if (member "acetutil.arx" (arx)) ....)
    I found how to have dialogue box of vba msgbox and inputbox (in vlisp) without passing by the express tools, but by still for the repertories. I'm certain that that must be some share, because if I look in express tools (acet-ui-pickdir [title [path [message]]]), with objectdcl (Odcl_BrowseFolder message [Path]) and doslib (dos_getdir title [path [message]]), I find that it's the same thing. If you knows how to make, I'm a prennor

    @+

  8. #8
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    Does it yours?
    http://www.theswamp.org/index.php?topic=11480.0
    And related:
    http://www.theswamp.org/index.php?topic=9684.0
    ---
    Edited:
    I'm using my own ActiveX DLL for these messages, so it doesn't critical for me.
    All I say is only my opinion.

  9. #9
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Sep 2006
    Posts
    106

    Smile

    Yes, and i have posted for InputBox, but i don't find for a dialog box directories in this forum and another

    @+

  10. #10
    Senior Member kpblc's Avatar
    Using
    AutoCAD 2005
    Join Date
    May 2006
    Location
    Russia, St-Petersburg
    Posts
    317

    Default

    Registered forum members do not see this ad.

    I don't remember where from i cutted this code:
    Code:
    (defun browsefolder (msg / shlobj folder fldobj outval)
      (vl-load-com)
      (setq
        shlobj (vla-getinterfaceobject
    	     (vlax-get-acad-object)
    	     "Shell.Application"
    	     ) ;_ end of vla-getInterfaceObject
        folder (vlax-invoke-method
    	     shlobj
    	     'browseforfolder
    	     0
    	     (if msg
    	       msg
    	       ""
    	       ) ;_ end of if
    	     0
    	     ) ;_ end of vlax-invoke-method
        ) ;_ end of setqs
      (vlax-release-object shlobj)
      (if folder
        (progn
          (setq
    	fldobj (vlax-get-property folder 'self)
    	outval (vlax-get-property fldobj 'path)
    	) ;_ end of setq
          (vlax-release-object folder)
          (vlax-release-object fldobj)
          outval
          ) ;_ end of progn
        ) ;_ end of if
      ) ;_ end of defun
    All I say is only my opinion.

Similar Threads

  1. Open File Dialog Box - How do I Change to Detail View
    By Weirdo109 in forum AutoCAD General
    Replies: 3
    Last Post: 10th May 2007, 05:23 pm
  2. Cannot open files
    By careyc in forum Autodesk Software General
    Replies: 11
    Last Post: 11th Jan 2007, 03:57 pm
  3. Open dwg. folder
    By windseaker in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 1st Nov 2005, 10:29 pm
  4. Default File Open Folder
    By WannaBeCader in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 6th Jun 2005, 03:23 pm
  5. Can you change which folder Open command goes to?
    By fewer_98 in forum AutoCAD General
    Replies: 6
    Last Post: 2nd Sep 2004, 10:14 pm

Bookmarks

Posting Permissions

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