exceed Posted January 24, 2022 Posted January 24, 2022 (edited) ; Logic Diagram Simulator - 2022.01.24 exceed ; caution - if this lisp loaded. block "and, or, nor, nand, not, lamp, switch" will be added ; please try this in empty drawing. ; command "and" - make and gate ; command "or" - make or gate ; command "not" - make not gate ; command "nand" - make nand gate ; command "nor" - make nor gate ; command "switch" - make switch (input) ; command "lamp" - make lamp (output) ; connecting these blocks with Polyline (LWPOLYLINE) ; then simulate with command "sw" (vl-load-com) (if (= (tblsearch "block" "and") nil) (progn (entmake '((0 . "BLOCK")(2 . "and")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 2.0 0.0)(11 -5.0 2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 -2.0 0.0)(11 -5.0 -2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 10.0 0.0 0.0)(11 5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "AND")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (if (= (tblsearch "block" "or") nil) (progn (entmake '((0 . "BLOCK")(2 . "or")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 2.0 0.0)(11 -5.0 2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 -2.0 0.0)(11 -5.0 -2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 10.0 0.0 0.0)(11 5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "OR")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (if (= (tblsearch "block" "nand") nil) (progn (entmake '((0 . "BLOCK")(2 . "nand")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 2.0 0.0)(11 -5.0 2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 -2.0 0.0)(11 -5.0 -2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 10.0 0.0 0.0)(11 5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "NAND")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (if (= (tblsearch "block" "nor") nil) (progn (entmake '((0 . "BLOCK")(2 . "nor")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 2.0 0.0)(11 -5.0 2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 -2.0 0.0)(11 -5.0 -2.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 10.0 0.0 0.0)(11 5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "NOR")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (if (= (tblsearch "block" "not") nil) (progn (entmake '((0 . "BLOCK")(2 . "not")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -10.0 0.0 0.0)(11 -5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 10.0 0.0 0.0)(11 5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "NOT")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (if (= (tblsearch "block" "switch") nil) (progn (entmake '((0 . "BLOCK")(2 . "switch")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "LINE")(10 10.0 0.0 0.0)(11 5.0 0.0 0.0)(8 . "0")(62 . 0))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "SWITCH")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (if (= (tblsearch "block" "lamp") nil) (progn (entmake '((0 . "BLOCK")(2 . "lamp")(70 . 64)(10 0.0 0.0 0.0)(8 . "0")(62 . 255))) (entmake '((0 . "LINE")(10 5.0 5.0 0.0)(11 5.0 -5.0 0.0)(62 . 0)(8 . "0"))) (entmake '((0 . "LINE")(10 5.0 -5.0 0.0)(11 -5.0 -5.0 0.0)(62 . 0)(8 . "0"))) (entmake '((0 . "LINE")(10 -5.0 -5.0 0.0)(11 -5.0 5.0 0.0)(62 . 0)(8 . "0"))) (entmake '((0 . "LINE")(10 -5.0 5.0 0.0)(11 5.0 5.0 0.0)(62 . 0)(8 . "0"))) (entmake '((0 . "LINE")(10 -10.0 0.0 0.0)(11 -5.0 0.0 0.0)(62 . 0)(8 . "0"))) (entmake '((0 . "TEXT")(10 0.0 0.0 0.0)(40 . 1.0)(1 . "LAMP")(72 . 1)(73 . 2)(62 . 0))) (entmake '((0 . "ENDBLK"))) ) ) (defun c:sw () (setvar 'cmdecho 0) (LM:startundo (LM:acdoc)) ;error control (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\n Error: " msg)) ) (setvar 'cmdecho 1) (redraw) (princ) ) (if (and (setq startrange (getpoint "\n Select range to simulate - start point")) (setq endrange (getcorner startrange "\n Select range to simulate - end point")) ) (progn (setq p2 (list (car endrange) (cadr startrange)) p4 (list (car startrange) (cadr endrange)) ) (grvecs (list -1 startrange p2 p2 endrange endrange p4 p4 startrange)) ;(getstring "\nPress any Key...") ) ) (redraw) (princ) (if (setq ss0 (ssget "C" startrange endrange '((0 . "LWPOLYLINE")) )) (progn (setq ss0l (sslength ss0)) (setq ss0index 0) (repeat ss0l (setq ss0obj (vlax-ename->vla-object (ssname ss0 ss0index))) (vlax-put-property ss0obj 'Color 255) (setq ss0index (+ ss0index 1)) ) ) ) (princ "\n Select which switch to turn ON and OFF ") (if (setq ss (ssget '((0 . "INSERT") (2 . "switch")) )) (progn (setq ssl 0) (setq ssl (sslength ss)) (setq ssindex 0) (repeat ssl (setq ssent (entget (ssname ss ssindex))) (setq sscolor (cdr (assoc 62 ssent))) (setq ssobj (vlax-ename->vla-object (ssname ss ssindex))) (cond ((= sscolor 255) (setq newcolor 1)) ((setq newcolor 255)) ) (setq check (vlax-property-available-p ssobj "Color" T)) (if check (vlax-put-property ssobj 'Color newcolor) );end if (setq ssindex (+ ssindex 1)) );end repeat );end progn );end if (princ) (ex:logicloop) ) (defun ex:logicloop () (ex:logic) (setq loop (+ ss1l ss2l ss3l ss4l ss5l ss6l ss7l)) (repeat loop (ex:logic) ) (LM:endundo (LM:acdoc)) (setvar "cmdecho" 1) (princ) ) (defun ex:logic () (setq ss1 nil) (setq ss2 nil) (setq ss3 nil) (setq ss4 nil) (setq ss5 nil) (setq ss6 nil) (setq ss7 nil) (setq fuzzy 1) (setq ss1l 0) (setq ss2l 0) (if (setq ss1 (ssget "C" startrange endrange '((0 . "lwpolyline")))) (progn (setq ss1l 0) (setq ss1l (sslength ss1)) (setq ss1index 0) (repeat ss1l (setq ss1ent (entget (ssname ss1 ss1index))) (setq startpoint (cdr (assoc 10 ss1ent))) (setq stx (car startpoint)) (setq sty (cadr startpoint)) (setq startpoint (list (+ stx fuzzy) (+ sty fuzzy))) (setq endpoint (list (- stx fuzzy) (- sty fuzzy))) (setq ss1obj (vlax-ename->vla-object (ssname ss1 ss1index))) (setq check (vlax-property-available-p ss1obj "Color" T)) (if check (vlax-put-property ss1obj 'Color 255) );end if ;(princ startpoint) (if (setq ss2 (ssget "C" startpoint endpoint '((0 . "INSERT,LWPOLYLINE")))) (progn (setq ss2l 0) (setq ss2l (sslength ss2)) (setq ss2index 0) (repeat ss2l (setq ss2ent (entget (ssname ss2 ss2index))) (setq ss2color (cdr (assoc 62 ss2ent))) (setq ss2index (+ ss2index 1)) );end repeat ss2 (setq check (vlax-property-available-p ss1obj "Color" T)) (if check (vlax-put-property ss1obj 'Color ss2color) );end if );end progn (progn (setq ss2color 255) (setq check (vlax-property-available-p ss1obj "Color" T)) (if check (vlax-put-property ss1obj 'Color ss2color) );end if );end progn );end if (setq ss1index (+ ss1index 1)) );end repeat ss1 );end progn );end if ss1 (setq ss3l 0) (if (setq ss3 (ssget "C" startrange endrange '((0 . "INSERT") (2 . "and")))) (progn (setq ss3l 0) (setq ss3l (sslength ss3)) (setq ss3index 0) ;(princ "\n and gate count - ") ;(princ ss3l) (repeat ss3l (setq ss3obj (vlax-ename->vla-object (ssname ss3 ss3index))) (setq check3 (vlax-property-available-p ss3obj "Color" T)) (if check3 (vlax-put-property ss3obj 'Color 255) );end if (setq ss3ent (entget (ssname ss3 ss3index))) ;(princ ss3ent) (setq ss3bp (cdr (assoc 10 ss3ent))) ;(princ "\n ss3bp - ") ;(princ ss3bp) (setq ss3input1pt (list (- (car ss3bp) 10) (+ (cadr ss3bp) 2))) (setq ss3in1x (car ss3input1pt)) (setq ss3in1y (cadr ss3input1pt)) (setq ss3in1startpoint (list (+ ss3in1x fuzzy) (+ ss3in1y fuzzy))) (setq ss3in1endpoint (list (- ss3in1x fuzzy) (- ss3in1y fuzzy))) (if (setq ss3in1 (ssget "C" ss3in1startpoint ss3in1endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss3in1l 0) (setq ss3in1l (sslength ss3in1)) (setq ss3in1index 0) (repeat ss3in1l (setq ss3in1ent (entget (ssname ss3in1 ss3in1index))) (setq ss3in1color (cdr (assoc 62 ss3in1ent))) (setq ss3in1index (+ ss3in1index 1)) );end repeat ss3in1 ) (progn (setq ss3in1color 255)) ) (setq ss3input2pt (list (- (car ss3bp) 10) (- (cadr ss3bp) 2))) (setq ss3in2x (car ss3input2pt)) (setq ss3in2y (cadr ss3input2pt)) (setq ss3in2startpoint (list (+ ss3in2x fuzzy) (+ ss3in2y fuzzy))) (setq ss3in2endpoint (list (- ss3in2x fuzzy) (- ss3in2y fuzzy))) (if (setq ss3in2 (ssget "C" ss3in2startpoint ss3in2endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss3in2l 0) (setq ss3in2l (sslength ss3in1)) (setq ss3in2index 0) (repeat ss3in2l (setq ss3in2ent (entget (ssname ss3in2 ss3in2index))) (setq ss3in2color (cdr (assoc 62 ss3in2ent))) (setq ss3in2index (+ ss3in2index 1)) );end repeat ss3in1 ) (progn (setq ss3in2color 255)) ) ;(princ "\n ss3in1 - ") ;(princ ss3in1color) ;(princ "\n ss3in2 - ") ;(princ ss3in2color) (cond ((and (= ss3in1color 1) (= ss3in2color 1)) (setq ss3out 1)) ((setq ss3out 255)) ) (setq ss3obj (vlax-ename->vla-object (ssname ss3 ss3index))) (setq check3 (vlax-property-available-p ss3obj "Color" T)) (if check3 (vlax-put-property ss3obj 'Color ss3out) );end if (setq ss3index (+ ss3index 1)) );end repeat ss3 ) ) (setq ss4l 0) (if (setq ss4 (ssget "C" startrange endrange '((0 . "INSERT") (2 . "or")))) (progn (setq ss4l 0) (setq ss4l (sslength ss4)) (setq ss4index 0) ;(princ "\n or gate count - ") ;(princ ss4l) (repeat ss4l (setq ss4obj (vlax-ename->vla-object (ssname ss4 ss4index))) (setq check4 (vlax-property-available-p ss4obj "Color" T)) (if check4 (vlax-put-property ss4obj 'Color 255) );end if (setq ss4ent (entget (ssname ss4 ss4index))) ;(princ ss4ent) (setq ss4bp (cdr (assoc 10 ss4ent))) ;(princ "\n ss4bp - ") ;(princ ss4bp) (setq ss4input1pt (list (- (car ss4bp) 10) (+ (cadr ss4bp) 2))) (setq ss4in1x (car ss4input1pt)) (setq ss4in1y (cadr ss4input1pt)) (setq ss4in1startpoint (list (+ ss4in1x fuzzy) (+ ss4in1y fuzzy))) (setq ss4in1endpoint (list (- ss4in1x fuzzy) (- ss4in1y fuzzy))) (if (setq ss4in1 (ssget "C" ss4in1startpoint ss4in1endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss4in1l 0) (setq ss4in1l (sslength ss4in1)) (setq ss4in1index 0) (repeat ss4in1l (setq ss4in1ent (entget (ssname ss4in1 ss4in1index))) (setq ss4in1color (cdr (assoc 62 ss4in1ent))) (setq ss4in1index (+ ss4in1index 1)) );end repeat ss4in1 ) (progn (setq ss4in1color 255)) ) (setq ss4input2pt (list (- (car ss4bp) 10) (- (cadr ss4bp) 2))) (setq ss4in2x (car ss4input2pt)) (setq ss4in2y (cadr ss4input2pt)) (setq ss4in2startpoint (list (+ ss4in2x fuzzy) (+ ss4in2y fuzzy))) (setq ss4in2endpoint (list (- ss4in2x fuzzy) (- ss4in2y fuzzy))) (if (setq ss4in2 (ssget "C" ss4in2startpoint ss4in2endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss4in2l 0) (setq ss4in2l (sslength ss4in1)) (setq ss4in2index 0) (repeat ss4in2l (setq ss4in2ent (entget (ssname ss4in2 ss4in2index))) (setq ss4in2color (cdr (assoc 62 ss4in2ent))) (setq ss4in2index (+ ss4in2index 1)) );end repeat ss4in1 ) (progn (setq ss4in2color 255)) ) ;(princ "\n ss4in1 - ") ;(princ ss4in1color) ;(princ "\n ss4in2 - ") ;(princ ss4in2color) (cond ((or (= ss4in1color 1) (= ss4in2color 1)) (setq ss4out 1)) ((setq ss4out 255)) ) (setq ss4obj (vlax-ename->vla-object (ssname ss4 ss4index))) (setq check4 (vlax-property-available-p ss4obj "Color" T)) (if check4 (vlax-put-property ss4obj 'Color ss4out) );end if (setq ss4index (+ ss4index 1)) );end repeat ss4 ) ) (setq ss5l 0) (if (setq ss5 (ssget "C" startrange endrange '((0 . "INSERT") (2 . "not")))) (progn (setq ss5l 0) (setq ss5l (sslength ss5)) (setq ss5index 0) ;(princ "\n not gate count - ") ;(princ ss5l) (repeat ss5l (setq ss5obj (vlax-ename->vla-object (ssname ss5 ss5index))) (setq check5 (vlax-property-available-p ss5obj "Color" T)) (if check5 (vlax-put-property ss5obj 'Color 255) );end if (setq ss5ent (entget (ssname ss5 ss5index))) ;(princ ss5ent) (setq ss5bp (cdr (assoc 10 ss5ent))) ;(princ "\n ss5bp - ") ;(princ ss5bp) (setq ss5input1pt (list (- (car ss5bp) 10) (cadr ss5bp))) (setq ss5in1x (car ss5input1pt)) (setq ss5in1y (cadr ss5input1pt)) (setq ss5in1startpoint (list (+ ss5in1x fuzzy) (+ ss5in1y fuzzy))) (setq ss5in1endpoint (list (- ss5in1x fuzzy) (- ss5in1y fuzzy))) (if (setq ss5in1 (ssget "C" ss5in1startpoint ss5in1endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss5in1l 0) (setq ss5in1l (sslength ss5in1)) (setq ss5in1index 0) (repeat ss5in1l (setq ss5in1ent (entget (ssname ss5in1 ss5in1index))) (setq ss5in1color (cdr (assoc 62 ss5in1ent))) (setq ss5in1index (+ ss5in1index 1)) );end repeat ss5in1 ) (progn (setq ss5in1color 255)) ) (cond ((= ss5in1color 1) (setq ss5out 255)) ((setq ss5out 1)) ) (setq ss5obj (vlax-ename->vla-object (ssname ss5 ss5index))) (setq check5 (vlax-property-available-p ss5obj "Color" T)) (if check5 (vlax-put-property ss5obj 'Color ss5out) );end if (setq ss5index (+ ss5index 1)) );end repeat ss5 ) ) (setq ss6l 0) (if (setq ss6 (ssget "C" startrange endrange '((0 . "INSERT") (2 . "nand")))) (progn (setq ss6l 0) (setq ss6l (sslength ss6)) (setq ss6index 0) ;(princ "\n nand gate count - ") ;(princ ss6l) (repeat ss6l (setq ss6obj (vlax-ename->vla-object (ssname ss6 ss6index))) (setq check6 (vlax-property-available-p ss6obj "Color" T)) (if check6 (vlax-put-property ss6obj 'Color 255) );end if (setq ss6ent (entget (ssname ss6 ss6index))) ;(princ ss6ent) (setq ss6bp (cdr (assoc 10 ss6ent))) ;(princ "\n ss6bp - ") ;(princ ss6bp) (setq ss6input1pt (list (- (car ss6bp) 10) (+ (cadr ss6bp) 2))) (setq ss6in1x (car ss6input1pt)) (setq ss6in1y (cadr ss6input1pt)) (setq ss6in1startpoint (list (+ ss6in1x fuzzy) (+ ss6in1y fuzzy))) (setq ss6in1endpoint (list (- ss6in1x fuzzy) (- ss6in1y fuzzy))) (if (setq ss6in1 (ssget "C" ss6in1startpoint ss6in1endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss6in1l 0) (setq ss6in1l (sslength ss6in1)) (setq ss6in1index 0) (repeat ss6in1l (setq ss6in1ent (entget (ssname ss6in1 ss6in1index))) (setq ss6in1color (cdr (assoc 62 ss6in1ent))) (setq ss6in1index (+ ss6in1index 1)) );end repeat ss6in1 ) (progn (setq ss6in1color 255)) ) (setq ss6input2pt (list (- (car ss6bp) 10) (- (cadr ss6bp) 2))) (setq ss6in2x (car ss6input2pt)) (setq ss6in2y (cadr ss6input2pt)) (setq ss6in2startpoint (list (+ ss6in2x fuzzy) (+ ss6in2y fuzzy))) (setq ss6in2endpoint (list (- ss6in2x fuzzy) (- ss6in2y fuzzy))) (if (setq ss6in2 (ssget "C" ss6in2startpoint ss6in2endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss6in2l 0) (setq ss6in2l (sslength ss6in1)) (setq ss6in2index 0) (repeat ss6in2l (setq ss6in2ent (entget (ssname ss6in2 ss6in2index))) (setq ss6in2color (cdr (assoc 62 ss6in2ent))) (setq ss6in2index (+ ss6in2index 1)) );end repeat ss6in1 ) (progn (setq ss6in2color 255)) ) ;(princ "\n ss6in1 - ") ;(princ ss6in1color) ;(princ "\n ss6in2 - ") ;(princ ss6in2color) (cond ((and (= ss6in1color 1) (= ss6in2color 1)) (setq ss6out 255)) ((setq ss6out 1)) ) (setq ss6obj (vlax-ename->vla-object (ssname ss6 ss6index))) (setq check6 (vlax-property-available-p ss6obj "Color" T)) (if check6 (vlax-put-property ss6obj 'Color ss6out) );end if (setq ss6index (+ ss6index 1)) );end repeat ss6 ) ) (setq ss7l 0) (if (setq ss7 (ssget "C" startrange endrange '((0 . "INSERT") (2 . "nor")))) (progn (setq ss7l 0) (setq ss7l (sslength ss7)) (setq ss7index 0) ;(princ "\n nor gate count - ") ;(princ ss7l) (repeat ss7l (setq ss7obj (vlax-ename->vla-object (ssname ss7 ss7index))) (setq check7 (vlax-property-available-p ss7obj "Color" T)) (if check7 (vlax-put-property ss7obj 'Color 255) );end if (setq ss7ent (entget (ssname ss7 ss7index))) ;(princ ss7ent) (setq ss7bp (cdr (assoc 10 ss7ent))) ;(princ "\n ss7bp - ") ;(princ ss7bp) (setq ss7input1pt (list (- (car ss7bp) 10) (+ (cadr ss7bp) 2))) (setq ss7in1x (car ss7input1pt)) (setq ss7in1y (cadr ss7input1pt)) (setq ss7in1startpoint (list (+ ss7in1x fuzzy) (+ ss7in1y fuzzy))) (setq ss7in1endpoint (list (- ss7in1x fuzzy) (- ss7in1y fuzzy))) (if (setq ss7in1 (ssget "C" ss7in1startpoint ss7in1endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss7in1l 0) (setq ss7in1l (sslength ss7in1)) (setq ss7in1index 0) (repeat ss7in1l (setq ss7in1ent (entget (ssname ss7in1 ss7in1index))) (setq ss7in1color (cdr (assoc 62 ss7in1ent))) (setq ss7in1index (+ ss7in1index 1)) );end repeat ss7in1 ) (progn (setq ss7in1color 255)) ) (setq ss7input2pt (list (- (car ss7bp) 10) (- (cadr ss7bp) 2))) (setq ss7in2x (car ss7input2pt)) (setq ss7in2y (cadr ss7input2pt)) (setq ss7in2startpoint (list (+ ss7in2x fuzzy) (+ ss7in2y fuzzy))) (setq ss7in2endpoint (list (- ss7in2x fuzzy) (- ss7in2y fuzzy))) (if (setq ss7in2 (ssget "C" ss7in2startpoint ss7in2endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss7in2l 0) (setq ss7in2l (sslength ss7in1)) (setq ss7in2index 0) (repeat ss7in2l (setq ss7in2ent (entget (ssname ss7in2 ss7in2index))) (setq ss7in2color (cdr (assoc 62 ss7in2ent))) (setq ss7in2index (+ ss7in2index 1)) );end repeat ss7in1 ) (progn (setq ss7in2color 255)) ) ;(princ "\n ss7in1 - ") ;(princ ss7in1color) ;(princ "\n ss7in2 - ") ;(princ ss7in2color) (cond ((or (= ss7in1color 1) (= ss7in2color 1)) (setq ss7out 255)) ((setq ss7out 1)) ) (setq ss7obj (vlax-ename->vla-object (ssname ss7 ss7index))) (setq check7 (vlax-property-available-p ss7obj "Color" T)) (if check7 (vlax-put-property ss7obj 'Color ss7out) );end if (setq ss7index (+ ss7index 1)) );end repeat ss7 ) ) (setq ss8l 0) (if (setq ss8 (ssget "C" startrange endrange '((0 . "INSERT") (2 . "lamp")))) (progn (setq ss8l 0) (setq ss8l (sslength ss8)) (setq ss8index 0) ;(princ "\n lamp count - ") ;(princ ss8l) (repeat ss8l (setq ss8obj (vlax-ename->vla-object (ssname ss8 ss8index))) (setq check8 (vlax-property-available-p ss8obj "Color" T)) (if check8 (vlax-put-property ss8obj 'Color 255) );end if (setq ss8ent (entget (ssname ss8 ss8index))) ;(princ ss8ent) (setq ss8bp (cdr (assoc 10 ss8ent))) ;(princ "\n ss8bp - ") ;(princ ss8bp) (setq ss8input1pt (list (- (car ss8bp) 10) (cadr ss8bp))) (setq ss8in1x (car ss8input1pt)) (setq ss8in1y (cadr ss8input1pt)) (setq ss8in1startpoint (list (+ ss8in1x fuzzy) (+ ss8in1y fuzzy))) (setq ss8in1endpoint (list (- ss8in1x fuzzy) (- ss8in1y fuzzy))) (if (setq ss8in1 (ssget "C" ss8in1startpoint ss8in1endpoint '((0 . "LWPOLYLINE")))) (progn (setq ss8in1l 0) (setq ss8in1l (sslength ss8in1)) (setq ss8in1index 0) (repeat ss8in1l (setq ss8in1ent (entget (ssname ss8in1 ss8in1index))) (setq ss8in1color (cdr (assoc 62 ss8in1ent))) (setq ss8in1index (+ ss8in1index 1)) );end repeat ss8in1 ) (progn (setq ss8in1color 255)) ) (cond ((= ss8in1color 1) (setq ss8out 1)) ((setq ss8out 255)) ) (setq ss8obj (vlax-ename->vla-object (ssname ss8 ss8index))) (setq check8 (vlax-property-available-p ss8obj "Color" T)) (if check8 (vlax-put-property ss8obj 'Color ss8out) );end if (setq ss8index (+ ss8index 1)) );end repeat ss8 ) ) (princ) ) (defun c:and () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "and" pt "1" "1" "0") ) (defun c:or () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "or" pt "1" "1" "0") ) (defun c:not () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "not" pt "1" "1" "0") ) (defun c:nand () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "nand" pt "1" "1" "0") ) (defun c:nor () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "nor" pt "1" "1" "0") ) (defun c:lamp () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "lamp" pt "1" "1" "0") ) (defun c:switch () (command "-color" "255") (setq pt (getpoint "\n select point to insertion")) (command "-insert" "switch" pt "1" "1" "0") ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc_forrf 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc_forrf) ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo_forrf doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) I know this is not suitable for use in autocad. this is just for fun switch on off command is "SW" The order of the polyline's start and end points should go from left to right. Use the block names "switch" "and" "or" "not" "nor" "nand". Find the input and output terminals as offsets from the basepoints of the gates and determine on/off by color I want to add oscillator but seems difficult. maybe it seems to be possible to make something like (command "regen") run 10 times Once the "clock" is created, there will be many more things that can be done. Edited January 25, 2022 by exceed add lord of lisp's grvec undo code Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.