scubastu Posted November 5, 2009 Posted November 5, 2009 I have a line with multiple lines at endpoint. Each of these lines have their own line coming off etc... From pt1 I able to collect the first and second lines through ssget as the assoc 10 of second = assoc 11 of first.. QUESTION.. Can I loop the ssget somehow to continue retrieving any lines or objects at the end of the second, third, fourth etc until there aren't any to get (e.g. = nil)? Thanks in advance Quote
SteveK Posted November 5, 2009 Posted November 5, 2009 Not that I know of. Though I'm sure you could ssget all the lines initially, then once you have the initial point (and I'm confused thinking about it) use a couple of nested while loops to find end points at start points until you run out. (I know it works for a single worm of lines cause I did it once to make a polyline, but I'm sure it'd be more complicated for multiple worms - the code I wrote is messy so I don't think it'd help you) Quote
scubastu Posted November 6, 2009 Author Posted November 6, 2009 Not that I know of. Though I'm sure you could ssget all the lines initially, then once you have the initial point (and I'm confused thinking about it) use a couple of nested while loops to find end points at start points until you run out. (I know it works for a single worm of lines cause I did it once to make a polyline, but I'm sure it'd be more complicated for multiple worms - the code I wrote is messy so I don't think it'd help you) Hi Steve, Thanks for replying! The response has been dismal. So your worm lisp followed more than two lines over a single path? if so Can I have a look at it please? Cheers Stu Quote
SteveK Posted November 6, 2009 Posted November 6, 2009 No, my worm lisp followed one line, and when it got to a place where it found two possible paths it asked the user to pick which one to continue; whereas you could open up another list or list of lists instead of asking the user. My code is amongst another program and it seriously is so messy you'd be better off just planning how your code will work (cause I have a feeling it could get messy (like mine) quickly) before trying to implement it. I can only give you this, which I called a few times within another loop, sending it the end point of a line and a list of start points of lines (if you don't want fuzz factor set it to 0). ;; Check against List of Co-ord's ;; ;; ;; ;; @param pt to check ;; ;; @param List of Co-Ordinates to check against ;; ;; @param fuzz factor ;; ;; @return Point if pt found in Co-ordinate List ;; (defun chk4pt (pt coordLst fuzz / tempLst nearPt) (setq tempLst coordLst) (while (and tempLst (not nearPt)) (if (equal (car tempLst) pt fuzz) (setq nearPt (car tempLst)) ) (setq tempLst (cdr tempLst)) );_ while nearPt ) ;; Quote
alanjt Posted November 6, 2009 Posted November 6, 2009 I must admit, I'm not sure I fully understand what you are wanting. Is this close? Quote
scubastu Posted November 8, 2009 Author Posted November 8, 2009 I must admit, I'm not sure I fully understand what you are wanting. Is this close?] Hi alanjt, Ok.. just got to see the animated picture.. only had the picture and nothing else yesterday. I think yes..if it could be nested into my lisp and I'd need to modify mine to work better with regards to moving original lines instead of drawing new lines and deleting the original. Instead of trying to explain my lisp here it is.. any advice or re-writing is welcome as I am new at lisp! (defun c:adj3 (/ mis sset tot num itm totdis hnd ent dis indx lobj disa dist) (setq oldcmd (getvar "cmdecho")) (setvar "cmdecho" 0) (setvar "osnapcoord" 1) (command "._layer" "_M" "Misclose" "") (command "._layer" "_C" "2" "Misclose" "") (setvar "clayer" "Misclose") (setq p1 (getpoint "n\Pick unadjusted end of Traverse") p2 (getpoint "n\Pick closing point")) (command "line" p1 p2 "") (setq mis (entlast)) (setq sset (ssget '((0 . "LINE")))) (if sset (progn (setq tot 0.0) (setq num (sslength sset) itm 0) (repeat num (while (< itm num) (setq hnd (ssname sset itm)) (setq ent (entget hnd)) (setq pt1 (cdr (assoc 10 ent))) (setq pt2 (cdr (assoc 11 ent))) (setq dis (distance pt1 pt2)) (setq tot (+ tot dis)) (setq itm (1+ itm)) ) ))) (if (= itm num) (setq totdis tot)) (if totdis (progn (setq tot 0.0) (setq len (sslength sset) indx 0) (while (< indx len) (setq lobj (ssname sset indx)) (setq objd (entget lobj)) (setq pt1 (cdr (assoc 10 objd))) (setq pt2 (cdr (assoc 11 objd))) (if (> indx 0) (setq pl1 pl2)) (setq dis (distance pt1 pt2)) (setq tot (+ tot dis)) (command ".erase" objd "") (command "._copy" mis "" p1 pt2) (setq obj (entlast)) (setq disa (distance p1 p2)) (setq dist (* (/ tot totdis) disa)) (command "._scale" obj "" pt2 "r" p1 p2 "P" dist) (command "._layer" "_M" "Traverse Adjusted" "") (command "._layer" "_C" "1" "Traverse Adjusted" "") (setvar "clayer" "Traverse Adjusted") (setq pl2 (cdr (assoc 11 (entget obj)))) (if (= indx 0) (command "._line" pt1 pl2 "")) (if (> indx 0) (command "._line" pl1 pl2 "")) (setq ins (ssget "_X" (list '(-4 . "=,=,*")(cons 10 pt2)(cons 0 "insert")))) (command "._move" ins "" pt2 Pl2) (if (> indx 0) (progn (setq rad (ssget "_X" (list '(-4 . "=,=,*")(cons 10 pt1)(cons 0 "LINE")))) (command "._move" rad "" pt1 pl1))) (command ".erase" obj "") (setq indx (1+ indx)) ) ) ) (command ".erase" mis "") (command ".erase" sset "") (princ) ) Thanks again Bowditch.dwg Quote
CAB Posted November 8, 2009 Posted November 8, 2009 This may be of some interest: http://www.theswamp.org/index.php?topic=12069 Quote
scubastu Posted November 9, 2009 Author Posted November 9, 2009 This may be of some interest:http://www.theswamp.org/index.php?topic=12069 Thanks CAB, but it was a little beyond my capabilities! I did think about using plines but each Line has an angle attached on the properties which I like at quick glance. 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.