Select objects inside a boundary

Select objects inside a boundary

Anonymous
Not applicable
7,749 Views
16 Replies
Message 1 of 17

Select objects inside a boundary

Anonymous
Not applicable

How to Select objects inside a boundary in AutoCAD?

0 Likes
7,750 Views
16 Replies
Replies (16)
Message 2 of 17

j.palmeL29YX
Mentor
Mentor

This is not a Dynamic Block question.

But a short answer: Not included in the basic AutoCAD. In the web you will find any tools (LISP) to solve it. If you ask in another forum again you should give more informations about the "boundary" (one object or several objects, polyline(s) or spline(s) or ellipse (arcs) or lines or mixed of all or ...).

 

cadder

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 3 of 17

Anonymous
Not applicable

Use below lisp code, or just copy paste below code to your cad in F2 window. Then type SIB command. it asks you to select the polyline boundary. Just finished.

;Polyline/circle select - www.cadstudio.cz - www.cadforum.cz
;(use the WPS command or 'WPS inside an object selection prompt)

(defun C:SIB ( / i elist at cmde cen rad p1 impl)
(setq cmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq i 0 elist (entget (car (entsel "\nPick a bounding circle or polyline: "))))
(setvar "OSMODE" (boole 7 (getvar "OSMODE") 16384))
(if (zerop (getvar "CMDACTIVE")) (progn (setq impl T)(command "_select")))
(command "_wp") ; or _CP
(if (= (cdr(assoc 0 elist)) "CIRCLE")
(progn
(setq cen (cdr (assoc 10 elist))
rad (cdr (assoc 40 elist))
)
(repeat 90 ; 360/4 0.06981317=4*pi/180
(setq p1 (polar cen (* i 0.06981317) rad) i (1+ i))
; (command "_POINT" (trans p1 0 1))
(command (trans p1 0 1))
)); else
(repeat (length elist)
(setq at (nth i elist) i (1+ i))
; (if (= (car at) 10) (command (cdr at)))
(if (= (car at) 10) (command (trans (cdr at) 0 1)))
)
);if CIRCLE
(command "")
(setvar "OSMODE" (boole 2 (getvar "OSMODE") 16384))
(setvar "cmdecho" cmde)
(if impl (progn (command "")(sssetfirst nil (ssget "_P"))))
(princ)
)

Message 4 of 17

Kent1Cooper
Consultant
Consultant

Do a little Searching.  This has come up many times in this Forum alone.  You will find a variety of approaches, as well as discussion of possible difficulties [in particular, the effect of arc segments in Polylines as boundaries].

Kent Cooper, AIA
Message 5 of 17

Lindsay-CAD
Contributor
Contributor

Can that program be modified to select just specific sized circles within the boundary. I am trying to write a program to automatically dimension these circles from the boundary.  Thanks

0 Likes
Message 6 of 17

Kent1Cooper
Consultant
Consultant

@Lindsay-CAD wrote:

Can that program be modified to select just specific sized circles within the boundary. ....


[Should you be asking this of @Anonymous rather than of me?]

Routines that use (ssget), as many of those I was referring to in suggesting a Search, can filter for entity type and for various other things, including the radius for Circles.  I don't think a routine based on a SELECT command, as in Message 3, can do that.

Kent Cooper, AIA
0 Likes
Message 7 of 17

hak_vz
Advisor
Advisor

@Lindsay-CAD  I would need some more details about your request regarding how you would like your

circles to be selected but try this

 

(defun c:selectcirclesinside ( / *error* pick_poly take pointlist2d coords eo)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ)
		)
		(princ)
	)
	(defun pick_poly ()
		(setq e (car(entsel "\nSelect boundary lwpolyline >")))
		(if (and (not e) (= (getvar 'Errno) 7)) (pick_poly) e)
	)
	(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
	(defun pointlist2d (lst / ret) (while lst (setq	ret (cons (take 2 lst) ret) lst (cddr lst))) (reverse ret))
	(setq eo (vlax-ename->vla-object (pick_poly)))
	(cond 
		((vlax-property-available-p eo 'coordinates)
			(sssetfirst 
				nil 
				(ssget
					"_CP" 
					(pointlist2d (vlax-get eo 'coordinates)) 
					(list (cons 0 "CIRCLE") (cons 40 (getreal "\nEnter circle radius > ")))
				)
			)
		)
	)
	(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 17

Lindsay-CAD
Contributor
Contributor
Thank you for your reply.
Just to clarify what I am trying to develop. Keeping in mind that I am not an expert programmer. I have written numerous simple programs and rely heavily on things I have extracted from other post and edited to fit what I set out to do. What I am trying to achieve is to automatically dimension Concrete Tilt Panels. The are typically rectangular and have numerous embedded elements in them. I have been able to achieve what I want TO do manually, now I trying to automate that manual process. In a typical project there could be over 100 panels, different sizes and number of internal elements. I will attach a CAD file as an example. The CAD file is a DXF export from a Design package called "Tiltwerks" which I clean up for our construction drawings.
My goal is to select the panel outline (bounding box) which selects the interior contents. Then Using qdim, dimension the location of these elements. The elements dictate the side of the panel the dimensions are on. In my experimenting I created lisp points that are outside of the bounding box at the midpoint of each side of the bounding box. These points locate the dimension line placement.
I hope this make some sense to you. The Cad file might give you a better picture
Thank
Rob Hillier
Senior CAD Technician
Lindsay Construction

0 Likes
Message 9 of 17

Kent1Cooper
Consultant
Consultant

@Lindsay-CAD wrote:
.... I will attach a CAD file as an example. The CAD file is a DXF export .... The Cad file might give you a better picture ....

[Nothing attached]

Kent Cooper, AIA
0 Likes
Message 10 of 17

Lindsay-CAD
Contributor
Contributor
Not sure what happened. It's showing up as an attachment in my sent email. Hope you get this one.
Thanks
RobH
0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant

If you're replying as an email response to an email notification of traffic on your Topic, with something like a cell phone, you can't attach things that way.  You need to come to the website in a "real" browser.

Kent Cooper, AIA
0 Likes
Message 12 of 17

Lindsay-CAD
Contributor
Contributor

Attached is the sample CAD file

 

0 Likes
Message 13 of 17

hak_vz
Advisor
Advisor

@Lindsay-CAD 

Instead of circles inside panel you have inserts (blocks). I understand what you want to achieve and it is not difficult to make a program for this. Lets assume that all objects that have to be dimensioned are block.

1) collect all vertexes of panels and insertion points of all different blocks and retain only unique point i.e remove duplicates

2) on left side and bottom side create create dimensions related to panel size

3) on top and right side create dimensions related to inserted blocks

Creation of block dimensions i.e. right sequence can be defined by user quarry or predefined

 

I have some program for auto dimensioning  and I know @Kent1Cooper has it too. His programs are probably better regarding US dimension units since I predominantly work with SI units

If he can attach his dimensioning script I can make modifications to my code posted above and we can have your program created soon.

 

You can also start a new post. It will be more interesting to other forum users, and it makes possible for solution creator(s) to receive solution points. In this request attach sample drawing and detailed description of what you want to achieve.

I can work on it during the weekend. Meanwhile you can write how exactly you want your dimensioning program to work as I described above. 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 14 of 17

Lindsay-CAD
Contributor
Contributor
Thank you for the response and great information and suggestions. I will start putting something together for a new post.
This has been an ongoing project for me, and the dimensioning is almost the last piece in the puzzle.
Weekends are for relaxing and enjoying time with Family and friends. This can wait.
RobH
0 Likes
Message 15 of 17

Sea-Haven
Mentor
Mentor

If there was an admin that could be contacted then your posts and answers could be moved to a new post, that's why Cadtutor is so much better. 

 

Have you talked to Tiltwerks about your requests ? Yes did google.

0 Likes
Message 16 of 17

john.uhden
Mentor
Mentor

@hak_vz ,

Of course that raises the age old question of what is meant by "inside."

"CP" can **** the edge of a circle whose center (radius point) is outside the boundary.

"WP" would not include a circle unless the entire circle were inside the boundary.

Same is true for complex things like block references and dimensions and mtext.

Of course for "CP" hatch objects are literally hit or miss.  I had a case last Friday where the boundary managed to find its way through a concrete hatch without ever crossing any internal line.  The only solution was to temporarily recreate an associative boundary.

Same can happen with "CP" and *TEXT, where the boundary happens to sneak between every character.  It's because AutoCAD is looking for visual intersections, not mathematical.

Oh yeah.  Same holds true for gaps in dashed linetypes, though LTGAPSELECTION (of which I just learned from @Kent1Cooper ) can help.  So a circle with a dashed linetype may not be selected at all with "CP."  Hmm, I just remembered that my earliest work included functions for finding mathematical intersections, though not for things like splines or ellipses, which we never used.

John F. Uhden

0 Likes
Message 17 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

Wait a second.  The SELECT command accepts the methods of "W" "C" "WP" "CP" and "F."

I don't know anything about the relatively new "LASSO."

Oops.  My apologies.  You were speaking of the SELECT command as not having filtering capabilities.  I believe that is correct.

John F. Uhden

0 Likes