Author Topic: Get Polyline inside Polyline  (Read 2718 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio123

  • Guest
Get Polyline inside Polyline
« on: January 07, 2015, 07:52:52 AM »
Hi

anyone have any idea why the object is not found within the Polyline?
For simpler objects such as a rectangle the code works.

Code: [Select]
(defun c:test ( / cdrs plEnt plList ss)

(defun cdrs (DxfKey ImpLst / TmpLst OutLst)
(while (setq TmpLst (assoc DxfKey ImpLst))
(setq OutLst (cons (trans (cdr TmpLst) 0 1) OutLst)
ImpLst (cdr (member TmpLst ImpLst))
)
)
(reverse OutLst)
)

(setq plEnt (entget (car (entsel "\nSelect pline:"))))
(setq plList (cdrs 10 plEnt))
(setq ss (ssget "_WP" plList))

)

Pedro


hmspe

  • Bull Frog
  • Posts: 362
Re: Get Polyline inside Polyline
« Reply #1 on: January 07, 2015, 08:25:11 AM »
Your code works in your test drawing when I run it in Bricscad.
"Science is the belief in the ignorance of experts." - Richard Feynman

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Get Polyline inside Polyline
« Reply #2 on: January 07, 2015, 10:05:40 AM »
Is the object fully visible in the drawing area when the ssget expression is evaluated? - Note that graphical selection methods such as WP/CP etc will only select objects that reside in the visible drawing area (I believe this is a consequence of the method used by AutoCAD to determine which objects fall within a selection window/polygon).

pedroantonio123

  • Guest
Re: Get Polyline inside Polyline
« Reply #3 on: January 07, 2015, 10:14:46 AM »
Hi Lee,

the object is fully visible,
maybe it has to do with the length of the list passed to ssget?
perhaps there is another method to get the object?
Pedro

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Get Polyline inside Polyline
« Reply #4 on: January 07, 2015, 10:55:41 AM »
Modify this line:
    (setq plList (cdrs 10 plEnt))
to:
    (setq plList (ALE_List_RemoveDupOnLst (cdrs 10 plEnt)))
Code: [Select]
; Function: ALE_List_RemoveDupes
;
; Version 1.00 - 9 Apr 2003
;
; Description:
;   removes all the duplicated elements leaving originals,
;   faster on lists with low number of duplicates
;   For example:
;   (setq alist (atoms-family 1))
;   (setq alist (append alist alist alist alist))
;
; Arguments:
;   In_Lst = A list
;
(defun ALE_List_RemoveDupOnLst (In_Lst / OutLst)
  (reverse
    (foreach ForElm In_Lst
      (if (vl-position ForElm OutLst)
        OutLst
        (setq OutLst (cons ForElm OutLst))
      )
    )
  )
)

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Get Polyline inside Polyline
« Reply #5 on: January 07, 2015, 04:01:38 PM »
You will also run into trouble if the polyline is self intersecting.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio123

  • Guest
Re: Get Polyline inside Polyline
« Reply #6 on: January 08, 2015, 08:58:35 AM »
Thanks  Marc'Antonio   :-)  it works.


lamarn

  • Swamp Rat
  • Posts: 636
Re: Get Polyline inside Polyline
« Reply #8 on: March 15, 2016, 05:36:25 AM »
follwing the idea to get objects within a closed (not self-intersecting) polyline i was trying to use this to get ALL elements, not just polylines.
This would be beneficial when working with the tool for manupulating viewport. I was thinking the cdrs statement has to be tuned to get this idea working..


Design is something you should do with both hands. My 2d hand , my 3d hand ..