Jump to content

Recommended Posts

Posted

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.

 

 

Knipsel.PNG

Knipsel2.PNG

CenterCross.lsp

Posted

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)
)

 

  • Like 1
Posted

Why are you not using a block for this?

Posted
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.

Posted
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!!!!

Posted
39 minutes ago, Lippens Infra said:

Works as a charm!! thanks a lot!!!!

You're welcome anytime. :) 

  • Like 1
Posted (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 by BIGAL
Posted
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. 🍻

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...