• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Valued Contributor
    Posts: 61
    Registered: ‎02-19-2007

    Import Views from 1700 Drawings

    88 Views, 1 Replies
    11-04-2009 12:12 PM
    I want to import the views from over 1700 drawings into one drawing. I have seen VIEWIMP.LSP by Tony Tanzillo and it is great for selecting one drawing at a time, but I want to process all drawings in a directory. It could be either using a list of drawing names or by selecting the directory or by selecting the multiple files (like for xref attach). Any ideas are greaty appreciated.
    Please use plain text.
    Valued Contributor
    Posts: 61
    Registered: ‎02-19-2007

    Re: Import Views from 1700 Drawings

    11-04-2009 02:27 PM in reply to: soverstreet
    I found a way to do what I need. I noticed the Thread: get bounds of a block (thanks devitg) and used the code there as a starting point.

    The views needed are for the extents of the 1700 drawings. So I xref's the drawings on layer "0" and ran the following code. Some of the file names have extra text after a "_" so the testmode part is to strip that off and use only the front part of the drawing name for the view name.

    My code is a quick beginning, so if anyone want to suggest improvements here's what I have:

    (defun MYVIEWMAKE ()
    (setq D-L NIL)
    (setq U-R NIL)
    (setq ONE (vlax-ename->vla-object (ssname SS INDEX)))
    (setq MYOBJECT (vla-get-objectname ONE))
    (if (= (vla-get-objectname ONE) "AcDbBlockReference")
    (progn
    (if (vlax-method-applicable-p ONE 'GETBOUNDINGBOX)
    (progn (vla-getboundingbox ONE 'min 'max)
    (setq D-L (vlax-safearray->list min)) ;_ the down left point
    (setq LLXX (car D-L))
    (setq LLYY (cadr D-L))
    (setq LLXX_TXT (rtos (car D-L)))
    (setq LLYY_TXT (rtos (cadr D-L)))

    (setq LL_COORDS (strcat "x=" LLXX_TXT " " "y=" LLYY_TXT))
    (setq LL_PT (strcat LLXX_TXT "," LLYY_TXT))

    (setq U-R (vlax-safearray->list max)) ;_ the Up Rigth point
    (setq URXX (car U-R))
    (setq URYY (cadr U-R))
    (setq URXX_TXT (rtos (car U-R)))
    (setq URYY_TXT (rtos (cadr U-R)))

    (setq UR_COORDS (strcat "x=" URXX_TXT " " "y=" URYY_TXT))
    (setq UR_PT (strcat URXX_TXT "," URYY_TXT))
    (command "-view" "w" VIEWNAME LL_PT UR_PT)
    ) ;_ progn
    ) ;_ if
    ) ;_ progn
    ) ;_ IF block
    ) ;_ end of defun

    (defun C:XREF_VIEWS_MAKE ()
    (vl-load-com)
    (setq SS (ssget "X" (list (cons 0 "insert") (cons 8 "0"))))
    (setq N (sslength SS))
    (setq INDEX -1)
    (if (/= SS NIL)
    (repeat N
    (setq INDEX (+ 1 INDEX))
    (setq BLK_ID (ssname SS INDEX))
    (setq BLK (entget BLK_ID))
    (setq XREF_NAME (cdr (assoc 2 BLK)))
    (princ (strcat "\n XRef Name is: " XREF_NAME))
    (terpri)
    (setq LNGTH (strlen XREF_NAME))
    (setq VIEWNAME "")
    (setq CHECK_LETTER "")
    (setq INC 0)
    (setq TESTMODE "GO")
    (while TESTMODE
    (progn
    (setq INC (+ 1 INC))
    (setq TRIM_NAME (substr XREF_NAME INC))
    (setq FIRST_LETTER (substr TRIM_NAME 1 1))
    (if (= FIRST_LETTER "_")
    (setq TESTMODE NIL)
    (progn
    (setq VIEWNAME (strcat VIEWNAME FIRST_LETTER))
    ) ;_ end of progn
    ) ;_ end of if
    (if (= LNGTH INC)
    (setq TESTMODE NIL)
    ) ;_ end of if
    ) ;_ end of progn
    ) ;_ end of while
    (princ (strcat "\n View Name is: " VIEWNAME))
    (terpri)
    (MYVIEWMAKE)
    ) ;_ end of repeat
    ) ;_ end of if
    ) ;_ end of defun Edited by: soverstreet@greenvillewater.com on Nov 4, 2009 5:30 PM
    Please use plain text.