scubastu
28th Oct 2009, 05:56 am
Hi learned friends,
Achieve what exactly?
Here's my lisp.. it is a modified linesum lisp. My idea was, after drawing a circuit with lines, not closed (with a misclose), to apply this loop as an adjustment to apply to each line to make it a closed circuit of individual lines, by selecting each line in order after picking the misclose points. I may be going about all wrong but please let me know if so. So it works by drawing a misclose line at the end of each traverse line. Then scale it by dividing the length (from start upto the end of the line where the misclose line is drawn) with the total of all lengths of line(<---problem) ...times (*) the misclose distance picked at the start.
The problem
Variable totdis, total distance of all lines, is null or equal to tot until end of loop but I need it within the loop to scale each line without having to select it again (minimum finger clicking (and thinking) required). It worked when the Lisp was run without the scale baggage as the variable was "full". Can I leap frog to get the total of all lines and then step back to the loop?
or
Can I store all new misclose lines into a set to go back and scale them all by the length of the line they are associated with (the line that precedes it from the first set). This is probably the way but not sure how to go about it. It will need storing of the indx along with Length of line to scale each one correctly.. then there are the base point problems which all change.
All I want to do is align each traverse line to the end point of the new adjustment line then make the start of the next one the same as the end of the last..:? ...create a new unbroken repositioned square from a broken square.
(defun c:adjust()
(setq oldcmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "osnapcoord" 1)
(setq p1 (getpoint "n\Pick unadjusted end of Traverse")
p2 (getpoint "n\Pick closing point or start of Traverse"))
(command "line" p1 p2 "")
(setq mis (entlast))
(setq sset (ssget '((0 . "LINE"))))
(if sset
(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)))
(setq dis (distance pt1 pt2))
(setq tot (+ tot dis))
(setq indx (1+ indx))
(command "._layer" "_M" "Misclose" "")
(command "._layer" "_C" "2" "Misclose" "")
(setvar "clayer" "Misclose")
(command "._copy" mis "" p1 pt2)
(setq obj (entlast))
(setq disa (distance p1 p2))
(if (= indx len) (setq totdis tot))
(setq dist (* (/ tot totdis) disa))
(command "._scale" obj "" pt2 "r" p1 p2 "p" dist)
)
)
)
)
thanks in advance.
Stu
Achieve what exactly?
Here's my lisp.. it is a modified linesum lisp. My idea was, after drawing a circuit with lines, not closed (with a misclose), to apply this loop as an adjustment to apply to each line to make it a closed circuit of individual lines, by selecting each line in order after picking the misclose points. I may be going about all wrong but please let me know if so. So it works by drawing a misclose line at the end of each traverse line. Then scale it by dividing the length (from start upto the end of the line where the misclose line is drawn) with the total of all lengths of line(<---problem) ...times (*) the misclose distance picked at the start.
The problem
Variable totdis, total distance of all lines, is null or equal to tot until end of loop but I need it within the loop to scale each line without having to select it again (minimum finger clicking (and thinking) required). It worked when the Lisp was run without the scale baggage as the variable was "full". Can I leap frog to get the total of all lines and then step back to the loop?
or
Can I store all new misclose lines into a set to go back and scale them all by the length of the line they are associated with (the line that precedes it from the first set). This is probably the way but not sure how to go about it. It will need storing of the indx along with Length of line to scale each one correctly.. then there are the base point problems which all change.
All I want to do is align each traverse line to the end point of the new adjustment line then make the start of the next one the same as the end of the last..:? ...create a new unbroken repositioned square from a broken square.
(defun c:adjust()
(setq oldcmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "osnapcoord" 1)
(setq p1 (getpoint "n\Pick unadjusted end of Traverse")
p2 (getpoint "n\Pick closing point or start of Traverse"))
(command "line" p1 p2 "")
(setq mis (entlast))
(setq sset (ssget '((0 . "LINE"))))
(if sset
(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)))
(setq dis (distance pt1 pt2))
(setq tot (+ tot dis))
(setq indx (1+ indx))
(command "._layer" "_M" "Misclose" "")
(command "._layer" "_C" "2" "Misclose" "")
(setvar "clayer" "Misclose")
(command "._copy" mis "" p1 pt2)
(setq obj (entlast))
(setq disa (distance p1 p2))
(if (= indx len) (setq totdis tot))
(setq dist (* (/ tot totdis) disa))
(command "._scale" obj "" pt2 "r" p1 p2 "p" dist)
)
)
)
)
thanks in advance.
Stu