link base points block like a swarm

link base points block like a swarm

jtm2020hyo
Collaborator Collaborator
1,097 Views
4 Replies
Message 1 of 5

link base points block like a swarm

jtm2020hyo
Collaborator
Collaborator

...I mean something  like images below (lisp does not need be exactly as imagen) :

PD:  I leave a LISP routine that might be useful as a base.

 

image.pngimage.png




0 Likes
Accepted solutions (1)
1,098 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here is something to play with. Have fun.

 

(defun c:BConnenct (/ ss dst ang pts pt)
  
  (if (and (setq ss (ssget '((0 . "INSERT,CIRCLE,POINT"))))
	   (setq dst (getdist "\nMax distance: "))
	   (not (initget "Horizontal Vertical Orthogonal Diagonal Angular"))
	   (or (setq ang (getkword "\nExclude direction [Orthogonal/Horizontal/Vertical/Angular/Diagonal] <none>: "))
	       T)
	   (setq pts (mapcar '(lambda (e)
				(cdr (assoc 10 (entget e))))
			     (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
	   )
    (repeat (1- (length pts))
      (setq pt (car pts)
	    pts (cdr pts))
      (foreach px pts
	(and (<= (distance pt px) dst)
	     (cond ((not (setq ax (angle pt px))))
		   ((not ang))
		   ((= ang "Horizontal")
		    (not (equal (rem ax pi) 0. 1e-3)))
		   ((= ang "Vertical")
		    (not (equal (rem ax pi) (/ pi 2) 1e-3)))
		   ((= ang "Orthogonal")
		    (not (equal (rem ax (/ pi 2)) 0. 1e-3)))
		   ((= ang "Angular")
		    (equal (rem ax (/ pi 2)) 0. 1e-3))
		   ((= ang "Diagonal")
		    (not (equal (rem ax (/ pi 2) (/ pi 4)) 0. 1e-3))))
	     (entmake (list (cons 0 "LINE")
			    (cons 10 pt)
			    (cons 11 px)))))))
  (princ)
  )

Note. If the red ones are missing on purpose, you're unable to exclude them.

image.png

 

Edit: code updated.

Message 3 of 5

jtm2020hyo
Collaborator
Collaborator

great advance.

I do not if I'm doing it right but the angular option does not work for me. 

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

I'm afraid you must be misunderstood something. The routine works exactly as designed.

Anyway, if you need to do some adjustments, feel free to do that by yourself. The routine should offer you a lot to learn from. Have fun!

Message 5 of 5

jtm2020hyo
Collaborator
Collaborator

thanks for your help.

0 Likes