# Thread: Area in metric from English units drawing

1. Login to Give a bone

## Area in metric from English units drawing

I need a lisp routine that:

Selects an object (polyline, hatch, etc.)
that is drawn in english untis

and

Returns the area in metric units mm^2

Anybody know how to do this?

2. Login to Give a bone

## Re: Area in metric from English units drawing

You can supply the selection & area portions, this will convert the area to mm^2:

(cvunit 60.0 "feet^2" "mm^2")
(cvunit 60.0 "inch^2" "mm^2")

3. Login to Give a bone

## Re: Area in metric from English units drawing

Here is a quick and dirty that should work for hatch or polyline entities for getting the raw area, but I didn't try it on lines, arcs, etc.:

Code:
```(defun c:getarea (/ e vlaobj)
(setq e (entget (car (entsel))))
(setq vlaobj (vlax-ename->vla-object (dxf -1 e)))
(vlax-get-property vlaobj 'Area)
);defun```
It should at least get you started.

Take care,
Tim

4. Login to Give a bone

## Re: Area in metric from English units drawing

Ok, that is giving me:

Select object: ; error: no function definition: DXF

5. Login to Give a bone

## Re: Area in metric from English units drawing

Originally Posted by Robert.Hall
Ok, that is giving me:

Select object: ; error: no function definition: DXF
Robert,

Try this function. It appears Tim has a routine to extract some data from an entity's group code data.

Code:
`(defun DXF (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY))) ;;; retrieve assoc data from entity`
Tim, If the above code is not right, please let Robert know. Just trying to help out.

6. Login to Give a bone

## Re: Area in metric from English units drawing

that solves the dxf error

however............

; error: ActiveX Server returned the error: unknown name: AREA

7. Login to Give a bone

## Re: Area in metric from English units drawing

Originally Posted by Robert.Hall
that solves the dxf error

however............

; error: ActiveX Server returned the error: unknown name: AREA
I can't fix everything.

I'll see what I can come up with after lunch, if I have time.

8. Login to Give a bone

## Re: Area in metric from English units drawing

Just a quick thought. Have you tried adding (vl-load-com) to the beginning of the routine?

9. Login to Give a bone

## Re: Area in metric from English units drawing

Oops, sorry,

In my haste, I forgot to give you the dxf function:

(defun dxf (code elist)
(cdr (assoc code elist))
);defun

Also, it looks like it only returns the area for those items that have area (i.e. hatch and polylines).

I hope this helps.

By the way, from personal experience, it is possible to golf in the snow. It's pretty frustrating when the ball turns into a snowball and won't fit in the hole, though.

Tim

10. Login to Give a bone

## Re: Area in metric from English units drawing

So I have an area returned, however, it isn't converted.
I have been messing around with converting the output
and I have not had any success. Where in this code do

Code:
```(defun c:aw (/ e vlaobj)
(setq e (entget (car (entsel))))
(setq vlaobj (vlax-ename->vla-object (dxf -1 e)))
(vlax-get-property vlaobj 'Area)
);defun
(defun dxf (code elist)
(cdr (assoc code elist))
);defun
)```

Page 1 of 3 123 Last

#### Posting Permissions

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