Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting random number of multiple points - AutoLISP/VBA..

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi guys and gals,

How do I code in AutoLISP and/or VBA to allow the user to select multiple points on screen and use them as a point-list for a polyline (actually I want to use the command like the area command only, this one will convert the fiqure to metres-square and insert the answer as text).. Now this point list can be an random amount depending on what the user selects..

Any ideas,

Cheers,

Renegade.. BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
+447919 117062 (mobile)
 
Here's a lisp approach:

(setq ptlist nil)
;;following while loop builds a point list of
;;each selected point
(while
(setq pt (getpoint "\nPick a point: "))
(setq ptlist (cons pt ptlist));add point to fron
)
(setq ptlist (reverse ptlist)) ;reorder points, first to last

Now you can work this point list into an "area" command within the routine
 
Thanks CarlAK,

I'll try that out..

As I'm new to AutoLISP, I'm hazarding a guess at the next line here:

Code:
(COMMAND "_area" plist " ")

Also, wouldn't you have to have a WHILE argument, like:

Code:
WHILE (/= pt nil)

....or does the way you wrote stop the command on a nil entry?

Cheers,

Renegade..

BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
+447919 117062 (mobile)
 
DJR,
Yes, your code should return the area. The last "" should have no space between quotes. And yes the way it was written, creation of the ptlist would end on a nil (return). Then to get the area, use

(setq PtsArea (getvar "area"))
..which gives you area in current units.

Another way to collect points from user is from within the "area" command:

(command "area");starts the area command
(while (/= (getvar "cmdactive") 0);;loop while there is input
(command pause);;pauses for user input
);while

then get the area in the same way.

Have fun,

Carl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top