Creating multiple closed polygons in selected closed boundaries

Creating multiple closed polygons in selected closed boundaries

Anonymous
Not applicable
6,871 Views
13 Replies
Message 1 of 14

Creating multiple closed polygons in selected closed boundaries

Anonymous
Not applicable

Dear Helpers,

 

I stucked in creating lot of closed polygons in closed boudaries. Suppose we have so many rooms in a floor of a building with just lines and arcs. The lisp should generate multiple polygons inside the closed boundaries of rooms or zones.

Please have a look on attached drawing.

0 Likes
Accepted solutions (2)
6,872 Views
13 Replies
Replies (13)
Message 2 of 14

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

If your every Room is named then try this........(Chose a layer create Polyline & change its properties.....)

 

(defun C:CB (/)
(setvar "CMDECHO" 0)
(princ "\nSelect the Text/Mtext Inside the Closed Area: ")
(Setq selectionset (ssget '((0 . "*TEXT"))))
(repeat (setq N (sslength selectionset))
	(setq Data (ssname selectionset (setq N (- N 1))))
	(setq EntityData (entget Data))
	(setq IP_Text (cdr (assoc 10 EntityData)))
	(command "BOUNDARY" "_none" IP_Text "") 
)
(setvar "CMDECHO" 1)
(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 3 of 14

Anonymous
Not applicable

Exact Solution I got from you.

Very Nice. Thankin you So much. Perfectly suited to my task

0 Likes
Message 4 of 14

Anonymous
Not applicable

Thank you Very much.

 

But it's not working with without text. If some rooms may not having text inside. So in that case also it should create Room boundaries.

Thank you inadvance, Sir.

0 Likes
Message 5 of 14

dbhunia
Advisor
Advisor

chek this..... created by @ВeekeeCZ.....

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ssget-to-select-a-polyline-using-two...

 

And first give some clue how the problem can be solved.......

 

Second post your workout.......

 

Because its sure you are going to ask many questions 1 by 1.......


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 6 of 14

phanaem
Collaborator
Collaborator
Accepted solution

Try the attached lisp.

Works with lines, arcs, circles and polylines, parallel to UCS.

 

Message 7 of 14

Anonymous
Not applicable

I used the below code from that link. But couldn't work.

(defun c:testeclose ( / ss i obj pnt ptlst ptsum )

  (if (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "&=") (70 . 1) (-4 . "NOT>") (-4 . ">") (90 . 2))))
    (repeat (setq i (sslength ss))
      (setq ptlst nil ptsum '(0 0)
	    ptlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10))
				      (entget (ssname ss (setq i (1- i)))))))
      (foreach x ptlst (setq ptsum (mapcar '+ x ptsum)))
      (setq pnt (mapcar '/ ptsum (list (length ptlst) (length ptlst))))
      (if pnt (command "_.-boundary" "_non" pnt ""))))
  (princ)
)
0 Likes
Message 8 of 14

Anonymous
Not applicable

Thank you So much Sir. It's working fetatstic

0 Likes
Message 9 of 14

alansanudo
Advocate
Advocate

What's the command how can i execute it? will it work to create multiple boundaries for different "areas" as the image attached?

 

create.png

windows 7, intel I7, 8 MB RAM, civil3d 2013.
0 Likes
Message 10 of 14

Kent1Cooper
Consultant
Consultant

@alansanudo wrote:

What's the command how can i execute it? will it work to create multiple boundaries for different "areas" as the image attached?


 

Here's a way to do that.  It asks you to pick points [just on-screen -- nothing drawn] defining opposite corners of a rectangular area that completely encloses the drawn [I assume property-line] parcels, and asks for a spacing increment, starts a BOUNDARY command, and just picks every point in a grid at that spacing throughout the area.  If it picks outboard of it all, a message goes by that no enclosed area was found, and if it picks more than once within the same area, a message goes by that the area has already been picked, but in either case it doesn't bother anything -- it keeps going.  Give it a spacing increment small enough that it's bound to land inside every parcel somewhere at least once, maybe a little less than the smallest parcel edge expected.  You will want to turn off Layers other than those of your property lines, so that it won't find an enclosed area outside of them all.  And it depends on all the parcels really being closed.  Minimally tested.

(defun C:MBound ; = Multiple Boundaries
  (/ cor1 cor2 UR rowleft pt)
  (setq
    cor1 (getpoint "\nOne corner of area-enclosing rectangle: ")
    cor2 (getcorner cor1 "\nOpposite corner: ")
    inc (getdist "\nPick-point spacing increment: ")
    UR (mapcar 'max cor1 cor2)
    rowleft (mapcar '+ (mapcar 'min cor1 cor2) (list inc inc))
    pt rowleft
  ); setq
  (command "_.boundary" "advanced" "object" "Polyline" "")
  (while (< (cadr pt) (cadr UR)); still below top edge
    (while (< (car pt) (car UR)); still to left of right edge
      (command pt)
      (setq pt (polar pt 0 inc))
    ); while
    (setq
      rowleft (polar rowleft (/ pi 2) inc)
      pt rowleft
    ); setq
  ); while
  (command "")
  (princ)
); defun
Kent Cooper, AIA
0 Likes
Message 11 of 14

alansanudo
Advocate
Advocate

Thanks for the explanation, but how do I execute the code? sorry for my ignorance.

windows 7, intel I7, 8 MB RAM, civil3d 2013.
0 Likes
Message 12 of 14

Kent1Cooper
Consultant
Consultant

Copy the code into a plain-text editor such as Notepad.  Save it to a file with a .LSP filetype ending [call it anything you want].  In AutoCAD, APPLOAD that file.  The command name is MBound [the part immediately following C: -- not case-sensitive].

Kent Cooper, AIA
0 Likes
Message 13 of 14

kareemelnady8
Participant
Participant

"Enclosed polylines v1.03.lsp" this is perfect it's very good thank you

0 Likes
Message 14 of 14

albinZ5N68
Contributor
Contributor

Hi, thanks for your work.

I'm trying to adapt it to get the result shown in the attachment (automatic separation of closed parts, with inclusion of objects inside the parts).

But already, when I use the LISP on my entire drawing, if I have multiple separate elements, the region detection gives me full regions instead of only the smallest ones... Do you know why?

0 Likes