Jump to content

Recommended Posts

Posted

Hi Guys 

I've made this lisp routine for getting the area of a shape using ssget...
Sometimes it works fine and sometimes it fails with the following error

Autolisp Error: ActiveX Server returned the error: unknown name: Area

 

Could someone please take a look and let me know where i've gone wrong?

many thanks

 

;Checks  area. min size of 30000mm2 set.
(defun c:ChkMinArea (/ ss1 Limit a b c)
 (setq Limit 30000)
 (setq ss1 (ssget "x" '((0 . "LWPOLYLINE")(8 . "FinalTrim" ))))
 (setq a (entlast))
 (setq b (vla-get-area (vlax-ename->vla-object a)))
 (setq c ( - Limit b))
 (if (>= b Limit)
  (princ "\nArea is Okay... proceeding....")
  (Alert (strcat "Plate needs extending by\n" (rtos c) "mm2 Area"))
 )
 (Princ)
);end defun

 

Test Upload.dwg

Posted (edited)
19 minutes ago, Sharper said:

Hi Guys 

I've made this lisp routine for getting the area of a shape using ssget...
Sometimes it works fine and sometimes it fails with the following error

Autolisp Error: ActiveX Server returned the error: unknown name: Area

 

Could someone please take a look and let me know where i've gone wrong?

many thanks

 

;Checks  area. min size of 30000mm2 set.
(defun c:ChkMinArea (/ ss1 Limit a b c)
 (setq Limit 30000)
 (setq ss1 (ssget "x" '((0 . "LWPOLYLINE")(8 . "FinalTrim" ))))
 (setq a (entlast))
 (setq b (vla-get-area (vlax-ename->vla-object a)))
 (setq c ( - Limit b))
 (if (>= b Limit)
  (princ "\nArea is Okay... proceeding....")
  (Alert (strcat "Plate needs extending by\n" (rtos c) "mm2 Area"))
 )
 (Princ)
);end defun

 

Test Upload.dwg 40.52 kB · 0 downloads

 

 

..

 

 

Edited by devitg
my error
Posted

you set ss1 using ssget but you are proccessing "a" by entlast. This is why it sometimes works and sometimes not, since the last entity is diffrent and errors out for wrong types

  • Thanks 1
Posted

The  Entlast , is the last entity made at the DWG, and NOT the last ent at the selection set 

 

 

 

 

 

Posted

Ahh this makes sense
Staring me right in the face for the last 3 days...

 

Thank you guys, really appreciate the help

 

Posted
(setq ss1 (ssget "x" '((0 . "POLYLINE")(8 . "FinalTrim" ))))
   (setq ent (ssname ss1 0))
  
 (setq a ent)

  Test  it , as it is a only one "POLYLINE"

  • Thanks 1
Posted

i would go like this
 

(defun c:ChkMinArea (/ ss1 Limit i a b c)
  (setq Limit 30000)
  (setq ss1 (ssget "_X" '((0 . "POLYLINE")(8 . "FinalTrim"))))
  (setq i 0)
  
  (while (< i (sslength ss1))
    (setq a (ssname ss1 i))
    (setq b (vla-get-area (vlax-ename->vla-object a)))
    (setq c ( - Limit b))
    (if (>= b Limit)
      (princ "\nArea is Okay... proceeding....")
      (progn
        (command "_zoom" "_obj" a "")
        (Alert (strcat "Plate needs extending by\n" (rtos c) "mm2 Area"))
      )
    )
    (setq i (1+ i))
  )
  (Princ)
);end defun

 

  • Thanks 1
Posted

Hey EnM4st3r
I originally started off using sslength count, but removed it once i realised it would only ever be one closed rectangular shape on each file.
I suppose it wouldn't have hurt if i left it in there

Posted

My routine is now updated and working perfectly.
Thank you once again for the assistance 

  • Like 1
Posted

If only one entity at a time, you can add a Has-Property 'Area check.

 

(while (setq obj (vlax-ename->vla-object (car  (entsel "Pick obj for area "))))
(setq a (vlax-get obj 'Area))
(setq lay (vlax-get obj 'layer))
(alert (strcat "The Area is " (rtos a 2 2) " on layer " lay))
)

 

 

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...