Lippens Infra Posted April 29, 2020 Posted April 29, 2020 hello, I'm frequently placing metal anchors for foundations. To do this i align those on the center lines. I've found a LISP what does what i need, creating the center lines of the rectangles. Can i add some code so i can select multiple polylines? Thanks in advance. CenterCross.lsp Quote
Tharwat Posted April 29, 2020 Posted April 29, 2020 Jive this a go and let me know. (defun c:Foo (/ int sel ent pts pt1 pt2 pt3 pt4 crs len ang dis str) ;; Tharwat - 29.Apr.2020 ;; (and (setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4))) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10) ) (entget ent) ) ) ) (mapcar 'set '(pt1 pt2 pt3 pt4) pts) (setq crs (inters pt1 pt3 pt2 pt4 nil)) (foreach grp (list (list pt1 pt2) (list pt2 pt3)) (setq len (distance (car grp) (cadr grp)) ang (angle (car grp) (cadr grp)) dis (/ len 10.0) ) (entmake (list '(0 . "LINE") (cons 10 (setq str (polar crs ang (+ (/ len 2.0) dis)))) (cons 11 (polar str (+ ang pi) (+ len (* dis 2.)))) ) ) ) ) ) (princ) ) 1 Quote
Lippens Infra Posted April 29, 2020 Author Posted April 29, 2020 54 minutes ago, ronjonp said: Why are you not using a block for this? because the size of the anchors is always different and the plans are delivered by the contractor. Quote
Lippens Infra Posted April 29, 2020 Author Posted April 29, 2020 1 hour ago, Tharwat said: Jive this a go and let me know. (defun c:Foo (/ int sel ent pts pt1 pt2 pt3 pt4 crs len ang dis str) ;; Tharwat - 29.Apr.2020 ;; (and (setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4))) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10) ) (entget ent) ) ) ) (mapcar 'set '(pt1 pt2 pt3 pt4) pts) (setq crs (inters pt1 pt3 pt2 pt4 nil)) (foreach grp (list (list pt1 pt2) (list pt2 pt3)) (setq len (distance (car grp) (cadr grp)) ang (angle (car grp) (cadr grp)) dis (/ len 10.0) ) (entmake (list '(0 . "LINE") (cons 10 (setq str (polar crs ang (+ (/ len 2.0) dis)))) (cons 11 (polar str (+ ang pi) (+ len (* dis 2.)))) ) ) ) ) ) (princ) ) Works as a charm!! thanks a lot!!!! Quote
Tharwat Posted April 29, 2020 Posted April 29, 2020 39 minutes ago, Lippens Infra said: Works as a charm!! thanks a lot!!!! You're welcome anytime. 1 Quote
BIGAL Posted April 29, 2020 Posted April 29, 2020 (edited) Just a thought like Ronjonp, Make a block 1 unit in size with c/l's and like Tharwat's good code find the plines and points they should all be consistent with the 1st point as they are a square just get distance pt1 - pt2 this is scale, then insert block at pt1 can erase pline if you want. same if plines have different x & y size still use block scale. Can check is rotated as well. Ps add if not block entmake it. Edited April 29, 2020 by BIGAL Quote
ronjonp Posted May 1, 2020 Posted May 1, 2020 On 4/29/2020 at 5:07 PM, BIGAL said: Just a thought like Ronjonp, Make a block 1 unit in size with c/l's and like Tharwat's good code find the plines and points they should all be consistent with the 1st point as they are a square just get distance pt1 - pt2 this is scale, then insert block at pt1 can erase pline if you want. same if plines have different x & y size still use block scale. Can check is rotated as well. Ps add if not block entmake it. Exactly .. this was my thought too. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.