Message 1 of 2
Centreline for walls without selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
AutoLISP noob here. I am trying to drawing centre lines between lines in a particular layer. (Iterating and comparing one entity with all other entities in a layer) and then drawing only between lines within wall thickness.
(defun c:cenline (/ cencord i j)
(setq I 0)
(setq j 0)
(while (< i (sslength (SSGET "_X" '((0 . "LINE") (8 . "Column")))))
(progn
(setq
s1
(cdr
(assoc
10
(entget
(SSNAME
(SSGET "_X" (list (cons 0 "line") (cons 8 "Column")))
I
)
)
)
)
)
(setq e1
(cdr
(assoc 11 (entget (SSNAME (SSGET "_X" '((0 . "LINE"))) I)))
)
)
(setq i (+ 1 i))
(while
(< j (sslength (ssget "_x" '((0 . "line") (8 . "Column")))))
(progn
(setq s2
(cdr
(assoc 10
(entget (SSNAME (SSGET "_X" '((0 . "LINE"))) j))
)
)
)
(setq e2
(cdr
(assoc 11
(entget (SSNAME (SSGET "_X" '((0 . "LINE"))) j))
)
)
)
(setq j (+ 1 j))
(if
(and (= (nth 0 s1) (nth 0 s2)) (/= (nth 1 s1) (nth 1 s2)) (= (rtoi (distance s1 s2)) 9))
(PROGN
(setq
cencord (list (mapcar '/ (mapcar '+ s1 s2) '(2 2 2))
(mapcar '/ (mapcar '+ e1 e2) '(2 2 2))
)
)
(command "line" (nth 0 cencord) (nth 1 cencord) "")
)
)
(if
(and (/= (nth 0 s1) (nth 0 s2)) (= (nth 1 s1) (nth 1 s2)) (= (rtoi (distance s1 s2)) 9)))
(progn
(setq
cencord (list (mapcar '/ (mapcar '+ s1 s2) '(2 2 2))
(mapcar '/ (mapcar '+ e1 e2) '(2 2 2))
)
)
(setq osmode 0)
(command "line" (nth 0 cencord) (nth 1 cencord) "")
)
)
(princ)
)
)
)
)
)
but I am not able to get it to stop after i hits the sslength (goes into infinite loop) or pick the correct points and then cencord changing according to the iterations.
Please let me know what I am missing