Do they need to be closed figures? Or can you just EXTEND lines until you just can't EXTEND no more, so to speak?
In my program, it has to be a colsed figure. What I want is the point lists of all the rects. just by "extend" wouldn't work.
.. in fact figure 5 is almost a match to figure 4 .. depends on the rules
You'd need some pretty complicated rules to make the decisions programmatically
Yes, many of them comes from the same starting shapes-two or three, or maybe four....rects. Acturally, we can recognize all the rects in the shapes at the first sight. But to get them (the point list) by program is so hard.
What's the rules between them...
the following is my routine. It can solve the "L" or "T" shape. But I want more...
;test: for test
(defun c:test (/ e i pt ptn )
(SETVAR "OSMODE" 0)
(setq e (vlax-ename->vla-object (car (entsel "\nPlsease select a colsed pline: ")))
i -1
ptn '()
)
(while (setq pt (vlax-curve-getPointAtParam e (setq i (1+ i))))
(setq ptn (cons pt ptn))
)
(sub ptn)
);test
;sub: to find out the rects from a colosed "L" or "T" shape.
(defun sub (ptn / n0 n1 n2 n3 pnum pt0 pt1 pt2 pt3 ptn)
(setq pnum (sub4 ptn 0 -1))
(setq n0 (nth 0 pnum))
(setq n1 (nth 1 pnum))
(setq pnum (sub4 ptn 0 1))
(setq n2 (nth 0 pnum))
(setq n3 (nth 1 pnum))
(if (< (cadr (nth n0 ptn)) (cadr (nth n3 ptn)))
(setq pt0 (list (car (nth n0 ptn)) (cadr (nth n3 ptn))))
(setq pt0 (nth n0 ptn))
);if
(if (> (cadr (nth n2 ptn)) (cadr (nth n1 ptn)))
(setq pt2 (list (car (nth n2 ptn)) (cadr (nth n1 ptn))))
(setq pt2 (nth n2 ptn))
);if
(command "-color" "1")
(command "rectang" pt0 pt2);draw the first rectangle
(setq pnum (sub4 ptn 1 -1))
(setq n0 (nth 0 pnum))
(setq n1 (nth 1 pnum))
(setq pnum (sub4 ptn 1 1))
(setq n2 (nth 0 pnum))
(setq n3 (nth 1 pnum))
(setq pt1 (list (max
(car (nth n0 ptn))
(car (nth n3 ptn))
) (min
(cadr (nth n0 ptn))
(cadr pt0)
)
)
)
(setq pt3 (list (min
(car (nth n1 ptn))
(car (nth n2 ptn))
) (max
(cadr (nth n2 ptn))
(cadr pt2)
)
)
)
(command "-color" "2")
(command "rectang" pt1 pt3);draw the second rectangle
)
;sub4: to arange
(defun sub4 (ptn axi cp / n n0 n1 nt pnum)
(setq n (vl-list-length ptn))
(setq n0 0)
(setq n1 0)
(while (> (setq n (1- n))
0
)
(if (> (* cp (nth axi (nth n ptn))) (* cp (nth axi (nth n0 ptn))))
(setq n0 n)
)
)
(setq n (vl-list-length ptn))
(while (> (setq n (1- n))
-1
)
(if (equal (nth axi (nth n ptn)) (nth axi (nth n0 ptn)) 5)
(if (/= n n0)
(setq n1 n)
);if
);if
);while
(setq axi (abs (- axi 1)))
(if (> (* cp (nth axi (nth n1 ptn))) (* cp (nth axi (nth n0 ptn))))
(progn
(setq nt n1)
(setq n1 n0)
(setq n0 nt)
);progn
);if
(setq pnum (list n0 n1))
pnum
)