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?
|
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?
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")
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.:
It should at least get you started.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
Take care,
Tim
Last edited by Opie; 2006-01-23 at 02:12 PM. Reason: [CODE] tags added
Ok, that is giving me:
Select object: ; error: no function definition: DXF
Robert,Originally Posted by Robert.Hall
Try this function. It appears Tim has a routine to extract some data from an entity's group code data.
Tim, If the above code is not right, please let Robert know. Just trying to help out.Code:(defun DXF (ELEMENT ENTITY /) (cdr (assoc ELEMENT ENTITY))) ;;; retrieve assoc data from entity
If you have a technical question, please find the appropriate forum and ask it there.
You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
jUSt
that solves the dxf error
however............
; error: ActiveX Server returned the error: unknown name: AREA
I can't fix everything.Originally Posted by Robert.Hall
I'll see what I can come up with after lunch, if I have time.
If you have a technical question, please find the appropriate forum and ask it there.
You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
jUSt
Just a quick thought. Have you tried adding (vl-load-com) to the beginning of the routine?
If you have a technical question, please find the appropriate forum and ask it there.
You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
jUSt
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
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
I add the conversion?
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 )