Author Topic: - = { Challenge } = - Extract Rooms from the floor plan  (Read 6554 times)

0 Members and 1 Guest are viewing this topic.

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
- = { Challenge } = - Extract Rooms from the floor plan
« on: June 05, 2015, 12:53:14 PM »
Hello, guys! You are the best programmers i know :-)
For now I'm looking for a routine to extract rooms from floor plan to a new layer. Below is that I have and that I want.

ChrisCarlson

  • Guest
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #1 on: June 05, 2015, 01:01:53 PM »
That's not really a challenge, just a productivity saver for you. Do you have a submission for this challenge?

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #2 on: June 05, 2015, 03:08:00 PM »
That's not really a challenge, just a productivity saver for you. Do you have a submission for this challenge?
Actually I have no idea on how to solve it, but I read many topics with non-ordinary tasks marked as 'challenge' . The main problem is that rooms are consist of lines & plines and have no closed boundary.
Sure, this routine should be useful for many people

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #3 on: June 05, 2015, 04:37:53 PM »
The point of most of the "challenge" posts is to share an intellectual exercise the OP finds interesting, and to see the various solutions compared to their own.

So, in that vein, I would ask you to start: how would you do this manually?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

ymg

  • Guest
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #4 on: June 05, 2015, 06:55:19 PM »
ur_naz,

Not an easy one I am afraid.

Maybe knowing that doors opening tends to be standard size,
One could attempt to close the gaps in the polylines.

Opening could be found by finding the segments that are the
same length as the thickness of the walls.

Or may trying to fill rooms with square that are at least the size
of an opening.

But there are a lot of traps in there.

ymg

« Last Edit: June 05, 2015, 07:05:09 PM by ymg »

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #5 on: June 06, 2015, 09:51:55 AM »
ur_naz,

Not an easy one I am afraid.

Maybe knowing that doors opening tends to be standard size,
One could attempt to close the gaps in the polylines.

Opening could be found by finding the segments that are the
same length as the thickness of the walls.

Or may trying to fill rooms with square that are at least the size
of an opening.

But there are a lot of traps in there.

ymg
Yes, it is not easy and i don't even know the uerisctic search algorithm is faster then manually drawing.
Just in mind on how to deternine room conner points. this is for square rooms only. When sort conners to find rooms

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #6 on: June 06, 2015, 10:23:20 AM »
Maybe this approach can work (untested :wink:):
  • Determine the bounding box of the plan.
  • Calculate a grid of points within the bounding box. The distance between the points is smaller than the smallest room (let's say 0.5m).
  • Set HPGAPTOL to a size that is a little bigger than the maximum door width.
  • For each grid point (try to) create a polyline using the BOUNDARY command, store the entity list and then erase the new entity.
  • Process the stored entity lists: Delete duplicates and erase polylines that were drawn on top of walls (check for a segment that is smaller than 0.5m).
  • Create polylines from the remaining entity lists.

EDIT: Nah, this won't work.
« Last Edit: June 06, 2015, 03:49:49 PM by roy_043 »

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #7 on: June 06, 2015, 03:52:14 PM »
Perhaps this thread will get you part-way there:

http://www.theswamp.org/index.php?topic=47422.0

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #8 on: June 08, 2015, 02:00:07 PM »
ur_naz, try this code... Only tested few times...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:wallspolys ( / *error* *adoc* ss d sss i ent le entl entl2 entl3 leent ip entln ce r r1 r2 bplst entdlst ar bpl bpl2 el )
  2.  
  3.  
  4.   (defun *error* ( msg )
  5.     (vla-endundomark *adoc*)
  6.     (if msg (prompt msg))
  7.     (princ)
  8.   )
  9.  
  10.   (vla-startundomark *adoc*)
  11.   (prompt "\nSelect walls without columns (LINES,ARCS)...")
  12.   (setq ss (ssget "_:L" '((0 . "LINE,ARC"))))
  13.   (while (not ss)
  14.     (prompt "\nEmpty sel.set... Please select walls without columns (LINES,ARCS) again...")
  15.     (setq ss (ssget "_:L" '((0 . "LINE,ARC"))))
  16.   )
  17.   (initget 7)
  18.   (setq d (getdist "\nPick or specify maximum width of walls - specify little larger value, but smaller than smallest wall length : "))
  19.   (setq sss (ssadd))
  20.   (repeat (setq i (sslength ss))
  21.     (setq ent (ssname ss (setq i (1- i))))
  22.     (ssadd ent sss)
  23.     (if (eq (cdr (assoc 0 (entget ent))) "LINE")
  24.       (progn
  25.         (if (>= d le)
  26.           (setq entl (cons (cons le ent) entl))
  27.         )
  28.       )
  29.     )
  30.   )
  31.   (setq entl (vl-sort entl '(lambda ( a b ) (< (car a) (car b)))))
  32.   (setq entl2 entl)
  33.   (foreach leent1 entl
  34.     (setq le (car leent1))
  35.     (setq entl2 (vl-remove leent1 entl))
  36.     (while (not (eq (length entl3) 1))
  37.       (setq leent (car entl3))
  38.       (if
  39.         (and
  40.           (equal le (vlax-curve-getdistatparam (cdr leent) (vlax-curve-getendparam (cdr leent))) 1e-5)
  41.           (and
  42.             (eq (sslength (ssget "_F" (list (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr leent))))) 4)
  43.             (eq (sslength (ssget "_F" (list (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getendpoint (cdr leent))))) 4)
  44.             (eq (sslength (ssget "_F" (list (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr leent))))) 4)
  45.             (eq (sslength (ssget "_F" (list (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getendpoint (cdr leent))))) 4)
  46.           )
  47.           (or
  48.             (eq ip nil)
  49.             (if ip
  50.               (and
  51.                 (not (equal (distance ip (vlax-curve-getstartpoint (cdr leent1))) 0.0 1e-5))
  52.                 (not (equal (distance ip (vlax-curve-getendpoint (cdr leent1))) 0.0 1e-5))
  53.                 (or
  54.                   (equal (distance ip (vlax-curve-getstartpoint (cdr leent1))) (distance ip (vlax-curve-getstartpoint (cdr leent))) 1e-5)
  55.                   (equal (distance ip (vlax-curve-getstartpoint (cdr leent1))) (distance ip (vlax-curve-getendpoint (cdr leent))) 1e-5)
  56.                   (equal (distance ip (vlax-curve-getendpoint (cdr leent1))) (distance ip (vlax-curve-getstartpoint (cdr leent))) 1e-5)
  57.                   (equal (distance ip (vlax-curve-getendpoint (cdr leent1))) (distance ip (vlax-curve-getendpoint (cdr leent))) 1e-5)
  58.                 )
  59.               )
  60.             )
  61.           )
  62.         )
  63.         (setq entl3 (list leent))
  64.         (setq entl3 (cdr entl3))
  65.       )
  66.     )
  67.     (vl-some
  68.     '(lambda ( x / ce )
  69.       (if
  70.         (and
  71.           (equal le (car x) 1e-5)
  72.           (equal
  73.             (distance (vlax-curve-getpointatparam (cdr leent1) (/ (+ (vlax-curve-getstartparam (cdr leent1)) (vlax-curve-getendparam (cdr leent1))) 2.0)) (vlax-curve-getpointatparam (cdr (car entl3)) (/ (+ (vlax-curve-getstartparam (cdr (car entl3))) (vlax-curve-getendparam (cdr (car entl3)))) 2.0)))
  74.             1e-5
  75.           )
  76.           (not (vl-position (cdr leent1) (apply 'append entln)))
  77.           (not (vl-position (cdr x) (apply 'append entln)))
  78.             (and
  79.               (not (ssget "_C" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getstartpoint (cdr leent1)))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getstartpoint (cdr leent1))))))
  80.               (not (ssget "_C" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getstartpoint (cdr leent1)))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getstartpoint (cdr leent1))))))
  81.               (not (ssget "_C" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getendpoint (cdr leent1)))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getendpoint (cdr leent1))))))
  82.               (not (ssget "_C" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getendpoint (cdr leent1)))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0))) (distance ce (vlax-curve-getendpoint (cdr leent1))))))
  83.             )
  84.             (and
  85.               (not (ssget "_C" (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0))))
  86.               (not (ssget "_C" (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0))))
  87.               (not (ssget "_C" (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getstartpoint (cdr x))) '(2.0 2.0 2.0))))
  88.               (not (ssget "_C" (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (cdr leent1)) (vlax-curve-getendpoint (cdr x))) '(2.0 2.0 2.0))))
  89.             )
  90.           )
  91.         )
  92.         (setq entln (cons (list (cdr leent1) (cdr x)) entln))
  93.       )
  94.      ) entl2
  95.     )
  96.   )
  97.   (foreach entpair entln
  98.       (progn
  99.         (setq ss (ssget "_C" (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (car entpair))))
  100.         (ssdel (car entpair) ss)
  101.         (setq ent (ssname ss 0))
  102.         (setq r (cdr (assoc 40 (entget ent))))
  103.         (setq ss (ssget "_C" (vlax-curve-getstartpoint (cadr entpair)) (vlax-curve-getstartpoint (cadr entpair))))
  104.         (ssdel (cadr entpair) ss)
  105.         (setq ent (ssname ss 0))
  106.         (setq r1 (cdr (assoc 40 (entget ent))))
  107.         (setq ss (ssget "_C" (vlax-curve-getendpoint (cadr entpair)) (vlax-curve-getendpoint (cadr entpair))))
  108.         (ssdel (cadr entpair) ss)
  109.         (setq ent (ssname ss 0))
  110.         (setq r2 (cdr (assoc 40 (entget ent))))
  111.         (if (equal r r1 1e-5)
  112.           (progn
  113.             (command "_.ARC" "_non" (vlax-curve-getstartpoint (car entpair)) "_non" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) r) "_non" (vlax-curve-getstartpoint (cadr entpair)))
  114.             (setq bplst (cons (if (> r2 r1) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (- r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair))))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (+ r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair)))))) bplst))
  115.             (setq entdlst (cons (entlast) entdlst))
  116.           )
  117.           (progn
  118.             (command "_.ARC" "_non" (vlax-curve-getstartpoint (car entpair)) "_non" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0))) r) "_non" (vlax-curve-getendpoint (cadr entpair)))
  119.             (setq bplst (cons (if (< r2 r1) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (- r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair))))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (+ r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair)))))) bplst))
  120.             (setq entdlst (cons (entlast) entdlst))
  121.           )
  122.         )
  123.         (setq ss (ssget "_C" (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (car entpair))))
  124.         (ssdel (car entpair) ss)
  125.         (setq ent (ssname ss 0))
  126.         (setq r (cdr (assoc 40 (entget ent))))
  127.         (setq ss (ssget "_C" (vlax-curve-getstartpoint (cadr entpair)) (vlax-curve-getstartpoint (cadr entpair))))
  128.         (ssdel (cadr entpair) ss)
  129.         (setq ent (ssname ss 0))
  130.         (setq r1 (cdr (assoc 40 (entget ent))))
  131.         (setq ss (ssget "_C" (vlax-curve-getendpoint (cadr entpair)) (vlax-curve-getendpoint (cadr entpair))))
  132.         (ssdel (cadr entpair) ss)
  133.         (setq ent (ssname ss 0))
  134.         (setq r2 (cdr (assoc 40 (entget ent))))
  135.         (if (equal r r1 1e-5)
  136.           (progn
  137.             (command "_.ARC" "_non" (vlax-curve-getendpoint (car entpair)) "_non" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) r) "_non" (vlax-curve-getstartpoint (cadr entpair)))
  138.             (setq bplst (cons (if (> r2 r1) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (- r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair))))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (+ r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair)))))) bplst))
  139.             (setq entdlst (cons (entlast) entdlst))
  140.           )
  141.           (progn
  142.             (command "_.ARC" "_non" (vlax-curve-getendpoint (car entpair)) "_non" (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0))) r) "_non" (vlax-curve-getendpoint (cadr entpair)))
  143.             (setq bplst (cons (if (< r2 r1) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (- r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair))))) (polar ce (angle ce (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0))) (+ r (distance (vlax-curve-getpointatparam (car entpair) (/ (+ (vlax-curve-getstartparam (car entpair)) (vlax-curve-getendparam (car entpair))) 2.0)) (vlax-curve-getstartpoint (car entpair)))))) bplst))
  144.             (setq entdlst (cons (entlast) entdlst))
  145.           )
  146.         )
  147.       )
  148.       (if
  149.         (and
  150.           (eq (sslength (ssget "_F" (list (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))))) 4)
  151.           (eq (sslength (ssget "_F" (list (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))))) 4)
  152.           (eq (sslength (ssget "_F" (list (vlax-curve-getendpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))))) 4)
  153.           (eq (sslength (ssget "_F" (list (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))))) 4)
  154.         )
  155.         (progn
  156.           (if
  157.             (< (distance (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair)))
  158.                (distance (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair)))
  159.             )
  160.             (progn
  161.               (command "_.LINE" "_non" (vlax-curve-getstartpoint (car entpair)) "_non" (vlax-curve-getstartpoint (cadr entpair)) "")
  162.               (setq bplst (cons (mapcar '+ (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '- (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0)))) bplst))
  163.               (setq entdlst (cons (entlast) entdlst))
  164.             )
  165.             (progn
  166.               (command "_.LINE" "_non" (vlax-curve-getstartpoint (car entpair)) "_non" (vlax-curve-getendpoint (cadr entpair)) "")
  167.               (setq bplst (cons (mapcar '+ (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '- (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getstartpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0)))) bplst))
  168.               (setq entdlst (cons (entlast) entdlst))
  169.             )
  170.           )
  171.           (if
  172.             (< (distance (vlax-curve-getendpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair)))
  173.                (distance (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair)))
  174.             )
  175.             (progn
  176.               (command "_.LINE" "_non" (vlax-curve-getendpoint (car entpair)) "_non" (vlax-curve-getstartpoint (cadr entpair)) "")
  177.               (setq bplst (cons (mapcar '+ (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '- (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0)))) bplst))
  178.               (setq entdlst (cons (entlast) entdlst))
  179.             )
  180.             (progn
  181.               (command "_.LINE" "_non" (vlax-curve-getendpoint (car entpair)) "_non" (vlax-curve-getendpoint (cadr entpair)) "")
  182.               (setq bplst (cons (mapcar '+ (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '- (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getendpoint (cadr entpair))) '(2.0 2.0 2.0)) (mapcar '/ (mapcar '+ (vlax-curve-getendpoint (car entpair)) (vlax-curve-getstartpoint (cadr entpair))) '(2.0 2.0 2.0)))) bplst))
  183.               (setq entdlst (cons (entlast) entdlst))
  184.             )
  185.           )
  186.         )
  187.       )
  188.     )
  189.   )
  190.   (foreach ent entdlst
  191.     (ssadd ent sss)
  192.   )
  193.   (setq el (entlast))
  194.   (foreach p bplst
  195.     (command "_.-BOUNDARY" "_A" "_O" "_P" "_I" "_Y" "_B" "_N" sss "" "" "_non" p "")
  196.     (while (> (getvar 'cmdactive) 0) (command ""))
  197.     (if (not (eq el (entlast)))
  198.       (setq bpl (cons (setq el (entlast)) bpl))
  199.     )
  200.   )
  201.   (foreach ent entdlst
  202.     (entdel ent)
  203.   )
  204.   (setq sss (ssadd))
  205.   (setq bpl (vl-sort bpl '(lambda ( a b ) (< (vlax-curve-getarea a) (vlax-curve-getarea b)))))
  206.   (setq bpl2 bpl)
  207.   (foreach bp bpl
  208.     (if (entget bp)
  209.       (progn
  210.         (setq ar (vlax-curve-getarea bp))
  211.         (ssadd bp sss)
  212.       )
  213.     )
  214.     (setq bpl2 (vl-remove bp bpl2))
  215.     (foreach bp2 bpl2
  216.       (if
  217.         (and
  218.           (entget bp2)
  219.           (equal ar (vlax-curve-getarea bp2) 1e-5)
  220.         )
  221.         (entdel bp2)
  222.       )
  223.     )
  224.   )
  225.   (sssetfirst nil sss)
  226.   (*error* nil)
  227. )
  228.  

HTH, M.R.
« Last Edit: June 16, 2015, 09:03:45 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #9 on: June 09, 2015, 11:58:53 AM »
ribarm, thank you for your code, but it seems does nothing or maybe i do it wrong. i attached 2 examples i tried to process

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #10 on: June 09, 2015, 03:27:25 PM »
AutoCAD Architecture
James Buzbee
Windows 8

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #11 on: June 09, 2015, 03:55:30 PM »
ribarm, thank you for your code, but it seems does nothing or maybe i do it wrong. i attached 2 examples i tried to process

ur_naz, I've updated my code... Yes, it had some lacks... And I've modified your DWG just a little to make it correct wall to wall alignment at openings... Drawing must be 100 % correct - all adjacent edges of opening in wall must be the same length - width of wall must not be different at opening... I'll attach your DWG - also I overkilled duplicate lines...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #12 on: June 09, 2015, 06:39:09 PM »
Finally, I've corrected code again... Make sure you don't have overlapping entities and that your DWG is drawn correctly according to above mentioned text... I strongly suggest that you have only lines and arcs which should also be overkilled before executing routine...

Regards, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #13 on: June 11, 2015, 01:50:16 PM »
Yes ymg, there are more traps... I've coded lisp even more... Now it has implemented Gilles (purge-pline) function for simplifying LWPOLYLINES - thanks Gilles... Also I've considered cases where rooms may have the same area values, so my above function may remove those LWPOLYLINES even if they don't actually overlap... So I've decided to implement my OVERKILL-MR inside main function (c:WALLSPOLYS) and now it should overcome this trap... It may be little slower but it's correct for now - main routine that was posted considered traps like wall length to opening the same as wall width of opening and the cases with multiple openings at the same wall close to each other like shown in posted gif... I've decided to create one more step for considering creating outer LWPOLYLINE also cleaned from added vertices from openings as in my working experiences now this version can be used for quick making of 3D walls from 2D drawing - you just have to extrude all created LWPOLYLINES and subtract outer SOLID with inside SOLID(S)... I'll attach used lisp for this - you have to create additional bounding rectangle and select both rectangle and lines and arcs you want to process... If you just want to stick with old version like my posted code I also included Gilles function and my overkill inside other lisp that is attached here - it's called - "inner walls"...

So that's all from me till now... If you find some more traps and you think it's important to mention them, please report your opinion... I or maybe someone else will be willing to try to overcome that trap...

HTH, Kr. M.R.
« Last Edit: June 16, 2015, 09:04:38 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: - = { Challenge } = - Extract Rooms from the floor plan
« Reply #14 on: June 14, 2015, 09:37:30 AM »
Although with this my new intervention it may be too slow, but if you're planning to do this just once in a time and you don't want to clean DWG from overlaps and other entity types like POLYLINEs and you're confident that your drawing is correct - constant width of walls at openings and frozen doors and other stuff like columns, I suggest that you use my double overkill-restore all selected entities version... Duration of processing now depends of complexity of selection set - the more entities you select, the more processing lasts... But I could think of no better if you're lazy of cleaning and preparing drawing... Beside this you may want to keep original POLYLINEs and LINEs and ARCs as they are with all their properties like colors, widths and so on...

As no one haven't posted some new traps, I consider this is final for now and fixed from undesired bugs...

Kr. M.R.
« Last Edit: June 16, 2015, 09:05:06 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube