TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Wianhm on October 13, 2020, 03:55:55 AM
-
Good day all,
This is my first post to this forum and I need a little help with a lisp that I'm making
The goal of this lisp is select all the roads in the drawing, then to count every single road crossing.
On small scale (0 - 50 roads) it works, but when handling larger projects I get error: bad argument type: lselsetp nil. Which tells me that it's most likely my selection set that isn't working.
Could someone please guide me on where I went wrong?
(defun c:RC_count ( / sel s1 ctr2 ss ctr )
(if (setq sel (ssget "x" '((0 . "LWPOLYLINE") (8 . "Streets"))))
(progn
(setq ctr 0)
(setq s1 (ssadd))
(repeat (sslength sel)
(setq ss
(ssget "_F"
(mapcar 'cdr
(vl-remove-if-not '(lambda ( x ) (= 10 (car x)))
(entget (ssname sel ctr))
)
)
'((0 . "LWPOLYLINE")(8 . "2F Aerial,4F Aerial,12F Aerial,18F Aerial,36F Aerial,48F Aerial,72F Aerial,96F Aerial,144F Aerial,12F,24F,36F,48F,72F,96F,144F"));checks the crossing lines
);ssget
);setq
;sssetfirst
(setq ctr2 0)
(repeat (sslength ss)
(ssadd (ssname ss ctr2) s1)
(setq ctr2 (1+ ctr2))
)
(setq ctr (1+ ctr))
);repeat
);progn
);if
(print (sslength s1))
(princ)
)
Thanks in advance and I apologize that I'm asking for help on my first post.
-
Try this (not tested):
(defun c:RC_count ( / sel s1 ctr2 ss ctr )
(if (setq sel (ssget "x" '((0 . "LWPOLYLINE") (8 . "Streets"))))
(progn
(setq ctr 0)
(setq s1 (ssadd))
(repeat (sslength sel)
(and ; <<<<<<<<<
(setq ss
(ssget "_F"
(mapcar 'cdr
(vl-remove-if-not '(lambda ( x ) (= 10 (car x)))
(entget (ssname sel ctr))
)
)
'((0 . "LWPOLYLINE")
(8 . "2F Aerial,4F Aerial,12F Aerial,18F Aerial,36F Aerial,48F Aerial,72F Aerial,96F Aerial,144F Aerial,12F,24F,36F,48F,72F,96F,144F"));checks the crossing lines
);ssget
);setq
(progn ; <<<<<
(setq ctr2 0)
(repeat (sslength ss)
(ssadd (ssname ss ctr2) s1)
(setq ctr2 (1+ ctr2))
)
(setq ctr (1+ ctr))
) ) ; <<<<<<<<<<<
);repeat
);progn
);if
(print (sslength s1))
(princ)
)
-
Also posted at Cadtutor see solution.