Jump to content

Recommended Posts

Posted

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

Posted (edited)

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
Posted (edited)
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
Posted

It mostly works on the Pipe_Network drawing.

image.png.260eedd4078aff696cdd0e1e864e3af2.png

  • Like 1
Posted
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?

Posted

What is supposed top happen in this scenario? That drawing is fairly inconsistent.

image.png.01e692da3de25806cd8d48bbd46c5a70.png

Posted
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

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

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

Posted (edited)
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
Posted
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

 

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

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