need help with lisp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello everyone,
I have work that needs to create the starting vertex of a polyline inside the contour not outside, I have a lisp but when I load it into AutoCAD it appears an error message (; error: syntax error), please can someone help me for this :
(defun c:polyInsideContour (/ pt obj) (setq obj (car (entsel "\nSelect the region boundary: "))) (if (not (eq 'closed (cdr (assoc 70 (entget obj))))) (princ "\nSelected object is not a closed polyline.") (setq pt (getpoint "\nSpecify starting point inside the region: ")) (if (inRegion obj pt) (progn (command "_.pline" "_Non" pt "") ; create the polyline with no vertices (setq pline (entlast)) ; select the last object (the polyline) (if (inRegion pline pt) (command (strcat "_Polyline" " " "C" " " pt " "))) ; add a vertex at the starting point (entdel pline) (princ "\nStarting point must be inside the region.") ) (princ "\nStarting point must be inside the region.") ) ) ) (defun inRegion (obj pt) (setq res 0) (if (and (eq 'closed (cdr (assoc 70 (entget obj)))) (eq "LWPOLYLINE" (cdr (assoc 0 (entget obj))))) (progn (setq vertices (cdr (assoc 10 (entget obj)))) (setq n (length vertices)) (setq j (- n 1)) (setq x pt) (setq x1 (car vertices)) (repeat n (setq x2 (car (nth j vertices))) (setq y2 (cadr (nth j vertices))) (setq y1 (cadr (nth (- j 1) vertices))) (if (> y1 y2) (setq tmp y1 y1 y2 y2 tmp)) (if (and (<= y1 x) (< y2 x) (< x2 x)) (if (/= tmp 0) ; check if point is on the edge (setq res (- res 1))) (setq j (- j 1)) ) ) (princ "\nSelected object is not a closed LWPOLYLINE.") (setq res 0) ) (if (< (abs res) 1) ; check if point is inside or outside the region (setq inside T) (setq inside nil) ) inside )