- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys,
I need LISP for Selection of alternate lines from the selection set of lines(horizontal, vertical & Angular) like 1st, 3rd, 5th, .....etc lines in Autocad.
I am attaching the file with my requirement in the following cases,
Case 1: Angular lines
Case 2: vertical lines(angle 90 or 270 degree angle lines)
Case 3: Horizontal lines(angle 0 & 180 degree angle lines)
For Case 2 & Case 3 i got the solution of lisp from the following link
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-a-set-object-in-alter...
with the following code by komondormrex(Thanks you sir)
;***************************************************************************************************************************************************** (defun c:even_odd_alternate_pattern_sset ( / lines_sset lines_sset_list command_terminated odd_order line_angle testing_coordinate alternate_sset alternate_index ename ) (if (setq lines_sset (cadr (ssgetfirst))) (sssetfirst) (setq lines_sset (ssget '((0 . "line")))) ) (setq lines_sset_list (vl-remove-if 'listp (mapcar 'cadr (ssnamex lines_sset)))) (cond ( (or (equal (* 1.5 pi) (setq line_angle (vla-get-angle (vlax-ename->vla-object (car lines_sset_list)))) 1e-2) (equal (* 0.5 pi) line_angle 1e-2) ) (setq testing_coordinate 'car) ; vertical ) ( (or (equal (* 0.0 pi) line_angle 1e-2) (equal (* 1.0 pi) line_angle 1e-2) ) (setq testing_coordinate 'cadr) ; horizontal ) ( t (setq testing_coordinate 'skip) ) ) (if (not (= testing_coordinate 'skip)) (setq lines_sset_list (vl-sort (mapcar '(lambda (line) (cons line (apply testing_coordinate (list (vlax-get (vlax-ename->vla-object line) 'startpoint))))) lines_sset_list ) '(lambda (line_1 line_2) (< (cdr line_1) (cdr line_2))) ) ) ) (sssetfirst nil lines_sset) (prompt "\rPress <Space> to see alternate pattern, <Esc,Enter> to confirm") (while (not command_terminated) (setq error_occurred (if (vl-catch-all-error-p (setq grread_data (vl-catch-all-apply 'grread (list t 12 0)))) t nil)) (cond ( error_occurred ; Esc (setq command_terminated t) ) ( (equal grread_data '(2 32)) ; Space (prompt "\rPress <Space> to see alternate pattern, <Esc,Enter> to confirm") (sssetfirst) (setq alternate_sset (ssadd) alternate_index 0 ) (if odd_order (setq alternate_index 1) (setq alternate_index 0) ) (setq odd_order (not odd_order)) (while (setq ename (car (nth alternate_index lines_sset_list))) (ssadd ename alternate_sset) (setq alternate_index (+ 2 alternate_index)) ) (sssetfirst nil alternate_sset) ) ( (equal grread_data '(2 13)) ; Enter (setq command_terminated t) ) ) ) (princ) )
Please help me out with an possible lisp solution for case 1.
Also,
Is there a Autocad Plugin to do this?
If so Please share it.
Thanks in advance,
Pankaj
Solved! Go to Solution.