Message 1 of 5

Not applicable
11-07-2018
01:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello everyone,
I have this code:
(defun c:LD (/ f curlayer curosmode ent exit a b spaces spaces1 testlst vlaobj1 vlaobj2 x y z) (while (setq vlaObj1 (vlax-ename->vla-object (setq ent (car (entsel)))) vlaObj2 (vlax-ename->vla-object (car (entsel))) curlayer (getvar 'clayer) curosmode (getvar 'osmode) spaces1 (getreal "\nEnter number of spaces: ")) (cond ((or (minusp spaces1) (< spaces1 1)) "Spaces should be greater than 1") (T (setvar 'clayer (cdr (assoc 8 (entget ent)))) (setvar 'osmode 16384) (setq spaces (test spaces1 ()) testlst (vl-sort (apply 'append (mapcar '(lambda (y) (mapcar '(lambda (x) (append (append (list (distance x y)) (list x)) (list y))) (list (vlax-curve-getStartPoint vlaObj1) (vlax-curve-getEndPoint vlaObj1)))) (list (vlax-curve-getStartPoint vlaObj2) (vlax-curve-getEndPoint vlaObj2)))) '(lambda (x y) (< (car x) (car y)))) a (cdar testlst) b (cdr (apply 'append (car (mapcar '(lambda (y) (mapcar '(lambda (x) (if (not (or (equal (cadar testlst) (cadr x) y) (equal (caddar testlst) (caddr x) y) (equal (cadar testlst) (caddr x) y) (equal (caddar testlst) (cadr x) y))) x)) testlst)) (list 1e-15)))))) (command "._undo" "_begin") (test2 a b spaces1 spaces) (command "._undo" "_end") (initget "Yes No") (setq f (cond ((getkword "\nFLip lines [Yes/No] <No>: ")) ("No"))) (cond ((wcmatch f "Yes,Y") (command "._undo" 1) (setq z (last a)) (setq a (cons (car a) (cdr b))) (setq b (cons (car b) (list z))) (test2 a b spaces1 spaces)) (T ()))))) (setvar 'clayer curlayer) (setvar 'osmode curosmode)) (defun test (x y) (cond ((< x 1) y) (T (test (fix (- x 1)) (cons (fix x) y))))) (defun test2 (a b c d) (mapcar '(lambda (x y) (command-s "._pline" x y "")) (mapcar '(lambda (x) (polar (car a) (angle (car a) (cadr a)) (* (/ (distance (car a) (cadr a)) c) x))) (if (not (zerop (rem c (fix c)))) d (cdr (reverse d)))) (mapcar '(lambda (x) (polar (car b) (angle (car b) (cadr b)) (* (/ (distance (car b) (cadr b)) c) x))) (if (not (zerop (rem c (fix c)))) d (cdr (reverse d))))))
It lets the user to pick 2 lines and enter the number of spaces and it makes lines between these two lines.
I want to make some amendments to it:
1. That this lisp will work also if you pick two lines of a rectangle,polyline or 2 xlines. it will devide them to the spaces the user enters , and will create xlines.
2. That it will create xlines instead of lines.
3. That the object snap will change to select all ( means that in Drafting setting when operating this lisp it will set it to select all).
Thanks in advance!
Eyal
Solved! Go to Solution.