TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: matrix2005in on June 08, 2006, 10:15:51 AM
-
HI
how can i add filter to this syntax
(setq sel (car(entsel "\nSelect Polyline")))
-
(prompt "\nSelect a polyline")
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE"))))
(and ss (setq sel (ssname ss 0)))
-
hi cab
gr8 it works the way i want..one more ..can you add closed polyline filter to this syntax?/
thanks
mathew
-
Select 1 closed pline....
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE")(-4 . "&")(70 . 1))))
-
hi jeff
thanks for the reply... 8-)
but that's not working.... :-(
-
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.
-
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
-
Now why didn't you say so to begin with? :-)
(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE,POLYLINE")
(-4 . "<NOT")
(-4 . "&")
(70 . 1)
(-4 . "NOT>")
)))
-
hi jeff
its working gr8
but how can i select multiple objects???
thanks
mathew
-
Just remove the "_+.:E:S", CAB added that to mimic the (entsel) command as you asked for.
-
hi Jeff
thanks man for your instant replies
now everthing works fine....
:)
mathew
-
You're welcome! Someone has to hold down the fort on weekends ;-)
-
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..
(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
-
oops there is little mistake in that
(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)
)
-
What version of ACAD are you using, mathew?Nevermind....this should work regardless of version:
(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)
)
-
Can a initget be added to the code as posted by CAB
(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?