# Thread: Check if a Rectangle is Closed or Open

1. Login to Give a bone

## Check if a Rectangle is Closed or Open

Hi alls
If you have a rectangle ,but you didn't know is it closed or open,my question is how to check it.

2. Login to Give a bone

## Re: Check if a Rectangle is Closed or Open

(70 . 1) closed
(70 . 0) open

3. Login to Give a bone

## Re: Check if a Rectangle is Closed or Open

Hi kennet,
Ah....I made stupid question,it's really easy solution.
many thanks kennet you was open my lock brain
here any code to know that,and I confuse last time why close and open always zero value 1

Code:
```(defun c:opencloserec (/ p1 p2 p3 p4 p5)
(setq p1 '(0 0 0))
(setq p2 '(10 0 0))
(setq p3 '(10 5 0))
(setq p4 '(0 5 0))
(setq p5 '(0 0.5 0))
(command "_pline" p1 p2 p3 p4 p5 "") ; for open rectangle
;(command "_pline" p1 p2 p3 p4 "c" "") ; for closed rectangle
(princ)
)```
(setq ss (car (entsel "\nSelect a open rectangle ")))
(setq sse (entget ss))
(setq recopen (cdr (assoc 70 sse)))

((-1 . <Entity name: 7d23e270>)
(0 . "LWPOLYLINE")
(330 . <Entity name: 7ef60cf8>)
(5 . "FE")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbPolyline")
(90 . 5)
(70 . 0)
(43 . 0.0)
(38 . 0.0)
(39 . 0.0)
(10 0.0 0.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 10.0 0.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 10.0 5.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 0.0 5.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 0.0 0.5)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(210 0.0 0.0 1.0))
_\$

0
_\$

(setq ss (car (entsel "\nSelect a open rectangle ")))
(setq sse (entget ss))
(setq recclosed (cdr (assoc 70 sse)))
<Entity name: 7d23e280>
((-1 . <Entity name: 7d23e280>)
(0 . "LWPOLYLINE")
(330 . <Entity name: 7ef60cf8>)
(5 . "100")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbPolyline")
(90 . 4)
(70 . 1)
(43 . 0.0)
(38 . 0.0)
(39 . 0.0)
(10 0.0 0.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 10.0 0.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 10.0 5.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(10 0.0 5.0)
(40 . 0.0)
(41 . 0.0)
(42 . 0.0)
(210 0.0 0.0 1.0))
1
_\$

Code:
```(defun c:test (/ ss sse)
(setq ss (car (entsel "\nSelect a rectangle")))
(setq sse (entget ss))
(if
(= (cdr (assoc 70 sse)) 1)
)
(princ)
)```
Originally Posted by kennet.sjoberg
(70 . 1) closed
(70 . 0) open
[ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]

4. Login to Give a bone

## Re: Check if a Rectangle is Closed or Open

Why not just check in the Properties Dialog Box? Just select it and it will say wether the polyline is opened or closed.

5. Login to Give a bone

## Re: Check if a Rectangle is Closed or Open

Originally Posted by srb
Why not just check in the Properties Dialog Box? Just select it and it will say wether the polyline is opened or closed.
Because quite often when you have the user in the middle of a routine, your routine really needs to know the answer to this and you usually can't rely on the user to do it for you, so you decide it's probably best to get yourself programatically.

Jeff

6. Login to Give a bone

## Re: Check if a Rectangle is Closed or Open

Thanks,

I lurk behind the scenes and try to learn a little about lisp & VBA.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•