
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi everyone,
i attached here lips that lisp I using now. my problem is it does not connect all block with a line . when i use this lisp only just doing insert block after nothing happened(not connect line for all block). I don't know why can't connect the line.
i pretty sure that lisp has some mistake but i don't know how to resolve it.
i want that lisp to do all itself.i hope you to understand everything. I attached here a block and image for reference.
i appreciate your help.
(DEFUN c:t4 (/ sc clay)
(setvar "cmdecho" 0)
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(setq Pt1
(getpoint "\nPick First Point")
) ;PROMPT FOR FIRST POINT
(setq Pt2
(getpoint "\nPick Second Point")
)
;(princ "\nPt1=")
; (princ Pt1)
;(princ "\nPt2=")
; (princ Pt2)
(setq os (getvar 'osmode))
(setvar 'osmode 0)
;;; you codes here ...
(setq drows (vla-GetReal
util
"\nEnter the distance between rows (---): "
)
)
(setq dcols (vla-GetReal
util
"Specify the distance between columns (|||): "
)
)
(setq X1 (car Pt1))
(setq Y1 (car (cdr Pt1)))
(setq X2 (car Pt2))
(setq Y2 (car (cdr Pt2)))
(setq X (abs (- X1 X2)))
(setq Y (abs (- Y1 Y2)))
(setq ncols (+ 1 (/ (- X (rem X dcols)) dcols)))
(setq nrows (+ 1 (/ (- Y (rem Y drows)) drows)))
(setq modx (/ (rem X dcols) 2))
(setq mody (/ (rem Y drows) 2))
(if (> X1 X2)
(setq X1 X2))
(if (> Y1 Y2)
(setq Y1 Y2))
(setq ptx (+ modx X1))
(setq pty (+ mody Y1))
(setq pt3 (list ptx pty))
(setq county 0)
(while (< county nrows)
(setq count 0)
(setq ptx (+ modx X1))
(setq pt3 (list ptx pty))
(while (< count ncols)
(command "_insert" "light normal.dwg" pt3 "" "" "")
(setq ptx (+ ptx dcols))
(setq count (+ 1 count))
(setq pt3 (list ptx pty))
)
(setq pty (+ pty drows))
(setq county (+ 1 county))
)
(defun draw_vertical_lines ( / x y-pair p1 p2)
(foreach x xl ; xl could be for example (50 100 150)
(foreach y-pair (rlxlist yl) ; = ((10 20) (20 30) (30 40)) , 1st y-pair = (10 20), 2nd y-pair = (20 30)
; make begin & end point , for example p1 = (list 50 10) , p2 = (list 50 20)
(setq p1 (list x (car y-pair)) p2 (list x (cadr y-pair)))
(if (member p1 pl)(setq p1 (list x (- (car y-pair) dy))))
(if (member p2 pl)(setq p2 (list x (+ (cadr y-pair) dy))))
; now draw the line
(command-s ".line" p1 p2 "")
)
)
)
(defun draw_horizontal_lines ( / y x-pair p1 p2)
(foreach y yl
(foreach x-pair (rlxlist xl)
(if (member (setq p1 (list (car x-pair) y)) pl) (setq p1 (list (+ (car x-pair) dx) y)))
(if (member (setq p2 (list (cadr x-pair) y)) pl) (setq p2 (list (- (cadr x-pair) dx) y)))
(command-s ".line" p1 p2 "")
)
)
)
; make list of all x-values with fuzz factor , this means no use of member function
(defun Find-X-Values ( %ss / xl )
(mapcar
'(lambda ( e / x)
(setq x (car (getbip e))) (if (null xl) (setq xl (list x)) (if (vl-every '(lambda (n) (not (equal x n fuzz))) xl)(setq xl (cons x xl)))))
%ss
)
(vl-sort xl '<)
)
; make list of all y-values with fuzz factor
(defun Find-Y-Values ( %ss / yl )
(mapcar
'(lambda ( e / y)
(setq y (cadr (getbip e))) (if (null yl) (setq yl (list y)) (if (vl-every '(lambda (n) (not (equal y n fuzz))) yl)(setq yl (cons y yl)))))
%ss
)
(vl-sort yl '>)
)
; list all block insertion points
(defun ListAllBips (l)
(mapcar 'getbip l)
)
(defun rlxlist (l) (reverse (cdr (reverse (mapcar '(lambda (x y)(list x y)) l (append (cdr l) (list (car l))))))))
(defun rlxlist2 (l) (mapcar '(lambda (x y)(list x y)) l (append (cdr l) (list (car l)))))
; get block insertion point
(defun getbip (e) (list (cadr (assoc 10 (entget e)))(caddr (assoc 10 (entget e)))))
; convert selectionset to list
(defun SS->lst (%ss)(vl-remove-if 'listp (mapcar 'cadr (ssnamex %ss))))
(setvar 'osmode 15871)
) ;_ end of defun
Solved! Go to Solution.