Modify lisp to work only at certain angles and others...

Modify lisp to work only at certain angles and others...

jtm2020hyo
Collaborator Collaborator
3,277 Views
20 Replies
Message 1 of 21

Modify lisp to work only at certain angles and others...

jtm2020hyo
Collaborator
Collaborator

I have this lisp created for @dbhunia and work great. 

This lisp creates a line between one-block -in-whole-drawing to nearest blocks:

(defun C:BBL ( / )
(vl-load-com)
(setq SB_lst nil)
(setq NB_lst nil)
(princ "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)")
(Setq SB_Name (cdr (assoc 2 (entget(car(entsel)))))) 
(Setq selectionset (ssget "_A" '((0 . "INSERT"))))
(repeat (setq N (sslength selectionset))
	(setq Data (ssname selectionset (setq N (- N 1))))
	(setq EntityData (entget Data))
	(setq B_Name (cdr (assoc 2 EntityData)))
	(setq BP_Block (cdr (assoc 10 EntityData)))
	(if (= SB_Name B_Name)
		(setq SB_lst (cons BP_Block SB_lst))
		(setq NB_lst (cons BP_Block NB_lst))
	)
)
(repeat (setq N (length SB_lst))
	(setq BP_SB (nth (setq N (- N 1)) SB_lst))
	(setq DIS_lst nil)
	(repeat (setq N1 (length NB_lst))
		(setq BP_NB (nth (setq N1 (- N1 1)) NB_lst))
	    	(setq PD (distance BP_SB BP_NB))
		(setq DIS_lst (cons PD DIS_lst))
	)
(setq LDP (vl-position (apply 'min DIS_lst) DIS_lst))
(setq NP (nth LDP NB_lst))
(command "line" BP_SB NP "")
(princ)
)
)

 

...but I need more option:
1 just to work at certain angles. I need draw a pline between selected block and their nearest block but that is above base point (90 grades). Angle might be a variable.
2 just to work at the selected block of distinct names
3 link selected blocks to one block with a certain name or a layer with a certain name.

...I think those request will help a lot of people. 

image explain how I need request 1:
image.png

0 Likes
3,278 Views
20 Replies
Replies (20)
Message 21 of 21

jtm2020hyo
Collaborator
Collaborator

@dlanorh @dbhunia

both codes work perfectly. thanks for your help.


Its possible add options or variable for angles limiting. something like: "ignore blocks between next angle range, since 'angle 1', until 'angle 2' " or something like: "just create a link with blocks between next ranges, since 'angle 1', until 'angle 2' "


0 Likes