Hello again!
This is the next part in the project that I have to submit next Monday and I'm having problems (again..!!)
So now, I have to lag a wall (polyline) 20cm outwards of the selected polyline.
I was pretty confident with my script but it's not working...
(defun c:decalage_voile()
;decalage means lag in french 😉
;créaion d'un nouveau calque
(command "_.layer" "N" "decalage" "")
(command "_.layer" "E" "decalage" "")
(setq contour_polyligne (car (entsel "Please select a polyline :")))
(setq defpolyligne (entget contour_polyligne))
(if (/= (cdr (assoc 8 defpolyligne)) "Polyligne_Concrete")
(prompt "\nYou havent selected a polyline")
);endif
(prompt "okko")
(foreach rec defpolyligne
(if (= (car rec)10)
(setq CoordPoly (cdr rec))
(append CoordPoly);on concatène la liste
(print "ok1")
(setq cpt 0)
(while i < (length (* CoordPoly 2))
(setq Xcoord (nth (* 2 i) CoordPoly))
(setq Ycoord (nth ((+ 1 (* 2 i) CoordPoly))))
(princ Xcoord)
(princ Ycoord)
(setq cpt (1+ cpt))
);while
);endif
);foreach
);fin defun
Thanks guys !!
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@Anonymous wrote:
....
So now, I have to lag a wall (polyline) 20cm outwards of the selected polyline.
.... it's not working.......
(foreach rec defpolyligne
(if (= (car rec)10)
(setq CoordPoly (cdr rec))
(append CoordPoly);on concatène la liste
(print "ok1")
(setq cpt 0)
(while i < (length (* CoordPoly 2))
(setq Xcoord (nth (* 2 i) CoordPoly))
(setq Ycoord (nth ((+ 1 (* 2 i) CoordPoly))))
(princ Xcoord)
(princ Ycoord)
(setq cpt (1+ cpt))
);while
....
I'm not sure what "lag" means in this case, and don't see anything related to 20cm in the code, but I see some errors.
The (append) function needs more than one argument -- you need to append something to something else. If CoordPoly is supposed to be all vertex coordinates in one list, there are more direct ways to get that, but in this context I think you want something like:
(if (= (car rec)10)
(setq CoordPoly (append CoordPoly (cdr rec)))
There does not seem to be any setting of the i variable. Is that supposed to be cpt instead?
The CoordPoly variable will be a list of two numbers [X & Y coordinates of a vertex] as written, or more if you take my suggestion above. You can't multiply a list times a number, so (* CoordPoly 2) is invalid.
I expect the test in the (while) function should be something like:
(while (<= i (/ (length CoordPoly) 2))
[or probably with cpt instead of i]