TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on March 01, 2019, 01:14:14 AM

Title: Creating list of points
Post by: HasanCAD on March 01, 2019, 01:14:14 AM
Hi all
I am trying to get a list of perpanducular points of alligned objects
but the list comes in strage format

Code - Auto/Visual Lisp: [Select]
  1. (setq dtlst nil )
  2. (setq p1 (getpoint"\nPick Point"))
  3. (setq p2 (getpoint p1 "\nPick Point"))
  4.  
  5. (setq objs (ssget "_C" p1 p2 ))
  6.  
  7. (repeat (setq cnt (sslength objs))
  8.   (setq objVL (vlax-ename->vla-object (ssname objs (setq cnt (1- cnt)))))
  9.   (setq dtlst (cons ps p1n))
  10.   )


Quote
((((((((nil 20.2771 10.3859 0.0) 20.9515 9.64759 0.0) 21.6259 8.90925 0.0) 22.3004 8.1709 0.0) 22.9748 7.43256 0.0) 23.6492 6.69422 0.0) 24.3236 5.95587 0.0) 24.791 6.38282 0.0)

edit kdub : Topics Merged
Title: Re: Creating list of points
Post by: CADwiesel on March 01, 2019, 02:08:09 AM
ssget normaly returns the objects in order they had been created.
you need to sort the points relative to P1 in the distance
Title: Re: Creating list of points
Post by: roy_043 on March 01, 2019, 03:08:26 AM
The code cannot produce the supplied return I think. The variable 'ps' is nil throughout.

But this:
Code: [Select]
(setq dtlst (cons ps p1n))Should probably be:
Code: [Select]
(setq dtlst (cons p1n dtlst))
Title: Re: Creating list of points
Post by: Lee Mac on March 01, 2019, 08:02:05 AM
You calculate a point assigned to variable p1n, but construct the list dtlst using variable ps which is not defined in your posted code.

Code - Auto/Visual Lisp: [Select]
  1.   (setq dtlst (cons ps p1n))
Title: Re: Creating list of points
Post by: HasanCAD on March 01, 2019, 07:55:07 PM
Thanks CADwiesel
Thanks roy_043
Thanks Lee
Title: Re: Creating list of points
Post by: BIGAL on March 02, 2019, 01:09:58 AM
If you use the fence option in your ssget it will pick objects in order. you have pt1 pt2

Code: [Select]
(setq lst (list p1 p2))
(setq objs (ssget "F" lst (list (cons 0 "line"))))
Title: Re: Creating list of points
Post by: HasanCAD on March 05, 2019, 10:16:11 AM
If you use the fence option in your ssget it will pick objects in order. you have pt1 pt2

Code: [Select]
(setq lst (list p1 p2))
(setq objs (ssget "F" lst (list (cons 0 "line"))))
Thanks BIGAL
Title: Re: Creating list of points
Post by: Tharwat on March 05, 2019, 12:50:05 PM
If you use the fence option in your ssget it will pick objects in order. you have pt1 pt2

Code: [Select]
(setq lst (list p1 p2))
(setq objs (ssget "F" lst (list (cons 0 "line"))))
Fence option will never detect hidden lines of example if the vector line of variables p1 & p2 passed through the empty gap of the line type.
Title: Re: Creating list of points
Post by: BIGAL on April 23, 2019, 06:19:38 AM
Thanks Tharwat have had that happen in day to day stuff. Its another of those frustrating Autocad lisp bugs.
Title: Re: Creating list of points
Post by: Tharwat on April 23, 2019, 09:46:32 AM
Thanks Tharwat have had that happen in day to day stuff. Its another of those frustrating Autocad lisp bugs.
Its my pleasure.