TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: matrix2005in on June 08, 2006, 10:15:51 AM

Title: How to Filter an entsel?
Post by: matrix2005in on June 08, 2006, 10:15:51 AM
HI

how can i add filter to this syntax

Code: [Select]
(setq sel (car(entsel "\nSelect Polyline")))
Title: Re: How to find vertex number
Post by: CAB on June 08, 2006, 11:34:41 AM
Code: [Select]
(prompt "\nSelect a polyline")
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE"))))
(and ss (setq sel (ssname ss 0)))
Title: Re: How to find vertex number
Post by: matrix2005in on June 09, 2006, 02:22:19 PM
hi cab

gr8 it works the way i want..one more ..can you add closed polyline filter to this syntax?/
thanks

mathew
Title: Re: How to find vertex number
Post by: Jeff_M on June 09, 2006, 03:56:09 PM
Select 1 closed pline....
Code: [Select]
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE")(-4 . "&")(70 . 1))))
Title: Re: How to find vertex number
Post by: matrix2005in on June 11, 2006, 11:21:32 AM
hi jeff

thanks for the reply... 8-)

but that's not working.... :-(

Title: Re: How to find vertex number
Post by: Jeff_M on June 11, 2006, 12:22:57 PM
It works here on Closed plines. If you manually close them, i.e. snap the last point to the start point, then it won't work.

And please, don't just say "it's not working".....post exatly what it does, or does not, do along with any error messages.

To test if this works just draw 2 "U" shaped plines, finish the second one with "C".
Now paste that one line of code I posted to the command line, select the first one and observe the command line output. Now paste the code to the command line again, select the second one and observe the output. The first should return nil, the second should return <Selection set: c>...where the "c' cand be any hex number.
Title: Re: How to find vertex number
Post by: matrix2005in on June 11, 2006, 01:39:16 PM
Hi jeff
sorry for the confusion...your code will work to select only closed polyline..but i want a code that wont select closed polylines..thnaks
mathew
Title: Re: How to find vertex number
Post by: Jeff_M on June 11, 2006, 01:59:13 PM
Now why didn't you say so to begin with? :-)
Code: [Select]
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE")
    (-4 . "<NOT")
    (-4 . "&")
    (70 . 1)
    (-4 . "NOT>")
    )))
Title: Re: How to find vertex number
Post by: matrix2005in on June 11, 2006, 02:44:22 PM
hi jeff
its working gr8
but how can i select multiple objects???

thanks

mathew
Title: Re: How to find vertex number
Post by: Jeff_M on June 11, 2006, 02:56:01 PM
Just remove the "_+.:E:S", CAB added that to mimic the (entsel) command as you asked for.
Title: Re: How to find vertex number
Post by: matrix2005in on June 11, 2006, 03:10:40 PM
hi Jeff

thanks man for your instant replies

now everthing works fine....
:)

mathew
Title: Re: How to find vertex number
Post by: Jeff_M on June 11, 2006, 03:44:07 PM
You're welcome! Someone has to hold down the fort on weekends ;-)
Title: Re: How to find vertex number
Post by: matrix2005in on June 12, 2006, 01:56:42 PM
hi

I KNOW this may be very simple..but i am not getting proper solution..can you please help me..i just combined your code and other code to make pjoin..the problem is this works well with arcs,lines..but if selection set includes polyline then it will give error..code is posted below..
Code: [Select]
(defun C:PJOIN (/ SS2)
  (setq ss2 (ssget '((0 . "LWPOLYLINE,POLYLINE,LINE,ARC")
     (-4 . "<NOT")
     (-4 . "&")
     (70 . 1)
     (-4 . "NOT>")
    )
    )
  )

  (if (=  "LWPOLYLINE" ss2)
    (command "._PEDIT" "m" ss2 "" "_J" "" "")
    (command "._PEDIT" "m" ss2 "" "_Y" "_J" "" "")
    )
  (princ)
)

thanks
mathew
Title: Re: How to find vertex number
Post by: matrix2005in on June 12, 2006, 01:58:15 PM
oops there is little mistake in that

Code: [Select]
(defun C:PJOIN (/ SS2)
  (setq ss2 (ssget '((0 . "LWPOLYLINE,POLYLINE,LINE,ARC")
     (-4 . "<NOT")
     (-4 . "&")
     (70 . 1)
     (-4 . "NOT>")
    )
    )
  )

  (if (=  "LWPOLYLINE" ss2)
    (command "._PEDIT" "m" ss2 "" "_J" "" "")
    (command "._PEDIT" "m" ss2 "" "_Y" "_J" "" "")
    )
  (princ)
)

Title: Re: How to find vertex number
Post by: Jeff_M on June 12, 2006, 03:00:15 PM
What version of ACAD are you using, mathew?Nevermind....this should work regardless of version:
Code: [Select]
(defun C:PJOIN (/ SS2)
  (setq ss2 (ssget '((0 . "LWPOLYLINE,POLYLINE,LINE,ARC")
     (-4 . "<NOT")
     (-4 . "&")
     (70 . 1)
     (-4 . "NOT>")
    )
    )
  ) 

  (if (and ss2
              (or (not (setq pa (getvar "peditaccept")));;if this sysvar is not available
           (= pa 0);;or if it's set to 0
       )
   (ssget "P" '((0 . "LINE,ARC")));;and check to see if any non-plines are in the ss
   )
    (command "._PEDIT" "m" ss2 "" "_Y" "_J" "" "");;there are, so use the "Y" to convert
    (command "._PEDIT" "m" ss2 "" "_J" "" "")
    )
  (princ)
)
Title: Re: How to Filter an entsel?
Post by: csgoh on June 24, 2006, 04:29:51 AM
Can a initget be added to the code as posted by CAB
Code: [Select]
(initget "Layer Property") ;added for keywords
(prompt "\nLayer / Continue / <select a polyline>")
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE"))))
(and ss (setq sel (ssname ss 0)))
[/code


Does any word that start with L a forbidden keyword as this will return the last entity in the dwg?