Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/07/2022 in all areas

  1. Jonathon "entmake is the fastest" I am not going to test but the guys at Bricscad said Vl-add is fastest to make objects. Matielo I would go down using (command while you learn much easier to understand what your doing. Or start using Visual Lisp as its more descriptive what its doing. (command "pline" pt1 pt2 pt3 pt4 "C") draws say a rectang. Contrary to mhupp's suggestion I have not had problems with setting osnap to 0 (setvar 'osmode 0) you can also set to "all off" 16384. Inserting 1000 blocks on a zoomed out dwg plus text, plus, plus works fine. Only time you can have a problem is if Autocad can not see objects on screen when doing some selection's a buggy problem since forever. You can drag and drop lisp. If your good at Excel macro's then write in VBA you just have to get the VBA extension for your version. Yeah I know VBA will be discontinued like 8 years ago now ? Here is some examples of entmake functions entmake functions.lsp
    3 points
  2. For a polyline, it will only select those that are closed. (More technically, selects the polyline whose "Closed" property is set to "Yes").
    2 points
  3. MHUPP beat me to it, in LISP a command has to be between brackets ( ) - your loop failed because getstring didn't have brackets, and so was expecting to insert the contents of a variable getstring... which doesn't exist. I also changed this line to offset the text (a copy of the last line really - which you should be able to spot what to do to correct that too). The next little thing that LISPs confused me is the IF statement, if you have more than 1 statement to work on for that condition you need to put that inside '(progn .... ) lke below - should be obvious where to put this in (repeat MySeg (command "_.rectang" MyPt (mapcar '+ (list MyW MyH 0) MyPt)) (if (= (rem acount 2) 0) ;; if, then the condition in between bracket. rem: remainder, 2 divided acount by 2 (progn ;;I am doing 2 things with an even number (if (= color 0) (command "_.clayer" "Hatch1") (command "_.clayer" "Hatch2")) ;statement 1 (command "-hatch" "S" (entlast) "" "") ; statement 2 ) ; end progn () ; left this in here, the 'else' though it isn't needed. If else has several statments it needs progn like above ) ; end if (command "_.text" "J" "L" (mapcar '+ MyPt (list (+ MyW 2) 0 0)) "" "" (getstring) ) and so back to the discussion about speed, entmake, and commands
    1 point
  4. I use mainly AutoCAD, and if my memory serves right, I recall @ronjonp mentioning it to me in another post where he outlined the time difference between using vla-add and entmake. I can't remember exactly where though.
    1 point
  5. @islasi more info closer to the bottom of the page under "Logical Operators" http://www.lee-mac.com/ssget.html Here is a better example. This will select any polyline on Mylayer that is either color red or white. (ssget '((0 . "*POLYLINE") (8 . "MyLayer") (-4 . "<OR") (62 . 1) (62 . 7) (-4 . "OR>"))) So its like two ssget's in one (ssget '((0 . "*POLYLINE") (8 . "MyLayer") (62 . 1))) (ssget '((0 . "*POLYLINE") (8 . "MyLayer") (62 . 7))) This isn't needed for dotted pairs with strings as you can search multiple criteria with a " , " (ssget '((0 . "*POLYLINE,CIRCLE") (8 . "MyLayer1,MyLayer2,MyLayer3") (62 . 7))) Select any polyline or circle that are on MyLayer1 - 3 that is color white
    1 point
  6. (defun c:mslice ( / *error* cmd s p d n i el pp ) (defun *error* ( m ) (if (= 8 (logand 8 (getvar (quote undoctl)))) (if command-s (command-s "_.UNDO" "_E") (vl-cmdf "_.UNDO" "_E") ) ) (if cmd (setvar (quote cmdecho) cmd) ) (if m (prompt m) ) (princ) ) (setq cmd (getvar (quote cmdecho))) (setvar (quote cmdecho) 0) (if (= 8 (logand 8 (getvar (quote undoctl)))) (if command-s (command-s "_.UNDO" "_E") (vl-cmdf "_.UNDO" "_E") ) ) (if command-s (command-s "_.UNDO" "_M") (vl-cmdf "_.UNDO" "_M") ) (prompt "\nSelect 3DSOLID(s) to multiple slice by XY parallel planes...") (if (setq s (ssget "_:L" '((0 . "3DSOLID")))) (progn (initget 1) (setq p (getpoint "\nPick or specify reference point on plane parallel with XY axises of current UCS : ")) (initget 7) (setq d (getdist "\nPick or specify distance between slicing planes : ")) (initget 7) (setq n (getint "\nSpecify number of slicing actions : ")) (setq i -1 el (entlast)) (while (and el (< (setq i (1+ i)) n)) (setq pp (mapcar (function +) p (list 0.0 0.0 (* i d)))) (if command-s (command-s "_.SLICE" s "" "_XY" "_non" pp "_B") (vl-cmdf "_.SLICE" s "" "_XY" "_non" pp "_B") ) (if (and (/= i 0) (eq el (setq el (entlast)))) (setq el nil) ) ) (prompt "\nFor UNDO - type \"UNDO\" - \"Back\" option...") ) (prompt "\nNothing selected...") ) (*error* nil) ) (defun c:mslicexy+rot-alongz-WCS3dsol-dist ( / *error* cmd sol ll ur d h n k r bp e gr loop ) (vl-load-com) (defun *error* ( m ) (if (= 8 (logand 8 (getvar (quote undoctl)))) (if command-s (command-s "_.UNDO" "_E") (vl-cmdf "_.UNDO" "_E") ) ) (if cmd (setvar (quote cmdecho) cmd) ) (if m (prompt m) ) (princ) ) (setq cmd (getvar (quote cmdecho))) (setvar (quote cmdecho) 0) (if (= 8 (logand 8 (getvar (quote undoctl)))) (if command-s (command-s "_.UNDO" "_E") (vl-cmdf "_.UNDO" "_E") ) ) (if command-s (command-s "_.UNDO" "_M") (vl-cmdf "_.UNDO" "_M") ) (while (or (not (setq sol (car (entsel "\nPick 3DSOLID placed in WCS...")))) (if sol (or (/= (cdr (assoc 0 (entget sol))) "3DSOLID") (vla-getboundingbox (vlax-ename->vla-object sol) (quote ll) (quote ur)) (not (equal 0.0 (caddr (safearray-value ll)) 1e-6)) ) ) ) (setq ll nil ur nil) (prompt "\nMissed or picked wrong entity type, or picked 3DSOLID not lie in WCS...") ) (setq h (caddr (safearray-value ur))) (setq d 1e+308) (while (or (> d h) loop) (prompt "\nHeight and max. distance is : ") (princ (rtos h 2 50)) (initget 7) (setq d (getdist "\nPick or specify distance between slice XY planes along Z axis : ")) (setq n (fix (/ h d))) (prompt "\nThere will be : ") (princ n) (prompt " sliced 3DSOLIDS.") (prompt "\nENTER - CONTINUE; SPACE - CHOOSE") (while (and (setq gr (grread nil)) (not (and (= (car gr) 2) (= (cadr gr) 13) ) ) (not (and (= (car gr) 2) (= (cadr gr) 32) ) ) ) ) (if (= (cadr gr) 32) (setq loop t) (setq loop nil) ) ) (initget 1) (setq r (getreal "\nSpecify unit angle in decimal degrees - can be positive CCW or negative CW or even 0.0 : ")) (initget 1) (setq bp (getpoint "\nPick or specify base point for incremental rotations : ")) (setq k 0) (repeat n (if command-s (command-s "_.SLICE" sol "" "_XY" "_non" (list 0.0 0.0 (* (setq k (1+ k)) d)) "_B") (vl-cmdf "_.SLICE" sol "" "_XY" "_non" (list 0.0 0.0 (* (setq k (1+ k)) d)) "_B") ) (vla-getboundingbox (vlax-ename->vla-object (entlast)) (quote ll) (quote ur)) (if (equal (caddr (safearray-value ur)) (* k d) 1e-6) (setq e sol) (setq e (setq sol (entlast))) ) (if command-s (command-s "_.ROTATE" e "" "_non" bp r) (vl-cmdf "_.ROTATE" e "" "_non" bp r) ) ) (prompt "\nFor UNDO - type \"UNDO\" - \"Back\" option...") (*error* nil) ) Regards, M.R. HTH.
    1 point
  7. An unzip example. (setq filename (getfiled "Select the File \"CAD-TOOLS-SEP-2022\"" "" "ZIP" 16)) ; unzip (startapp (strcat "powershell -command Expand-Archive -Path '" filename "' -DestinationPath 'C:/CAD-TOOLS' -FORCE")) (alert "programs unzipped to C:/CAD-TOOLS")
    1 point
  8. Yes, you certainly can. I would find the more professional way of doing this using Script Files. You can read about them here. However, what I think is better is to use macros, with the flexibility of prompting for user input.
    1 point
×
×
  • Create New...