Jump to content

dcl drawing selection box


O-man

Recommended Posts

morning, from maine,

 

I have wrote a lisp routine that when a drawing is open this routine creates a script file and runs it for that directory of the sheet open. my issue is that i need to visually select the specific drawings  Iin that directory and have that pass through my script. I stumbled upon afralisps .DCL and script for the life of me i cant seem to get the box to open/run. It keeps returning nil.

if there is a better way of doing such a thing as in vba getting a dialogue box and passing the info that way im not against it. a co-worker told me that DCL really is a cumbersome thing. 

 

here is my script:

#

(defun c:pageme (/ workingfile readfile openfile dir dname dwgbase dwgname)
  (setq dwgbase (getvar "dwgprefix"))
  (setq dwgname (getvar "dwgname"))
  (setq mktempdir (strcat "mkdir " "c:\\temp\\cbeli_temp\\"))
  (command "shell" mktempdir )
  (setq deltempdir (strcat "del /q c:\\temp\\cbeli_temp\\" "*.*"))
  (command "shell" deltempdir )
  (setq copyfiles (strcat "xcopy " dwbase "*.dwg" "c:\\temp\\cbeli_temp\\")
  (if (and (setq workingfile (strcat dwgbase "script.txt"))
(setq readfile (strcat dwgbase dwgname))
     (setq dir (vl-filename-directory readfile)))
(progn
(setq openfile (open workingfile "w"))
(foreach dname (vl-directory-files ( print dwgbase ) "*.dwg" 1) ;<-- probably the dname will hold the selected files im not sure
   (princ (strcat "open "dir """\\"""dname "\n" ; <--this is where i would like to pass the selection string from the DCL box
          "tilemode" "\n" "0" "\n"
         "ZOOM" "\n" "ALL" "\n"
         "_.-attedit" "\r" "y" "\r" "border" "\r" "sh_no" "\r" "\r" "cross" "\r" "-2,-2" "\r" "10,10" "\r" "v" "\r" "R" "\r" (substr dname 3 2) "\r" "\r"
         "qsave" "\n" "close" "\r" "\n") openfile);princ
  );foreach
(princ (strcat "(" "cbeli_mi " )openfile)
(prin1 (print dwgbase) openfile)
(princ (print ")" ) openfile)

(close openfile)
);progn
  (princ "\n<!> didnt do somthing correct <!>")
  );if

  (alert (strcat "file has been made here: " workingfile))
(princ))

#

 

the script that afralisp aka "kenny rammage" (https://www.afralisp.net/archive/vl/vl-dir1.htm) has written: .DCL FILE

#

FILES : dialog { label="AfraLisp File Dialog"; : text { key="CDIR"; } : row { : list_box { key="DIR"; label="Select Directory :"; width=25; fixed_width_font = true; } : list_box { key="FIL"; label="Select Files :"; width = 30; tabs = "20 31 40"; multiple_select = true; fixed_width_font = true; } } : row { : text { key="DIRS"; } : text { key="FILS"; } } : popup_list { key="EXT"; label="Select File Type :"; fixed_width_font = true; } ok_cancel; }

#

the script that afralisp aka "kenny rammage" (https://www.afralisp.net/archive/vl/vl-dir1.htm) has written: .LSP FILE

# (defun FileSelect (Dir Pat)
(setq DH (load_dialog "afrafiles"))
  (if (and DH (new_dialog "FILES" DH))
    (progn
      (setq iExt 0)
      (Refresh_Display)
      (start_list "EXT")
      (mapcar 'add_list Pat)
      (end_list)
      ;
      (action_tile "DIR" "(new_dir $value)")
      (action_tile "EXT" "(new_mask $value)")
      (action_tile "FIL" "(picked $value)")
      ;
      (if (= (start_dialog) 0)
(setq File_List nil)
      )
      (unload_dialog DH)
    )
  )
  File_List
)
;------------------------------------------------
(defun Refresh_Display ()
  (start_list "FIL")
  (end_list)
  (set_tile "CDIR" "Working...")
  (setq FL (VL-Directory-Files
             ;Dir Pat 1)
             Dir (nth iExt Pat) 1)
DR (VL-Directory-Files
     Dir nil -1)
FL (VL-Sort FL 'str_compare)
DR (VL-Sort DR 'str_compare)
)
  (start_list "DIR")
  (mapcar 'add_list DR)
  (end_list)
  (start_list "FIL")
  (if Show_the_details
    (mapcar
      '(lambda (F)
(setq Dt (VL-File-SysTime
    (strcat Dir F))
       F1 (if Dt
    (strcat
      F
      "\t"
      (itoa_f (nth 1 Dt) 2)
      "/"
      (itoa_f (nth 3 Dt) 2)
      "/"
      (itoa_f (nth 0 Dt) 4)
      "\t"
      (itoa_f (nth 4 Dt) 2)
      ":"
      (itoa_f (nth 5 Dt) 2)
      ":"
      (itoa_f (nth 6 Dt) 2)
      )
    (strcat F "\t\t")
  )
       Sz (VL-File-Size (strcat Dir F))
       F1 (strcat
    F1
    "\t"
    (rtos Sz 2 0))
       )
     (add_list F1))
  FL)
    (mapcar 'add_list FL)
  )
  (end_list)
  (set_tile "DIRS"
    (strcat
      "Directories = "
      (itoa (length DR))))
  (set_tile "FILS"
    (strcat
      "Files = "
      (itoa (length FL))))
  (set_tile "CDIR" Dir)
  )

(defun New_Dir (Pth)
  (setq Pth (nth (atoi Pth) DR))
  (cond
    ((= Pth ".")
     nil
     )
    ((= Pth "..") ;;back up a directory
     ;;remove directory name up one
     (setq L (1- (strlen Dir))
   Dir (substr Dir 1 L)
   )
     (while (/= (substr Dir L 1) "/")
       (setq L (1- L)))
     (setq Dir (substr Dir 1 L))
    )
    ('T
     (setq Dir (strcat Dir Pth "/"))
     )
  )
  (Refresh_Display)
)
;------------------------------------------------
;; Call back function to handle new file mask
;; selection by the user.
;;

(defun New_Mask (II)
  (setq iExt (atoi II))
  (Refresh_Display)
)
;
;------------------------------------------------
;; Call back function for saving the selected
;; file list in the variable FILE_LIST.
;;

(defun Picked (val / V)
  (setq val (read (strcat "(" Val ")"))
File_List
(mapcar '(lambda (V)
    (strcat
      Dir
      (nth V FL)))
Val)
)
)
;;-----------------------------------------------
;; Convert integer to padded ASCII string 
;;

(defun Itoa_F (I Digs)
  (setq I (itoa I))
  (while (< (strlen I) Digs)
    (setq I (strcat "0" I)))
  I
  )
;;-----------------------------------------------
(defun Str_Compare (T1 T2)
  (< (strcase T1)
     (strcase T2)))

(princ)
;;-----------------------------------------------
;CODING ENDS HERE

#

Edited by O-man
forgot to add dcl script
Link to comment
Share on other sites

If you look at lee-mac's web site you have a  list selection dcl that display a list and you add to a second list. Pretty sure he has a get dwg's in a directory to a list as well, they will do what you want to build the final list of dwgs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...