Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/11/2023 in all areas

  1. This is what I have to generate a script file to process a folder. You will have to rewrite the script part tho. ;;----------------------------------------------------------------------------;; ;; Generate a Script file for drawings in a folder (defun C:Gen-Script (/ Path UserFile BlkLst F1 FileName) (setq UserFile (getfiled "Choose a Folder to Process" (getvar 'DWGPREFIX) "*" 16) Path (vl-filename-directory UserFile) BlkLst (vl-directory-files Path "*.sat" 1) ;change extention to find dwg or dxf BlkLst (vl-remove (getvar 'DWGNAME) blkLst) ;if Active Drawing is in the same folder remove BlkLst (vl-sort blkLst '<) F (open (strcat (getenv "userprofile") "\\Documents\\Script.scr") "w") ;Save script in My Documents ) (if BlkLst (progn (foreach FileName BlkLst (write-line (strcat "_.Import \"" Path "\\" FileName "\"") F) ;; maybe idk ;.... other stuff (write-line "_.qsave" F) ) ) (prompt "\nNo Files Found in Folder") ) (close F) (prompt (strcat "\nScript File for " (itoa (length BlkLst)) " Files Created")) (if (= (ACET-UI-MESSAGE "Do you Want to run the Script Now?" "User Input" (+ Acet:YESNO Acet:ICONWARNING)) 6) ;Yes (vl-cmdf "_.Script" (strcat (getenv "userprofile") "\\Documents\\Script.scr")) ) (princ) )
    2 points
  2. Hi. This time for a change I am not whining about problems, but sharing a lisp created by knowledge shared here on the forum and I hope this lisp will be useful to other members here as it was effective for me. the lisp prompt the user to select the block to use for the selection set and then promt the user to select the items in the desiered area and select only the blocks of the of the desiered block that was selected in the first step. the lisp also select parametric blocks (I'm a bricscad user...) with *U name,probebly a dynamic blocks in autocad. regards, aridzv. Sel_Bl_ByName.lsp
    1 point
  3. Thanks mhupp! I got on command line (error: no function definition: CHECKI) then commented out the (CHECK) and it worked. That LISP is a great start! I'll look at your bit later Steven P, I get the Script.scr, but at the end no message working and on the command line (Usage: (acet-ui-message <text> [<caption> [<type>]]) ; error: ADS request error). So looks like what you posted is correct. Not sure when I'll get back to this, hopefully today.
    1 point
  4. Had trouble getting the message working, had to change it to this format: (ACET-UI-MESSAGE "\nDo you want to Run Script Now?" "Title" 52)
    1 point
  5. Thankyou both - I will try today and let you know how I get on. Thanks again Ash
    1 point
  6. I was literally doing a similar thing for my script a few weeks ago. I did it this way: ;********************************************************; ; Function: zoom_susp ; Arguments: ; susp (entity): Suspension entity ; Returns: ; vpinfo (list): List of viewport center and custom scale ; Description: ; This function performs a zoom operation in AutoCAD to zoom to the given suspension entity. ; It retrieves the center point of the suspension entity using the (cdr (assoc 10 (entget))) expression. ; The function then retrieves the active viewport entity and VLA object using cvport->ent function. ; It temporarily unlocks the display, performs the zoom operation using the "_.zoom" command, ; and locks the display again. Finally, it returns a list containing the viewport center and custom scale. ; Usage: (zoom_susp susp) (defun zoom_susp (susp vpinfo / susp-cent ent obj vpcenter vpscale) (setq susp-cent (cdr (assoc 10 (entget susp)))) (setq ent (cvport->ent)) (setq obj (vlax-ename->vla-object ent)) (command "_.mspace") ;(vlax-put-property obj 'DisplayLocked :vlax-false) ;(vla-put-lock obj :vlax-false) (vla-put-displaylocked obj 0) ;(command Regen) (setq vpcenter (car vpinfo)) (setq vpscale (cadr vpinfo)) (command "_.zoom" "C" susp-cent (strcat (rtos 0.1 2 6) "XP")) ;(vlax-put-property obj 'DisplayLocked :vlax-true) (vla-put-displaylocked obj -1) ;(vla-put-lock obj :vlax-true) ;(command "_.pspace") ;(list vpcenter vpscale) ) With a return zoom function like this: ;********************************************************; ; Function: zoom_return ; Arguments: ; input (list): A list containing viewport center and scale values ; Returns: None ; Description: ; This function performs a zoom operation in AutoCAD based on the given viewport center and scale values. ; It retrieves the viewport entity and VLA object, unlocks the display, performs the zoom operation, ; locks the display again, and switches back to paper space. ; Usage: (zoom_return input) (defun zoom_return (input / vpcenter vpscale ent obj) (setq vpcenter (car input)) (setq vpscale (cadr input)) (setq ent (cvport->ent)) (setq obj (vlax-ename->vla-object ent)) (command "mspace") (vlax-put-property obj 'DisplayLocked :vlax-false) (command "_.zoom" "C" vpcenter (strcat (rtos vpscale) "XP")) (vlax-put-property obj 'DisplayLocked :vlax-true) ;(command "pspace") (princ) ) And the VPINFO function that looks like this: ;********************************************************; ;; Function: vp-info ;; Returns: ;; vpinfo (list): List of viewport center and custom scale ;; Description: ;; This function retrieves the viewport center and custom scale of the active viewport. ;; It uses the cvport->ent function to retrieve the viewport entity and VLA object. ;; The function then gets the viewport center using the "viewctr" system variable, ;; and gets the custom scale using the vla-get-customscale method of the viewport object. ;; Finally, it returns a list containing the viewport center and custom scale. ;; Usage: (vp-info) (defun vp-info (/ ent obj vpinfo) (if (setq ent (cvport->ent)) (progn (setq obj (vlax-ename->vla-object ent)) ; (setq vpcenter (getvar "viewctr")) ; (setq vpscale (vla-get-customscale obj)) (setq vpinfo (list (getvar "viewctr") (vla-get-customscale obj) ) ) vpinfo ) ) ) The command line (command "_.zoom" "C" susp-cent (strcat (rtos 0.1 2 6) "XP")), with the value 0.1 to be modified as intended for each type of block that you want to zoom into. Works really well in tandem with a search function into a drawing and zooming into them to see the details.
    1 point
  7. @Steven P just a tip, this: (strcat "") ; versine under 7 Can be simply: "" ; versine under 7
    1 point
  8. Malformed list on input usually mean a list isn't quite in the right format error: syntax error is a function isn't quite right Often for both it is a bracket in the wrong place for me try this, a small change in the 'if' statement and added in the arclen function (defun c:versine ( / ang arc enx ins rad ) ;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-me-find-arc-length (defun arclen ( ent / enx ) (setq enx (entget ent)) (* (cdr (assoc 40 enx)) (rem (+ pi pi (- (cdr (assoc 51 enx)) (cdr (assoc 50 enx)))) (+ pi pi) ) ; end * ) ; end setq ) ; end defun (while (progn (setvar 'errno 0) (setq arc (car (entsel "\nSelect arc: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null arc) nil) ( (/= "ARC" (cdr (assoc 0 (setq enx (entget arc))))) (princ "\nSelected object is not an arc.") ) ) ; end conds ) ; end progn ) ; end while (if (and (= 'ename (type arc)) (setq ins (getpoint "\nSpecify point for text: "))) (progn (setq ArcLength (arclen arc)) (setq rad (cdr (assoc 40 enx)) ang (rem (+ pi pi (- (cdr (assoc 51 enx)) (cdr (assoc 50 enx)))) (+ pi pi)) ) ; end setq (entmake (list '(000 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 010 (trans ins 1 0)) (cons 001 (strcat "Length: " (rtos (* ang rad)) "\\P" "Radius: " (rtos rad) "\\P" "Versine: " (rtos (* rad (- 1 (cos (/ ang 2.0))))) "\\P" (if (> ArcLength 7) (strcat "Versine over 7M: " (rtos (* rad (- 1 (cos (/ 7000 rad 2.0)))))) ; versine over 7 (strcat "") ; versine under 7 ) ; end if ) ; end strcat ) ; end cons 001 (create text) ) ; end list ) ; end entmake ) ; end progn ) ; end if (princ) )
    1 point
  9. what I thought @aridzv was asking for is to run this code against only a per defined selection set. not pick all entities. is that what the (while (< 0 (getvar 'cmdactive)) is doing? (defun C:PipesToPline1 (/ *error* cmd pea lay layers ss sel ss2) (defun *error* (m) (if cmd (setvar 'cmdecho cmd)) (if pea (setvar 'peditaccept pea)) (if m (prompt m)) (princ) ) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 1) (setq pea (getvar 'peditaccept)) (setvar 'peditaccept 1) ;simplifed the list and added 0.1 to the command. (setq layers '("P_Laterl" "P_DN16-4" "P_DN16-6" "P_DN20-4" "P_DN25-4" "P_DN25-6" "P_DN32-4" "P_DN32-6" "P_DN32-8" "P_DN40-4" "P_DN40-6" "P_DN40-8" "P_DN50-6" "P_DN50-8" "P_DN50-10" "P_DN63-6" "P_DN63-8" "P_DN63-10" "P_DN75-6" "P_DN75-8" "P_DN75-10" "P_DN75-12.5" "P_DN90-6" "P_DN90-8" "P_DN90-10" "P_DN110-6" "P_DN110-8" "P_DN110-10" "P_DN110-12.5" "P_DN125-6" "P_DN140-6" "P_DN140-8" "P_DN140-10" "P_DN160-6" "P_DN160-8" "P_DN160-10" "P_DN160-12.5" "P_DN200-6" "P_DN225-6" "P_DN225-8" "P_DN225-10" "P_DN225-12.5" "P_DN250-6" "P_DN250-12.5" "P_DN280-6" "P_DN280-8" "P_DN280-10" "P_DN280-12.5" "P_DN315-6" "P_DN315-8" "P_DN315-10" "P_DN315-12.5" "P_DN355-6" "P_DN450-6") ) (setq ss (ssget '((0 . "*LINE")))) ;main selection you will be testing against. add other entites types (foreach lay layers (if (tblsearch "LAYER" lay) (progn (setq ss2 (ssadd)) (if (setq sel (ssget "_X" (list (cons 410 (getvar 'CTAB)) (cons 8 lay)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex sel))) (if (ssmemb ent ss) ;check to see if any of the ssget "_X" selection is inside the main selection ss (progn (ssadd ent ss2) ;if it is add to selection set ss2 (ssdel ent ss) ;remove it from the main seleciton ss ) ) ) ) (if (> (sslength ss2) 1) (progn (command "_.pedit" "_m" ss2 "" "_j" 0.1) (while (< 0 (getvar 'cmdactive)) (command "") );End while (setq ss2 nil) ) ) ) ;End progn ) ;End if ) ;End foreach (*error* nil) (princ) )
    1 point
×
×
  • Create New...