vsnap lisp

(DEFUN C:VSNAP (/)

; Sept. 25,97. By V.Mendez
; This function centers an object between two parallel lines.

(SETVAR “CMDECHO” 0)
(SETQ SelObj (ENTSEL “\nSelect Object : “))
(SETQ BPoint (GETPOINT “\nBase Point : “))
(COMMAND “OSNAP” “NONE”)
(COMMAND “OSNAP” “NEA”)
(SETQ Point1 (GETPOINT “\nFirst Point [nearest] : “))
(COMMAND “OSNAP” “PER”)
(SETQ Point2 (GETPOINT Point1 “\nSecond Point [Perpendicular] : “))
(COMMAND “OSNAP” “NONE”)
(SETQ X1 (CAR Point1)
Y1 (CADR Point1)
Z1 (CADDR Point1)
)
(SETQ X2 (CAR Point2)
Y2 (CADR Point2)
Z2 (CADDR Point2)
)
(SETQ XMid (/ (+ X2 X1) 2)
YMid (/ (+ Y2 Y1) 2)
ZMid (/ (+ Z2 Z1) 2)
)
(SETQ XObj (CAR BPoint)
YObj (CADR BPoint)
ZObj (CADDR BPoint)
)
(COND
((AND (= X1 X2) (= Y1 Y2)) (SETQ MidPoint (LIST XObj YObj ZMid)))
((AND (= X1 X2) (= Z1 Z2)) (SETQ MidPoint (LIST XObj YMid ZObj)))
((AND (= Y1 Y2) (= Z1 Z2)) (SETQ MidPoint (LIST XMid YObj ZObj)))
)
(COMMAND “MOVE” SelObj “” BPoint MidPoint)
(SETVAR “CMDECHO” 1)
)

Plocky Lisp

(Defun FC (Func N Xo dx)
(
(Setq LP ‘())
(Setq Int (/ dx N)
(Setq x (-Xo Int))
(Repeat (+ N 1)
(Setq x (+x Int))
(Setq y (FuncA x))
(Setq LPP (List x y))
(Setq LP (Cons LPP LP))
)
)
)
(Defun FuncA (V)
(* V V)
)
(Defun DrawF (ListP)
(Setq LPG ListP)
(While ((Lenght LPG) >= 2)
(Setq P1 (Car LPG))
(Setq P2 (Cadr LPG))
(Command “Line” P1 P2)
(Setq LPG (Cdr LPG))
)
)

mcrouti3 lisp

; If an error (such as CTRL-C) occurs
; while this command is active…
(defun at_err (st)
(if (and (/= st “Function cancelled”) (/= st “quit / exit abort”))
(princ (strcat “\nError: ” st))
);end if

;Restore modified modes
(setvar “regenmode” 1)
(setvar “cmdecho” 1)

(if (= (type rtfile) ‘FILE)
(close rtfile)
);end if

(setq rtfile nil)

; Restore old *error* handler
(setq *error* olderr)
(princ)
);end defun

;This function disconnect all variables inside itself.
(defun DiscVar ()
(setvar “regenmode” 0)
(setvar “cmdecho” 0)
);end defun

(defun C:BB ()
(setq bb(entget(car(entsel))))
(setq name (cdr(assoc 2 bb)))
(setq name (strcat “Block Name : ” name))
(alert name)
(princ)
);end defun

(defun c:CC()
(setq bb(entget(car(entsel))))
(setq name (cdr(assoc 8 bb)))
(setq name (strcat “Entity Layer : ” name))
(alert name)
(princ)
)

(defun C:BM (/ a a1 a2 nam ins bk1)

(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))

(command “explode” a )
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(command “move” a2 “” a2 pause)

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “” )
(setvar “regenmode” 1)
(princ)
);end defun

(DEFUN C:BE ( ) ;/ a a1 a2 nam ins bk1)
;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE BLOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))

;AQUI VA EL MODULO DE EXPLODE
(command “explode” a)
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(command “erase” a2 “”)

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)

(setvar “regenmode” 1)
(princ)
);end defun

(defun C:bda (/ a a1 a2 bm bk1 inf nam ins )
;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE BLOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))

;AQUI VA EL MODULO DE EXPLODE
(command “explode” a )
(setq bk1 (ssget “p”))

;PUNTOFINALDATA
;ERASE ENTITIES
(command “ddatte” a2 )

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “” )
(setvar “regenmode” 1)
(princ)
);end defun

(DEFUN C:ba (/ blo a a1 a2 nam ins bk1)

;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ssget))
(setq blo (entsel))
(setq inf(entget(car blo)))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))

(command “explode” blo)
(setq bk1 (ssget “p”))

(command “block” nam “y” ins bk1 a “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “”)
(setvar “regenmode” 1)
(princ)
);end defun

(DEFUN C:bs (/ a a1 a2 bk1 inf nam ins )
;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(setq p1 (getpoint))
(setq p2 (getcorner p1))
(SETQ A(ssget “c” p1 p2))
(setq b (entget(ssname a 0)))

(setq nam(cdr(assoc 2 b)))
(setq ins(cdr(assoc 10 b)))
(setq capa (cdr(assoc 8 b)))

(command “explode” a)
(setq bk1 (ssget “p”))

;stretch ENTITIES
(command “stretch” “c” p1 p2 “” p2 pause)
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “”)
(setvar “regenmode” 1)
(princ)
);end defun

(DEFUN C:bop (/ a a1 a2 nam ins bk1)
;VARS SETTINGS
(setvar “regenmode” 0)

(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE LOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))

;AQUI VA EL MODULO DE EXPLODE
(command “explode” a)
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(command “copy” a2 “” a2 pause)

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “”)
(setvar “regenmode” 1)
(princ)
);end defun

(DEFUN C:bco (/ a a1 a2 nam ins bk1)
;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE LOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))

;AQUI VA EL MODULO DE EXPLODE
(command “explode” a)
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(command “change” a2 “” “p” “lt” “continuous” “”)

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “”)
(setvar “regenmode” 1)
(princ)
);end defun

(DEFUN C:bhi (/ a a1 a2 nam ins bk1)

(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE LOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))

;AQUI VA EL MODULO DE EXPLODE
(command “explode” a )
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(command “change” a2 “” “p” “lt” “hidden” “”)

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “”)
(setvar “regenmode” 1)
(princ)
);end defun
(DEFUN C:bcl (/ a a1 a2 nam ins bk1)

;; VARS SETTINGSq
(setvar “regenmode” 0)
(setvar “cmdecho” 0)
;; Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))
;; FUTURE LOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))
;; AQUI VA EL MODULO DE EXPLODE
(command “explode” a )
(setq bk1 (ssget “p”))
;; ERASE ENTITIES
(command “change” a2 “” “p” “c” 8 “”)
;; MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “” )

(setvar “regenmode” 1)
(princ)
);End_Defun

(DEFUN C:b8 (/ a a1 a2 nam ins bk1)

;; VARS SETTINGSq
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;; Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;; FUTURE LOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa(cdr(assoc 8 inf)))
;; AQUI VA EL MODULO DE EXPLODE
(command “explode” a )
(setq bk1 (ssget “p”))
;; ERASE ENTITIES
(command “change” a2 “” “p” “c” 8 “”)
;; MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa “” )

(setvar “regenmode” 1)
(princ)
);End_Defun

(DEFUN C:TKI (/ ) ;a a1 a2 nam ins bk1)
;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;ENTITIES SELECTION
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE BLOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa2(cdr(assoc 8 inf)))

;EXPLODE MODULE
(command “explode” a )
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(setq nooo 0)
(repeat (sslength bk1)
(setq capa(ssname bk1 nooo))
(setq asso(cdr(assoc 8(entget capa))))
(SETQ BLO(CDR(ASSOC 2(ENTGET CAPA))))
(setq loc(cdr(assoc 10(entget capa))))
(setq ref(cdr(assoc 0(entget CAPA))) )

(IF (= “ITEMTAG” BLO)
(COMMAND “SCALE” CAPA “” LOC “1.6”)
)
(IF (= “RECTRAG” BLO)
(COMMAND “SCALE” CAPA “” LOC “1.6”)
)

(setq nooo(+ nooo 1))
);repeat

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa2 “” )
(setvar “regenmode” 1)
(princ)
);End_Defun

(DEFUN C:TEI (/ ) ;a a1 a2 nam ins bk1)
;VARS SETTINGS
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

;Seleccion de entidades
(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

;FUTURE BLOCK INFORMATION
(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa2(cdr(assoc 8 inf)))

;AQUI VA EL MODULO DE EXPLODE
(command “explode” a )
(setq bk1 (ssget “p”))

;ERASE ENTITIES
(setq nooo 0)
(repeat (sslength bk1)
(setq capa(ssname bk1 nooo))
(setq asso(cdr(assoc 8(entget capa))))
(SETQ BLO(CDR(ASSOC 2(ENTGET CAPA))))
(setq loc(cdr(assoc 10(entget capa))))
(setq ref(cdr(assoc 0(entget CAPA))) )

(IF (OR (= “PTAGM” BLO)(= “ETAGM” BLO)(= “EPTAGM” BLO)(= “ERITAG” BLO)(= “PRITAG” BLO)(= “ELLIPPLM” BLO)(= “ELLIPTAG” BLO))
(COMMAND “SCALE” CAPA “” LOC “1.6”)
)
(setq nooo(+ nooo 1))
);repeat

;MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa2 “” )
(setvar “regenmode” 1)
(princ)
);End_Defun

(DEFUN C:BO (/ bb name)
(setq bb(entget(car(entsel))))
(setq name (cdr(assoc 2 bb)))
(setq name (strcat “d:\\MCD_PR\\SOFTDESK\\” name “.DWG”))
(command “save” “”)
(command “open” name)
(princ)
)

(DEFUN C:TCI (/ ) ;a a1 a2 nam ins bk1)
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ a2 (car(cdr a)))

(setq inf (entget a1))
(setq nam(cdr(assoc 2 inf)))
(setq ins(cdr(assoc 10 inf)))
(setq capa2(cdr(assoc 8 inf)))

;; AQUI VA EL MODULO DE EXPLODE
(command “explode” a )
(setq bk1 (ssget “p”))

;; ERASE ENTITIES
(setq nooo 0)
(repeat (sslength bk1)
(setq capa(ssname bk1 nooo))
(setq asso(cdr(assoc 8(entget capa))))
(SETQ BLO(CDR(ASSOC 2(ENTGET CAPA))))
(setq loc(cdr(assoc 10(entget capa))))
(setq ref(cdr(assoc 0(entget CAPA))))

(IF (OR (= “3NOTE” BLO)(= “2NOTE” BLO)
(= “1NOTE” BLO)(= “4NOTE” BLO))

(COMMAND “SCALE” CAPA “” LOC “1.6”)
)

(setq nooo(+ nooo 1))
);repeat

;; MAKE BLOCK MODIFIED
(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa2 “” )

(setvar “regenmode” 1)
(princ)
);End_Defun

(DEFUN C:TCD (/ ) ;a a1 a2 nam ins bk1)
(setvar “regenmode” 0)
(setvar “cmdecho” 0)

(SETQ A(ENTSEL))
(SETQ A1(CAR A))
(SETQ A2 (car(cdr a)))

(setq Inf (entget A1))
(setq Nam(cdr(Assoc 2 Inf)))
(setq Ins(cdr(Assoc 10 Inf)))
(setq Capa2(cdr(Assoc 8 Inf)))

(command “explode” a)
(setq Bk1 (ssget “p”))

(setq Nooo 0)
(repeat (sslength Bk1)
(setq Capa (ssname Bk1 Nooo)
Asso (cdr(assoc 8(entget Capa)))
Blo (cdr(assoc 2(entget Capa)))
Loc (cdr(assoc 10(entget Capa)))
Ref (cdr(assoc 0(entget Capa)))
);setq end

(if (OR (= “3NOTE” BLO)(= “2NOTE” BLO)(= “1NOTE” BLO)(= “4NOTE” BLO))
(COMMAND “SCALE” CAPA “” LOC (/ 1 1.6))
);end if
(setq nooo(+ nooo 1))
);repeat

(command “block” nam “y” ins bk1 “”)
(command “insert” nam ins “” “” “”)
(command “change” “l” “” “p” “la” capa2 “” )

(setvar “regenmode” 1)
(princ)
);End_Defun

(DEFUN C:bbn (/ n p1 n1 n2 a co al1 cp cp2 t)
; Copia un bloque con nombre diferente
(setq n (entsel))
(setq p1 (car(cdr n)))

(command “copy” n “” p1 pause)
(setq n1(cdr(assoc 2(entget(car n)))))
(setq n2 (strcat (substr n1 1 7) “*”))
(setq a(ssget “x”(list(cons 0 “INSERT”) (cons 2 N2))))
(setq co (sslength a))
(setq al1 (strcat “TIENES ” (ITOA CO) ” BLOQUES.”))
(setq cp (ssget “l”))
(setq cp2 (entget(ssname cp 0)))
(command “explode” cp “”)
(setq t (ssget “p”))
(command “block” (strcat(substr n1 1 8)”_”(itoa co))
(cdr(assoc 10 cp2)) t “” )
(command “insert” (strcat(substr n1 1 8)”_”(itoa co))
(cdr(assoc 10 cp2)) “” “” “”)
(ALERT AL1)
(princ)
)