Jump to content

Select all wanted blocks touching circles with lisp


JovanG

Recommended Posts

Hey guys. I hope you're having a great day.

 

Today I was trying to modify the attached lisp to select all blocks touching circles instead of *lines (like it works rigth now), but I didn't succeed.

 

Can you help me please. What I'm trying to do is to create a lisp that helps me with this task:

1. Select all blocks called "Flow_direction" that touch a circle

2. Switch the selection to the other blocks called "Flow_direction" (those who don't touch any circle)

 

I really appreciate your time and help, and if you can comment in the lisp where step 1 ends and start the other (for my understanding) I would be highly grateful.

 

 

SBC.lsp

Link to comment
Share on other sites

You should post a sample drawing too.

Or change:

;;This: 
(setq plset (ssget '((0 . "*line"))))
;;to this:
 (setq plset (ssget '((0 . "CIRCLE"))))

 

Edited by ronjonp
Link to comment
Share on other sites

On 3/26/2021 at 4:11 PM, ronjonp said:

You should post a sample drawing too

Of course @ronjonp here I upload my general database of pipe network, and a plane where I have to insert the correspondent "flow_direction" blocks (with paste to original coordinates). And for that´s that i want to use this program, to paste automatically all blocks from my general data base and select those who don´t touch any circle to delete them.

 

On 3/26/2021 at 4:11 PM, ronjonp said:

;;to this:  (setq plset (ssget '((0 . "CIRCLE"))))

 

It didn´t works 😢 I don´t know why.

Pipe_Network.dwg

DWG-ALC-600.dwg

Edited by JovanG
Wrong attach
Link to comment
Share on other sites

4 minutes ago, ronjonp said:

It mostly works on the Pipe_Network drawing.

Oh! I thought that the program could identify all those blocks that touch any point of the circumference, including the one in the image because is touching it in two points. Thanks @ronjonp 

 

And do you know how to switch the selection to those blocks that didn't touch it?

Link to comment
Share on other sites

1 hour ago, ronjonp said:

What is supposed top happen in this scenario?

That's weird, that is not supposed to be that way. In fact in mine is OK

Link to comment
Share on other sites

34 minutes ago, JovanG said:

That's weird, that is not supposed to be that way. In fact in mine is OK

You're right .. I must have shifted them in your drawing after a test. Either way, what would the result be if there were an inconsistency like that?

Link to comment
Share on other sites

8 minutes ago, ronjonp said:

what would the result be if there were an inconsistency like that?

Sure the lisp program would delete it and I would realize it when print them all in PDF.

 

What I haven´t achived yet is to switch the selection to the "flow_direction" blocks to delete them.

Link to comment
Share on other sites

11 minutes ago, JovanG said:

Sure the lisp program would delete it and I would realize it when print them all in PDF.

 

What I haven´t achived yet is to switch the selection to the "flow_direction" blocks to delete them.

Try this .. it gives you a little bit of flexibility on the search distance to use.

(defun c:sbp (/ d p s s2 x)
  ;; RJP » 2021-03-30
  (cond	((and (setq d (getdist "\nPick a distance to search: "))
	      (setq s (ssget "_X" '((0 . "insert") (2 . "Flow_direction"))))
	      (setq s2 (ssget "_X" '((0 . "circle"))))
	 )
	 (setq s2 (mapcar 'cadr (ssnamex s2)))
	 (foreach e (mapcar 'cadr (ssnamex s))
	   (setq p (cdr (assoc 10 (entget e))))
	   (if (vl-some '(lambda (x) (<= (distance p (vlax-curve-getclosestpointto x p)) d)) s2)
	     (ssdel e s)
	   )
	 )
	 (sssetfirst nil s)
	)
  )
  (princ)
)

 

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

35 minutes ago, ronjonp said:

Try this .. it gives you a little bit of flexibility on the search distance to use.

Excelent @ronjonp! It makes all easier for me. Now i´ll finisht the code to be able to run it in my other drawings at once and print them.

 

Thanks to you and to all the programmers that help us every day with our codes. I won't doubt in donate to such helpful site (I´ll leave the link here just in case, because it took me almost 1 hour to find it 🤦‍♂️

https://www.cadtutor.net/general/about.php

The donation button is at the end of the page.

 

I really really thank you all

 

Link to comment
Share on other sites

2 minutes ago, JovanG said:

Excelent @ronjonp! It makes all easier for me. Now i´ll finisht the code to be able to run it in my other drawings at once and print them.

 

Thanks to you and to all the programmers that help us every day with our codes. I won't doubt in donate to such helpful site (I´ll leave the link here just in case, because it took me almost 1 hour to find it 🤦‍♂️

https://www.cadtutor.net/general/about.php

The donation button is at the end of the page.

 

I really really thank you all

 

Glad to help! 🍻

Link to comment
Share on other sites

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