1
CAD General / Re: Batch Find & Replace Text AutoCAD 2023
« Last post by Lee Mac on Today at 12:46:23 PM »Try setting LISPSYS to 0.
(defun c:split3dpolysegs ( / *error* getvertices unit d cmd uf s plx pl vl a b dd n sd nvl k )
(or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com))
(defun *error* ( m )
(if uf
(if command-s
(command-s "_.UCS" "_P")
(vl-cmdf "_.UCS" "_P")
)
)
(if cmd
(setvar (quote cmdecho) cmd)
)
(if m
(prompt m)
)
(princ)
)
(defun getvertices ( c / i p plst )
(setq i -1)
(while (<= (setq i (1+ i)) (vlax-curve-getendparam c))
(setq p (vlax-curve-getpointatparam c i))
(setq plst (cons p plst))
)
(reverse plst)
)
(defun unit ( v / d )
(if (not (equal (setq d (distance (list 0.0 0.0 0.0) v)) 0.0 1e-6))
(mapcar (function (lambda ( x ) (/ x d))) v)
)
)
; (setq d 1) ;;; initial setting - change to suit your needs ;;;
(setq cmd (getvar (quote cmdecho)))
(setvar (quote cmdecho) 0)
(if (= 0 (getvar (quote worlducs)))
(progn
(if command-s
(command-s "_.UCS" "_W")
(vl-cmdf "_.UCS" "_W")
)
(setq uf t)
)
)
(initget 7)
(setq
d (getreal "\nEnter Max Distance between Polyline Vertices : "
)
)
(prompt "\nPick reference 3D polyline...")
(if (setq s (ssget "_+.:E:S" (list (cons 0 "POLYLINE") (cons -4 "<or") (cons 70 8) (cons 70 9) (cons -4 "or>"))))
(progn
(setq plx (entget (setq pl (ssname s 0))))
(setq vl (getvertices pl))
(while (setq b (cadr vl))
(if (< d (setq dd (distance (setq a (car vl)) b)))
(progn
(setq n (fix (/ dd d)))
(setq sd (/ dd n))
(setq nvl (cons a nvl))
(setq k 0)
(repeat n
(setq nvl (cons (mapcar (function +) a (mapcar (function *) (unit (mapcar (function -) b a)) (list (* (setq k (1+ k)) sd) (* k sd) (* k sd)))) nvl))
)
(setq vl (cdr vl))
)
)
)
(setq a (car nvl))
(setq nvl (cdr nvl))
(if (not (vlax-curve-isclosed pl))
(setq nvl (cons a nvl))
)
(setq nvl (reverse nvl))
(vl-cmdf "_.3DPOLY")
(foreach v nvl
(vl-cmdf "_non" v)
)
(if (vlax-curve-isclosed pl)
(while (< 0 (getvar (quote cmdactive)))
(vl-cmdf "_C")
)
(while (< 0 (getvar (quote cmdactive)))
(vl-cmdf "")
)
)
)
)
(*error* nil)
)