Jump to content

Combining the Area Command in AutoLISP


mrthra

Recommended Posts

Morning!

 

Very simply, I have a drawing with houses and gardens in plan.

 

I am writing a routine which will pick and extract the house number text then pick round area of the garden and write both to a text file.

 

My problem is running the area command in Autolisp. As shown below, i start the area command and add a pause so i can pick round the perimeter of the garden. This doesnt seem to work?!! Any clues??

 

(command "area" pause)

(setq aa (getvar "area")

 

I use old skool lisp, so VBA is over my head!

 

regards

Link to comment
Share on other sites

Try to list programmatically the area instead of using the command:

 

(vl-load-com)
(setq MyEntity (vlax-ename->vla-object MyEntity))
(if (vlax-property-available-p MyEntity "area")
(vlax-get (vlax-ename->vla-object (entlast)) "area")
0.0
)

 

Regards

Link to comment
Share on other sites

Try to list programmatically the area instead of using the command:

 

(vl-load-com)
(setq MyEntity (vlax-ename->vla-object MyEntity))
(if (vlax-property-available-p MyEntity "area")
(vlax-get (vlax-ename->vla-object (entlast)) "area")
0.0
)

 

Regards

 

Thanks - however i want to pick points rather than select an object.

Link to comment
Share on other sites

So pick the points:

 

(defun _Area (/ val)
 (setq val (getvar 'area))
 (command "_.area")
 (while (< 0 (getvar 'cmdactive))
   (progn (princ "\nSpecify point: ")
          (command PAUSE)
   )
 )
 (if (not (member (getvar 'area) (list val 0.)))
   (getvar 'area)
 )
)

Personally, I'd do it this way (minus use of command and plus nice display), but we'll keep things simple to begin with:

 

area.gif

Link to comment
Share on other sites

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...