Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/04/2026 in all areas

  1. I work with 2D CAD drawings for protective foam packaging and CNC, so overlapping geometry is something I pay attention to. Duplicate lines can create problems downstream, especially when preparing closed profiles for cutting. I think it's worth teaching beginners to check their geometry early instead of waiting until export.
    2 points
  2. I still try to think about LT usage when redoing an old LISP and creating new LISP, but it's not a real priority. If those that use LT around here need something done with a LISP and we can't find one that runs on LT, I can see if it's adjustable to be made to work or I can just do it for them. I originally asked this because an engineer with AutoCAD LT needed to convert a bunch of DGNs, I did end up converting a lot of folders with my LISP, but in the end the company that sent us the DGNs sent the exported from Autoplant .dwgs, etc., the DGNs we had converted okay, but IIRC some information was missing here and there for some of the files.
    1 point
  3. I was looking for something quick and simple yesterday - thanks. Now the not so quick part, I decided to make the DCL file as 'create on demand' style, and then tweak it a touch.... and then sent it through Al... a bit updated does what I want now. (Al was reasonably competent in it saved me about an hour copy-paste from my reference LISPs) Edit: Oh, for LT... forgetting the reason I was looking - shortcut links use VLAX code and I think the desktop part needs amending too - shortcuts are bypassed - won't work in LT - desktop I'll come back to ;;https://www.cadtutor.net/forum/topic/78817-selecting-folders-autocad-lt-2024/ (defun c:gf ( / DriveList CurDrive SubfolderList CurSubfolder GetFolderOldErr GetFolderDcl CurPath CurPathDisplay PathHistoryList PathFutureList MyResult) (defun GetFolder_init ( / DrawingDrive ) (setq GetFolderDcl (load_dialog "GetFolder")) (setq GetFolderOldErr *error*) (setq *error* GetFolderErr) (MakeDriveList) (setq CurPath (getvar "DWGPREFIX")) ;; Current drawing folder (setq DrawingDrive (substr CurPath 1 2)) ;; Drive (setq CurDrive (vl-position DrawingDrive DriveList)) ;; (setq CurDrive (- (length DriveList) (length (Member DrawingDrive DriveList)))) ;; Without VL- function for LT? (if (null CurDrive) (setq CurDrive 0)) ; End If (setq PathHistoryList (list)) (setq PathFutureList (list)) (MakeSubfolderList CurPath) ) ; End GetFolder_init (defun GetFolder_exit ( / ) (setq CurPath CurPath) ) ; End GetFolder_exit (defun GetFolderErr ( s / ) (GetFolder_exit) (if GetFolderOldErr (setq *error* GetFolderOldErr) (setq *error* '()) ) ; End If ) ; End GetFolderErr (defun MakeDriveList ( / ascii-code drive ) (setq DriveList '()) (setq ascii-code 67) ;; ASCII code C = 67, Z = 90. Ignore A: B: (while (<= ascii-code 90) (setq drive (strcat (chr ascii-code) ":") ) (if (> (vl-file-size (strcat drive "/")) 0.0) (setq DriveList (append DriveList (list drive))) ) (setq ascii-code (1+ ascii-code)) ) ; End While ) ; End MakeDriveList (defun MakeSubfolderList ( dir / MyFolderList MyShortcutList ) (if (and dir (= (type dir) 'STR) (vl-file-directory-p dir) ) ; End And (progn (setq MyFolderList (vl-directory-files dir nil -1) ) ;; Folders (if (wcmatch (strcase (getvar 'program)) "*LT*") (setq SubfolderList (append (list "<-┐") MyFolderList )) ;;LT: vl-directoryfiles might not work (progn (setq MyShortcutList (vl-directory-files dir "*.lnk" 1) ) ;; Shortcuts (setq SubfolderList (append (list "<-┐") MyFolderList MyShortcutList )) ) ; end progn ) ; end if ) ; End Progn (setq SubfolderList (list "<-┐")) ) ; End If (setq SubfolderList (vl-remove "." SubfolderList) ) (setq SubfolderList (vl-remove ".." SubfolderList)) (if (wcmatch CurPath "@`:") (setq SubfolderList (vl-remove "<-┐" SubfolderList)) ) ; End If ) ; End MakeSubfolderList (defun UpdateSubfolder ( $value / MyShortcut MyTarget MyShell ) (setq CurSubfolder (nth (atoi $value) SubfolderList )) (cond ((and (equal CurSubfolder "<-┐") (= (length PathHistoryList) 0) ) ; end and (progn (setq CurPath CurPath) ) ) ; end cond ((and (equal CurSubfolder "<-┐") (= (length PathHistoryList) 1) ) ; end and (progn (setq PathFutureList (append (list CurPath) PathFutureList)) (setq CurPath (car PathHistoryList)) ) ) ; end cond ((and (equal CurSubfolder "<-┐") (> (length PathHistoryList) 1) ) ; end and (progn (setq PathFutureList (append (list CurPath) PathFutureList)) (setq CurPath (car PathHistoryList)) (setq PathHistoryList (cdr PathHistoryList)) ) ) ; end cond ((and (wcmatch (strcase CurSubfolder) "*.LNK") (wcmatch (strcase (getvar 'program)) "*LT*") ) ; end and (progn ) ; end progn ) ; end cond ((and ;; LT VLAX- might not work (wcmatch (strcase CurSubfolder) "*.LNK") (= (strcase (getvar 'program)) "ACAD") ) ; end and (setq MyShell (vlax-create-object "WScript.Shell")) (setq MyShortcut (vlax-invoke-method MyShell 'CreateShortcut (strcat CurPath "\\" CurSubfolder))) (setq MyTarget (vlax-get-property MyShortcut 'TargetPath)) (vlax-release-object MyShortcut) (vlax-release-object MyShell) (if (and ;; if lnk is a folder MyTarget (vl-file-directory-p MyTarget) ) ; End And (progn (setq PathFutureList (list)) (setq PathHistoryList (append (list CurPath) PathHistoryList )) (setq CurPath MyTarget) ;; Jump to shortcut target ) ; End Progn (progn ) ; end progn ) ; End If ) ; end cond (T ;; Normal folder (setq PathFutureList (list)) (setq PathHistoryList (append (list CurPath) PathHistoryList )) (setq CurPath (strcat CurPath "\\" CurSubfolder) ) ;; Enter selected folder ) ; end cond T ) ; End Conds (BackwardandForward) ) ; End UpdateSubfolder (defun UpdateDrive ( $value / ) (setq CurDrive (atoi $value) ) (setq CurPath (nth CurDrive DriveList) ) (setq PathFutureList (list)) (setq PathHistoryList (list CurPath) ) (BackwardandForward) ) ; End UpdateDrive (defun UpdatePath ( dir / ) (if (and dir (= (type dir) 'STR) (vl-file-directory-p dir) ) ; End And (setq CurPath dir) (alert "Invalid Path") ) ; End If ) ; End UpdatePath (defun BackwardandForward ( / ) (MakeSubfolderList CurPath) ;; Rebuild folders and shortcuts for the new location (start_list "subfolder" 3) ;; Update DCL (mapcar 'add_list SubfolderList) (end_list) (set_tile "subfolder" "0") ;; Select first item in refreshed list (setq CurPathDisplay (substr CurPath (max 1 (- (strlen CurPath) 52)))) (if (< (strlen CurPath) 55) (setq CurPathDisplay CurPath)(setq CurPathDisplay (strcat "..." CurPathDisplay))) (while (wcmatch (setq CurPathDisplay (vl-string-subst "\\" "\\\\" CurPathDisplay)) "*\\\\*")) (set_tile "path" CurPathDisplay) ) (defun BackLevel ( / MyShortcut MyTarget MyShell ) (setq CurSubFolder "<-┐") (cond ((= (length PathHistoryList) 0) (progn ) ) ; end cond 0 History List ((= (length PathHistoryList) 1) ;; top level (progn (setq PathFutureList (append (list CurPath) PathFutureList)) (setq CurPath (car PathHistoryList)) (setq PathHistorylist (list)) (BackwardandForward) ) ; end progn ) ; end cond History list 1 ((> (length PathHistoryList) 1) (progn (setq PathFutureList (append (list CurPath) PathFutureList)) (setq CurPath (car PathHistoryList)) (setq PathHistoryList (cdr PathHistoryList)) (BackwardandForward) ) ; end progn ); end cond PF > 1 (T (progn ) ) ; end T ) ; end conds ) ; End BackLevel (defun ForwardLevel ( / MyShortcut MyTarget MyShell ) (setq CurSubFolder "<-┐") (cond ((= (length PathFutureList) 0) (progn ) ) ; end cond 0 future List ((= (length PathFutureList) 1) ;; top level (progn (setq PathHistoryList (append (list CurPath) PathHistoryList)) (setq CurPath (car PathFutureList)) (setq PathFuturelist (list)) (BackwardandForward) ) ; end progn ) ; end cond Future list 1 ((> (length PathFutureList) 1) (progn (setq PathHistoryList (append (list CurPath) PathHistoryList)) (setq CurPath (car PathFutureList)) (setq PathFutureList (cdr PathFutureList)) (BackwardandForward) ) ; end progn ); end cond PF > 1 (T (progn ) ) ; end T ) ; end conds ) ; End ForwardLevel (defun UpLevel ( / MyParentPath ) ;; Remove trailing slash if present (if (or (= (substr CurPath (strlen CurPath) 1) "\\") (= (substr CurPath (strlen CurPath) 1) "/") ) ; Endor (setq CurPath (substr CurPath 1 (1- (strlen CurPath))) ) ) ; End If (setq MyParentPath (vl-filename-directory CurPath)) ;; parent folder (if MyParentPath (progn (setq PathFutureList (list)) (setq PathHistoryList (append (list CurPath) PathHistoryList)) (setq CurPath MyParentPath) (BackwardandForward) ) ; End Progn ) ; End If ) ; End UpLevel (defun DesktopLevel ( / MyShell MyDesktop ) ;;Double check for none VLAX for LT (if (wcmatch (strcase (getvar 'program)) "*LT*") (progn (setq MyDesktop (getenv "USERPROFILE")) (if MyDesktop (setq MyDesktop (strcat MyDesktop "\\Desktop")) (setq MyDesktop nil) ) ; End If ) ; end progn (progn (setq MyShell (vlax-create-object "WScript.Shell") ) (setq MyDesktop (vlax-invoke-method (vlax-get-property MyShell 'SpecialFolders) 'Item "Desktop")) (vlax-release-object MyShell) ) ; end progn ) ; end if (if (and MyDesktop (vl-file-directory-p MyDesktop) ) ; End And (progn (setq PathFutureList (list)) (setq PathHistoryList (append (list CurPath) PathHistoryList)) (setq CurPath MyDesktop) (BackwardandForward) ) ; End Progn (alert "Desktop folder not found.") ) ; End If ) ; end defun update desktop (defun DCL_Images ( / ); Rename function as required (defun CreateVector ( VectList XOff YOff TxCol / n) (foreach n VectList (vector_image (+ origin Xoff (nth 0 n))(+ Yoff (nth 1 n)) (+ origin Xoff (nth 2 n))(+ Yoff (nth 3 n)) (nth 4 n)) ) ; end foreach ) (setq TxCol 7) (setq Origin 0) (setq XOff 0) (setq YOff 5) (start_image "Im0"); Change to your image tile name (fill_image 0 0 (dimx_tile "Im0") (dimy_tile "Im0") -15); and change to your image name (setq BlkList (list (list 17 19 17 21 TxCol)(list 17 8 8 15 TxCol)(list 17 19 8 13 TxCol)(list 17 21 6 14 TxCol) (list 17 6 6 14 TxCol)(list 17 8 17 6 TxCol)(list 8 13 25 13 TxCol)(list 8 15 8 13 TxCol) (list 25 15 8 15 TxCol)(list 25 13 25 15 TxCol) )) (CreateVector BlkList XOff YOff TxCol) (end_image) (start_image "Im1"); Change to your image tile name (fill_image 0 0 (dimx_tile "Im1") (dimy_tile "Im1") -15); and change to your image name (setq BlkList (list (list 15 19 15 21 TxCol)(list 15 8 24 15 TxCol)(list 15 19 24 13 TxCol)(list 15 21 26 14 TxCol) (list 15 6 26 14 TxCol)(list 15 8 15 6 TxCol)(list 24 13 7 13 TxCol)(list 24 15 24 13 TxCol) (list 7 15 24 15 TxCol)(list 7 13 7 15 TxCol) )) (CreateVector BlkList XOff YOff TxCol) (end_image) );defun (defun InitDialog ( / ) (start_list "drive") (mapcar 'add_list DriveList) (end_list) (DCL_Images) (set_tile "drive" (itoa CurDrive)) ;; Select the drive containing the current drawing (start_list "subfolder") (mapcar 'add_list SubfolderList) (end_list) (setq CurPathDisplay (substr CurPath (max 1 (- (strlen CurPath) 52)))) (if (< (strlen CurPath) 55) (setq CurPathDisplay CurPath)(setq CurPathDisplay (strcat "..." CurPathDisplay))) (while (wcmatch (setq CurPathDisplay (vl-string-subst "\\" "\\\\" CurPathDisplay)) "*\\\\*")) (set_tile "path" CurPathDisplay) ) ; End InitDialog (defun CopyLink ( / MyResult ) ;; Might not work in LT (setq MyResult CurPath) (if (wcmatch (strcase (getvar 'program)) "*LT*") ;; LT Version (progn (setq MyTempFile (vl-filename-mktemp "CopyLink" nil ".cmd")) (setq MyFile (open MyTempFile "w")) (write-line "@echo off" MyFile) (write-line (strcat "<nul set /p =\"" CurPath "\" | clip.exe" ) MyFile) (close MyFile) (startapp MyTempFile) ) ; end prog (progn (while (wcmatch (setq MyResult (vl-string-subst "\\" "\\\\" MyResult)) "*\\\\*")) (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'SetData "Text" MyResult ) ) ; end progn ) ; end if ) (defun GetFolder_dialog ( / fname GF drv MyDclFile dcl_id MyFile) ;; Create DCL file ;;Start DCL (if (strcat (getvar "TEMPPREFIX") "GetFolder.dcl")(vl-file-delete (strcat (getvar "TEMPPREFIX") "GetFolder.dcl"))) (setq editdcl (strcat (getvar "TEMPPREFIX") "GetFolder.dcl")) (setq GF (open editdcl "w")) ;;Header (write-line "SelLays : dialog {" GF) (write-line " key = \"Folder\";" GF) (write-line " label = \"GetFolder (RLX-10/04)\";" GF) (write-line " spacer;" GF) ;;Stuff (write-line ":column { width = 60; fixed_width = true; " GF) (write-line " :row {alignment = top; fixed_width = True; width = 60;" GF) (write-line " :column { width = 3; fixed_width = true; " GF) (write-line " : popup_list { key = \"drive\"; label = \"Drive\"; edit_width = 2; fixed_width = True; }" GF) (write-line " }" GF) ; end column (write-line " :column {width = 50; fixed_width = true; " GF) (write-line " :text { key = \"path\"; label = \"Folder Location\"; width = 50; fixed_width_font = false; }" GF) (write-line " }" GF) ; end column (write-line " :column { width = 7; fixed_width = true; " GF) ;; (if (wcmatch (strcase (getvar 'program)) "*LT*") ; To take out coy button if command window is tooo annoying ;; (progn) (write-line " : button { key = \"CopyLink\"; label = \"Copy\"; width = 3; }" GF) ;; ) (write-line " }" GF) ; end column (write-line " }" GF) ; end row (write-line " :row {alignment = top; fixed_width = True; width = 60;" GF) (write-line " :column { width = 12; fixed_width = true; " GF) (write-line " :row {alignment = top;" GF) ;(write-line ":image_button {key = Im0; width = 4; height = 2; color = dialog_background; allow_accept = true; alignment = centered;}" GF) ;(write-line ":image_button {key = Im1; width = 4; height = 2; color = dialog_background; allow_accept = true; alignment = centered;}" GF) (write-line " : button { key = \"backlevel\"; label = \"<--\"; width = 5; }" GF) (write-line " : button { key = \"forwardlevel\"; label = \"-->\"; width = 5; }" GF) (write-line " : button { key = \"uplevel\"; label = \"↑ Up level\"; width = 5; }" GF) (write-line " : button { key = \"desktop\"; label = \"Desktop\"; width = 5; }" GF) (write-line " }" GF) ; end row (write-line " }" GF) ; end column (write-line " :column { width = 6; fixed_width = true; " GF) (write-line " }" GF) ; end column (write-line " :column { width = 5; fixed_width = true; " GF) (write-line " }" GF) ; end column (write-line " }" GF) ; end row (write-line " :row {alignment = top; fixed_width = True; width = 60;" GF) (write-line " : list_box { key = \"subfolder\"; label = \"Subfolders\"; height = 12; width = 45; }" GF) (write-line " }" GF) ; end row (write-line " ok_cancel;" GF) (write-line "}" GF) ; end column (write-line "}" GF) ; end dialog (close GF) (< 0 (setq dcl_id (load_dialog editdcl))) (if (and dcl_id (new_dialog "SelLays" dcl_id) ) ; End And (progn (InitDialog) (action_tile "drive" "(UpdateDrive $value)" ) (action_tile "desktop" "(DesktopLevel)" ) (action_tile "CopyLink" "(CopyLink)" ) (action_tile "backlevel" "(BackLevel)" ) (action_tile "Im0" "(BackLevel)") (action_tile "forwardlevel" "(ForwardLevel)" ) (action_tile "Im1" "(ForwardLevel)" ) (action_tile "uplevel" "(UpLevel)" ) (action_tile "desktop" "(DesktopLevel)" ) (action_tile "subfolder" "(UpdateSubfolder $value)" ) (action_tile "path" "(UpdatePath $value)" ) (action_tile "accept" "(done_dialog 1)" ) (action_tile "cancel" "(done_dialog 0)" ) (setq drv (start_dialog)) (cond ((= drv 0) (setq CurPath nil) ) ((= drv 1) (setq CurPath CurPath) ) ) ; End Cond ) ; End Progn ) ; End If (if dcl_id (unload_dialog dcl_id) ) ) ; End GetFolder_dialog (GetFolder_init) (GetFolder_dialog) (setq MyResult (strcat (GetFolder_exit) "\\")) (while (wcmatch (setq MyResult (vl-string-subst "\\" "\\\\" MyResult)) "*\\\\*")) MyResult ) Edited to tidy the code, add a couple of buttons and 'copy' filepath to clipboard - should by LT compatible and if not should skip past those parts
    1 point
×
×
  • Create New...