TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on September 22, 2018, 11:00:22 AM

Title: Ssget "_X" by DXF point with fuzz
Post by: Marc'Antonio Alessi on September 22, 2018, 11:00:22 AM
Is it possible to pass a point list with a fuzz factor?
Example: (ssget "_X" (list '(0 . "MULTILEADER") (list 15 999.0 999.0 0.0)))
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: ribarm on September 22, 2018, 11:09:41 AM
Your point list does not have DXF group code... I suppose it should be 10 or 11 or ...
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: Marc'Antonio Alessi on September 22, 2018, 11:18:58 AM
I think I found the solution here by Lee Mac:
https://www.cadtutor.net/forum/topic/65020-select-object-by-insertion-point/

... I also found my similar question from some years ago …
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ssget-to-filter-entities-by-points/td-p/790381
 :grumpy: :whistling:
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: Marc'Antonio Alessi on September 22, 2018, 12:01:05 PM
Code by Lee Mac simplified for my purpose:
Code: [Select]
(defun SsgetMLeaderByDxf15 (PntLst FuzFac)
  (ssget "_X"
    (list
      '(0 . "MULTILEADER")
      '(-4 . ">=,>=,>=")
       (cons 15 (mapcar '- PntLst (list FuzFac FuzFac FuzFac)))
      '(-4 . "<=,<=,<=")
       (cons 15 (mapcar '+ PntLst (list FuzFac FuzFac FuzFac)))
    )
  )
)
(SsgetMLeaderByDxf15 '(1905.13 2043.22 0.0) 0.1)
Updated by Lee suggestion.
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: Lee Mac on September 22, 2018, 01:46:03 PM
You're welcome  :-)

Note that the additional <AND ... AND> items in the filter list are no longer required when only filtering for a single point - the AND logic is inherent in the way that filter list is interpreted.
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: Marc'Antonio Alessi on September 22, 2018, 03:17:19 PM
You're welcome  :-)

Note that the additional <AND ... AND> items in the filter list are no longer required when only filtering for a single point - the AND logic is inherent in the way that filter list is interpreted.
Thanks Lee  :-) I update the code now.
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: Marc'Antonio Alessi on October 23, 2018, 02:42:38 AM
New request:
(defun Ctr_Utils_SsgetByDxf10 (ObjTyp LyrNam PntLst FuzFac)
  (ssget "_X"
    (list
       (cons 0 ObjTyp) (cons 8 LyrNam)
      '(-4 . ">=,>=,>=") (cons 10 (mapcar '- PntLst (list FuzFac FuzFac 0)))
      '(-4 . "<=,<=,<=") (cons 10 (mapcar '+ PntLst (list FuzFac FuzFac 0)))
    )
  )
)
(Ctr_Utils_SsgetByDxf10 "LWPOLYLINE" "Mylayer" '(10.0 10.0 0.) 0.01)

On polylines there are many situations in which the result is wrong. The more vertices there are, the greater the probability of error.
Solutions?
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: roy_043 on October 23, 2018, 09:32:49 AM
@Marc'Antonio Alessi:
What you want to do is not possible for LW polylines with ssget only. The function will have to be extended with a 'post-process'. It is not the number of vertices that is the issue, but their location relative to PntLst. Your code will select any rectangle around PntLst for example.
Title: Re: Ssget "_X" by DXF point with fuzz
Post by: Marc'Antonio Alessi on October 23, 2018, 10:09:02 AM
@Marc'Antonio Alessi:
What you want to do is not possible for LW polylines with ssget only. The function will have to be extended with a 'post-process'. It is not the number of vertices that is the issue, but their location relative to PntLst. Your code will select any rectangle around PntLst for example.
Yes, that's what I found… Thanks.