Look into the NCOPY command and/or the (nentsel) AutoLisp function. Which approach makes the most sense would depend on what you want to do once you access it.
Thanks Dear , actually I want to reach to a point where I can easily select the lwpolyline alone, by Visual Lisp.
thanks
I am using this program but still I need to select the LWpolyline Only , at present it is selecting LWpolyline with markers , stations ETC
thanks
(defun c:subent ()
(while
(setq Ent (entsel "\nPick an entity: "))
(print (strcat "Entity handle is: "
(cdr (assoc 5 (entget (car Ent))))))
)
(while
(setq Ent (nentsel "\nPick an entity or subEntity: "))
(print (strcat "Entity or subEntity handle is: "
(cdr (assoc 5 (entget (car Ent))))))
)
(prompt "\nDone.")
(princ)
)
You will need to check and see with an IF statement if the entity selected is a LWPOLYLINE before continuing with the rest of your code.
(defun c:test () (while (setq Ent (nentsel "\nPick an entity or subEntity: ")) (if (= (cdr (assoc 0 (entget (car Ent)))) "LWPOLYLINE") (print (strcat "Entity or subEntity handle is: " (cdr (assoc 5 (entget (car Ent)))))) (princ "\n ** Not a LWPOLYLINE!") ) ) )
You are reminding me of my XOFFSET command function which allows offsetting or cloning of a nested line, arc, circle, ray, xline, or polyline (either a segment or the entire polyline) with a dialog for other choices like layer, color, linetype.
As @DannyNL pointed out, you must use nentsel, not entsel.
John F. Uhden
@mehsan wrote:
....
(defun c:subent ()
(while
(setq Ent (entsel "\nPick an entity: "))
(print (strcat "Entity handle is: "
(cdr (assoc 5 (entget (car Ent))))))
)
(while
(setq Ent (nentsel "\nPick an entity or subEntity: "))
(print (strcat "Entity or subEntity handle is: "
(cdr (assoc 5 (entget (car Ent))))))
)
(prompt "\nDone.")
(princ)
)
I don't see anything to stop the first (while) loop, which probably means the only way to get out of it is with ESCape, and you therefore would never get to the second (while) loop that uses (nentsel). Or maybe picking nowhere or hitting Enter stops it, but I'm wondering what you're doing with what it returns -- it doesn't save the handle, or anything. And if you pick multiple things until Enter or a missed pick, nothing at all is saved about any of them except the last one.
I also don't see why the (nentsel) one is in a (while) loop, which also has nothing to end it. Try something much simpler:
(defun c:subent ()
(setq Ent (nentsel "\nPick an entity or subEntity: "))
(print
(strcat
"Entity or subEntity handle is: "
(cdr (assoc 5 (entget (car Ent))))
)
)
(princ)
)
That would be fine if user don't miss picking with (nentsel); if he misses your code would error Kent...
So don't miss and/or build code for the handling of a nil value.
It seems to me that it is very unlikely this code is already finished and I guess it has to do something more than just to return a handle, so error handling is still something to be developed in this case.
Since I'm not selling anything anymore, should I just give away my XOFFSET?
It doesn't use NCOPY nor copyfrom; it entmakes a new object translated (transformed?) from the nested one.
It works with non-nested entities as well which is neat if you want to offset just one segment of a polyline.
John F. Uhden
@marko_ribar wrote:
That would be fine if user don't miss picking with (nentsel); if he misses your code would error Kent...
Yes, and @mehsan's in Post 6 would just stop and say "Done" -- kind of meaningless, really, since nothing would be saved from whatever picking of object(s) was done before that point. There's got to be a lot more to this than we've seen so far.
(setvar "errno" 0)
(while (/= (getvar "errno") 52)
...
)
John F. Uhden
Thanks Every One,
To remove the confusion , Let me explain what is my purpose of this program.
I have a stations or chanaige program which is working perfectly all right for Polylines, but if I want to use the same program while polyline is xrefed what will be my basic strategy to select the Polyline, forget if you see stations already marked on my polyline drawing I attached.
thanks
John F. Uhden