0 Members and 1 Guest are viewing this topic.
;;; converts meters to US Survey Feet;;; put all of this in one file(defun conv (m / ft) (setq ft (/ (* m 39.37) 12)) )(defun c:m2f (/ m f) (prompt "\nConvert Meters to US Survey Feet") (if (setq m (getreal "\nEnter Meters: ")) (setq f (conv m)) ) (prompt (strcat (rtos m)" converted to "(rtos f))) (princ) )
;;;===================================================================;;;; Set the curent layer based on a selected object. ;;;;===================================================================;(defun entse7 (/ x) (while (not (setq x (car (entsel)))) (princ "\nYou missed, try again.")) x)(defun GetLyr () (cdr (assoc 8 (entget (entse7)))))(defun PutLyr (lyr) (setvar "clayer" lyr))(defun c:as () (PutLyr (GetLyr)))
;;; Convert Radians to Degrees (defun rtod (r) (* 180.0 (/ r pi)));;; Convert Degrees TO Radians (defun dtor (d) (/ (* d pi) 180.0)) ;Make 2D point from 3D point(defun 3dP->2dP (3dpt)(list (car 3dpt) (cadr 3dpt)))
Remember to give names to your variables and commands that give adequate description to what they are. For example:Use elist instead of e
That would be an entity list Mark.
If you had to teach a newbie one thing about autolisp programming what would it be?
point: p pt p1 p2 pt1 pt2center point: cp cptentity name: e e1 e2 en en1 ent ent1 entity list: e eL elistangle: a a1 ang ang1counter: c cnt xBox positions: LL lower left ur Upper Right lr lower right ul upper leftSelection set: ss ss1 s1Center: cent c c1Center point: cptDistance: dist dRadius: rad rad1Coordinates: coor x y xyObject: obj
Learn to use the Vlisp console, I still need to....It probably will turn you into a "SMadsen" overnight
This is way it was written when I got here:***********************(setq del_item (entget(car(entsel "\nSelect item you want to delete: "))))(setq txt1 del_item)(setq txt2 (assoc 0 txt1))(setq txt2a (cdr txt2))(setq txt3 (assoc 8 txt1))(setq txt3a (cdr txt2))(setq sel_item (ssget "X" (list (cons 0 txt2) (cons 8 txt3))))(command ".erase" sel_item "")************************This is what I did in rewriting it...much shorter and sweeter from 8 lines to 3 lines. Imagine that on a much larger scale or more complex program.************************ (setq del_item (entget(car(entsel "\nSelect item you want to delete: "))));;selects single entity and creates list (setq sel_item (ssget "X" (list (cons 0 (cdr (assoc 0 del_item))) (cons 8 (cdr (assoc 8 del_item))))));;extracts entity name and layer it's on and selects all entities that match this criteria (command ".erase" sel_item "");;deletes selected item************************