BIGAL Posted April 22, 2010 Posted April 22, 2010 I am sure its simple but can not get it to work. I have a polyline entsel it explode it and now want to select the new line at the same pick point rather than pick twice. Need a line for rest of routine. Entsel can use a point but I can not get it to use the returned first entsel point tried strings lists etc Quote
MSasu Posted April 22, 2010 Posted April 22, 2010 Use ENTLAST statement to select it - after explosion the line become the last entity in database. This works well if the polyline is done by only one line. For a multi-segment polyline, can record the name of last entity before explosion and parse new added items just after to find the one that is closest to selection point. Regards, Quote
MSasu Posted April 22, 2010 Posted April 22, 2010 Alternatively can use: (ssget MySelectionPoint) Regards, Quote
Lee Mac Posted April 22, 2010 Posted April 22, 2010 Another way to approach it: (defun EntnextToEnd ( ent ) (if (setq ent (entnext ent)) (cons ent (EntnextToEnd ent)))) (defun c:test (/ ent eLast ss ) (if (setq ent (car (entsel))) (progn (setq eLast (entlast)) (command "_.explode" ent) (setq ss (ssadd)) (mapcar (function (lambda ( e ) (ssadd e ss))) (EntnexttoEnd eLast)) (sssetfirst nil ss))) (princ)) Quote
viviancarvalho Posted April 22, 2010 Posted April 22, 2010 Another way to approach it: (defun EntnextToEnd ( ent ) (if (setq ent (entnext ent)) (cons ent (EntnextToEnd ent)))) (defun c:test (/ ent eLast ss ) (if (setq ent (car (entsel))) (progn (setq eLast (entlast)) (command "_.explode" ent) (setq ss (ssadd)) (mapcar (function (lambda ( e ) (ssadd e ss))) (EntnexttoEnd eLast)) (sssetfirst nil ss))) (princ)) Lee Even i have a somewhat same problem. I want to select two lines & want to use these same picked points again. It could be a combination of entsel & getpoint or vice versa. How can this be acheived ? Help please Quote
Lee Mac Posted April 22, 2010 Posted April 22, 2010 You can store the picked points as variables, getpoint will obviously return the picked point, and entsel returns a two element list: (<entityname> (x y z)) With the second element being the picked point - bear in mind however, that the picked point is the center of the pick box, which may not necessarily lie on the object picked. Lee Quote
alanjt Posted April 22, 2010 Posted April 22, 2010 You can store the picked points as variables, getpoint will obviously return the picked point, and entsel returns a two element list: (<entityname> (x y z)) With the second element being the picked point - bear in mind however, that the picked point is the center of the pick box, which may not necessarily lie on the object picked. Lee The point could also be '(0. 0. 0.) if the user issued "L" for last. eg. Command: (entsel) Select object: l (<Entity name: 77831480> (0.0 0.0 0.0)) Quote
BIGAL Posted April 23, 2010 Author Posted April 23, 2010 Back to me the SSGET worked as entsel does not seem to allow for a automatic pick point. Regarding pick two lines above not a problem just entsel and make two variables or ssget two objects and can work out say a mid pt of lines (ssget no pick point). Quote
alanjt Posted April 23, 2010 Posted April 23, 2010 (setq p (getpoint)) (setq ss (ssget p)) (setq e (ssname ss 0)) OR (nentselp (getpoint)) Quote
BIGAL Posted April 27, 2010 Author Posted April 27, 2010 Hi Guys don't you hate it when something just will not work and you can not see it. Heres a part of the code (setq obj (entsel "\nPick back of kerb line")) (setvar "osmode" 0) (setq objtype (cdr (assoc 0 (entget (car obj))))) (IF (or (= objtype "POLYLINE")(= objtype "LWPOLYLINE")) (progn (setq objpt (cadr obj)) (princ "\nNow exploding polyline that was picked :") (command "explode" obj "") (setq ss (ssget objpt)) (setq obj2 (entget (ssname ss 0))) ) (setq obj2 (entget (car obj))) ; else is line ) obj2 works fine either way Further along a break is called for (command "break" pt15 pt16) this does not work if original was a ployline then exploded but works perfect if it was originaly a line, if I run this break code at the command prompt it works ? Any ideas would be appreciated others having a look often find the cause straight away. Quote
Lee Mac Posted April 28, 2010 Posted April 28, 2010 BIGAL, I would approach the problem using the code I submitted in my earlier post. Quote
BIGAL Posted April 28, 2010 Author Posted April 28, 2010 Hi lee thanks for the suggestion problem is the entlast seems to always return the last part of a pline and the user has picked a different section when the pline is made of multiple plines. here is full code Just draw a line say 10 units long pick 2 points same side within line length accept distance returned and the line will have an offset section drawn into it we then repeat for as many house driveways as required. Try again but with pline say 10 units long or multi lengths. (princ "\nTo run again type DRV") (princ "\n") (defun c:DRV () (setq oldsnap (getvar "osmode")) (command "ucs" "w") (setq pt1 (getpoint "\npick point 1 left side of driveway:")) (setq pt1 (list (car pt1)(cadr pt1) 0.0)) ; rip z elevation out (setq pt2 (getpoint "\npick point 2 right side of driveway:")) (setq pt2 (list (car pt2)(cadr pt2) 0.0)) (setq dist (distance pt1 pt2)) (setq ang (angle pt1 pt2)) (setq pt3 (polar pt1 ang (/ dist 2.0))) ;1/2 way between drive (setq obj (entsel "\nPick back of kerb line")) (setvar "osmode" 0) (setq objtype (cdr (assoc 0 (entget (car obj))))) (IF (or (= objtype "POLYLINE")(= objtype "LWPOLYLINE")) (progn (setq objpt (cadr obj)) (princ "\nNow exploding polyline that was picked :") (command "explode" obj "") (setq ss (ssget objpt)) (setq obj2 (entget (ssname ss 0))) ) (setq obj2 (entget (car obj))) ; else is linepl ) ;start point of line (princ "\nEnter new width of driveway or press enter to accept existing :") (princ dist) (setq newdist (getreal "...")) (setq pt10 (cdr (assoc 10 obj2))) (setq pt10 (list (car pt10)(cadr pt10) 0.0)) ; rip z elevation out (princ pt10) ;end point of line (setq pt11 (cdr (assoc 11 obj2))) (setq pt11 (list (car pt11)(cadr pt11) 0.0)) ; rip z elevation out (princ pt11) (setq ang3 (angle pt10 pt3)) (setq ang4 (angle pt10 pt11)) (setq dist3 (distance pt3 pt10)) ;may need a check here to ensure angle is always under 90 1.5707 (setq angdiff (- ang3 ang4)) ; use cos(ang) = o/h to cal perp point (setq dist4 (* (cos angdiff) dist3)) (setq pt4 (polar pt10 ang4 dist4)) (setq dist2 (+ (distance pt3 pt4)10.0 )) (setq ang2 (angle pt3 pt4)) (if (= newdist nil)(setq newdist dist)) (setq halfdist (/ newdist 2.0)) (setq ang3 (+ ang 3.1417)) (setq pt5 (polar pt3 ang halfdist)) (setq pt6 (polar pt3 ang3 halfdist)) (setq pt7 (polar pt5 ang2 dist2)) (setq pt8 (polar pt6 ang2 dist2)) (setq pt9 (inters pt10 pt11 pt5 pt7)) (setq pt12 (inters Pt10 pt11 pt6 pt8)) (setq dist4 (- (distance pt5 pt9) 0.3)) ; shorten kerbs by 0.3m (setq ang1 (angle pt5 pt9)) (setq pt13 (polar pt5 ang1 dist4)) (setq dist4 (- (distance pt6 pt12) 0.3)) (setq pt14 (polar pt6 ang1 dist4)) (command "line" pt5 pt13 pt14 pt6 "") ; draw driveway (setq ang2 (angle pt12 pt9)) (setq ang3 (angle pt9 pt12)) (setq pt15 (polar pt9 ang2 0.6)) (setq pt16 (polar pt12 ang3 0.6)) (command "break" pt15 pt16) (command "line" pt15 pt13 "") (command "line" pt16 pt14 "") (setvar "osmode" oldsnap) (setq obj nil) ;(setq obj2 nil) (setq ss nil) ) ;end defun (princ) ) Quote
Lee Mac Posted April 28, 2010 Posted April 28, 2010 Did you include the recursive EntnexttoEnd function I provided? Quote
BIGAL Posted April 29, 2010 Author Posted April 29, 2010 Hi Lee thanks for the suggestion, my fault the problem is actually in the break command, if its a pline doesn't work but if you run the line (command "break" pt15 pt16) at the command line works perfectly, always works for a line so all the points are being calculated correctly. Quote
alanjt Posted April 29, 2010 Posted April 29, 2010 Hi Lee thanks for the suggestion, my fault the problem is actually in the break command, if its a pline doesn't work but if you run the line (command "break" pt15 pt16) at the command line works perfectly, always works for a line so all the points are being calculated correctly. Try replacing with: (command "break" "_non" pt15 "_non" pt16) Might be as simple as your running OSnaps are screwing with things. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.