Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/25/2022 in all areas

  1. What the error message is telling you: This line of code invokes a self written function findplotarea. (setq plotlist (findplotarea ss)) Somewhere in your original lisp file there's a (defun findplotarea ( ....) ... ) You need to find that function definition ( defun means define function ) and copy/paste it to your new .lsp file. ... And if that function uses other self written functions, then you copy/paste them too.
    2 points
  2. To understand these lisps you need to look at the ssget in each. ;;Locks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-true) ;;Unlocks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-false) ;; Lock All Viewports (SSVPLock (ssget "_X" '((0 . "VIEWPORT"))) :vlax-true) ;; Unlock All Viewports (SSVPLock (ssget "_X" '((0 . "VIEWPORT"))) :vlax-false) These then feed into the SSVPLock Function. looking at both locks has :vlax-true and both unlocks have :vlax-false Using this to update your first code (defun C:LAV (/ ss n vp); = Lock All Viewports (if (setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1)))) ;just filter out the paper space viewports with ssget. ;this is saying select all viewports in drawing (! except) the ones that 69 = 1 aka paper space (foreach vp (mapcar 'cadr (ssnamex SS)) ;this list all the entity names in selection set with out haveing to use repeat and (1- i) ;(foreach vp (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) ;this is needed if you use ssget with out the "X" modifier (vla-put-DisplayLocked (vlax-ename->vla-object vp) :vlax-true) ;to unlock set to ":vlax-false" ) ); if ); defun
    2 points
  3. You need a double backslash \\RV 0 and you don't need to check if it exists: (defun c:test nil (vl-mkdir (strcat (getvar "dwgprefix") "\\RV 0"))) Here is a quick example to make nested folders: (defun c:test (/ pre) (setq pre (getvar 'dwgprefix)) (foreach d '("\\RV 0" "\\RV 1" "\\RV 2") (vl-mkdir (setq pre (strcat pre d)))) )
    1 point
  4. It worked OK for just testing it, though I think it will fail if the text height isn't exactly what it is looking for - you'll need a fuzz factor Someone will be able to help out with that, not something I do much
    1 point
  5. Just had to fix a co workers pc make sure snaps is off F9 should toggle it on/off. This snaps your mouse to the points on the grid. Commands: Snap Grid
    1 point
  6. Maybe this? (defun c:foo nil (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= 0 (vlax-get b 'isxref)) (vlax-for a b (and (vlax-write-enabled-p a) (vlax-property-available-p a 'constantwidth) (<= (vla-get-constantwidth a) 0.1) (vla-put-constantwidth a 0) ) ) ) ) (princ) )
    1 point
  7. findplotarea is a function that you no longer have loaded. you need that for the rest of the lisp to work.
    1 point
  8. Here is final version... It should work as desired like you wanted... Regards, M.R. (defun c:pts_along_pipe_trees_by_length-new ( / preprocess process pt bp dd ch c ell xll pxx ) ; ell xll pxx - lexical globals (vl-load-com) (defun preprocess ( / ss ex i b vbl sa coords ) (if (setq ss (ssget "_A" (list (cons 0 "*POLYLINE")))) (foreach pl (vl-remove (function listp) (mapcar (function cadr) (ssnamex ss))) (if (or (= (cdr (assoc 90 (setq ex (entget pl)))) 1) (and (= (cdr (assoc 90 ex)) 2) (equal (cdr (assoc 10 ex)) (cdr (assoc 10 (reverse ex))) 1e-6) ) ) (entdel pl) ) (if (not (vlax-erased-p pl)) (progn (setq vbl nil) (setq i (1+ (fix (+ 0.1 (vlax-curve-getendparam pl))))) (while (<= 0 (setq i (1- i))) (setq vbl (cons (list (vlax-curve-getpointatparam pl (float i)) (if (not (vl-catch-all-error-p (setq b (vl-catch-all-apply (function vla-getbulge) (list (vlax-ename->vla-object pl) i))))) b)) vbl)) ) (setq vbl (vl-remove-if-not (function (lambda ( x ) (= (length (vl-remove-if (function (lambda ( y ) (equal (car x) y 1e-6))) (mapcar (function car) vbl))) (1- (length vbl))))) vbl)) (if (not (vl-position (cons 100 "AcDb3dPolyline") ex)) (progn (setq vbl (mapcar (function (lambda ( x ) (list (trans (car x) 0 (cdr (assoc 210 ex))) (cadr x)))) vbl)) (setq ex (subst (cons 90 (length vbl)) (assoc 90 ex) ex)) (setq ex (append (vl-remove-if (function (lambda ( x ) (vl-position (car x) (list 10 40 41 42 91 210)))) ex) (apply (function append) (mapcar (function (lambda ( x ) (list (cons 10 (car x)) (cons 40 0.0) (cons 41 0.0) (cons 42 (cadr x)) (cons 91 0.0)))) vbl)) (list (assoc 210 ex)))) (entupd (cdr (assoc -1 (entmod ex)))) ) (progn (setq sa (vlax-make-safearray vlax-vbDouble (cons 0 (1- (length (setq coords (apply (function append) (mapcar (function car) vbl)))))))) (vla-put-coordinates (vlax-ename->vla-object pl) (vlax-make-variant (vlax-safearray-fill sa coords))) ) ) ) ) ) ) ) (defun process ( dd pt / proclst makepoly processlst ss sss i el e pt d len f n par l p ) (defun proclst ( f len dd pt / par ddd ) (if (and (setq par (float (fix (vlax-curve-getparamatpoint e (trans pt 1 0))))) (setq pt (vlax-curve-getpointatparam e par)) ) (if f (progn (setq ddd (- dd (- len (vlax-curve-getdistatpoint e (trans (setq pt (trans pt 0 1)) 1 0))))) (setq processlst (cons (list ddd pt) processlst)) ) (progn (setq ddd (- dd (vlax-curve-getdistatpoint e (trans (setq pt (trans pt 0 1)) 1 0)))) (setq processlst (cons (list ddd pt) processlst)) ) ) ) ) (defun makepoly ( f e p c / polyprocess s ee pl1 pl2 vl i ) (defun polyprocess ( f e p c / ln ep i pbl par b ll lx a ex ) (setq ln (vlax-curve-getdistatparam e (setq ep (vlax-curve-getendparam e)))) (repeat (setq i (1+ (fix (+ 0.1 ep)))) (setq pbl (cons (list (vlax-curve-getpointatparam e (float (setq i (1- i)))) (if (not (vl-catch-all-error-p (setq b (vl-catch-all-apply (function vla-getbulge) (list (vlax-ename->vla-object e) i))))) b)) pbl)) ) (setq par (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e p))) (if (equal par ep 1e-6) (setq f t) ) (if f (progn (setq par (- ep par)) (setq pbl (mapcar (function (lambda ( x ) (list (car x) (if (cadr x) (- (cadr x)))))) (reverse pbl))) ) ) (if (setq b (cadr (nth (fix (+ par 1.000001)) pbl))) (progn (setq ll (if f (- (- ln (vlax-curve-getdistatparam e (float (fix par)))) (- ln (vlax-curve-getdistatparam e (float (fix (+ par 1.000001)))))) (- (vlax-curve-getdistatparam e (float (fix (+ par 1.000001)))) (vlax-curve-getdistatparam e (float (fix par)))))) (setq lx (if f (- (- ln (vlax-curve-getdistatparam e (float (fix par)))) (- ln (vlax-curve-getdistatparam e par))) (- (vlax-curve-getdistatparam e par) (vlax-curve-getdistatparam e (float (fix par)))))) (setq a (* 4.0 (atan b))) (setq b (/ (sin (/ (* (/ a ll) lx) 4.0)) (cos (/ (* (/ a ll) lx) 4.0)))) ) ) (setq pbl (reverse (member (nth (fix par) pbl) (reverse pbl)))) (setq pbl (append pbl (list (list p b)))) (setq ex (entget e)) (if (vl-some (function numberp) (mapcar (function cadr) pbl)) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length pbl)) (cons 70 (* 128 (getvar 'plinegen))) (assoc 38 ex) ) (apply (function append) (mapcar (function (lambda ( x ) (list (cons 10 (trans (car x) 0 (cdr (assoc 210 ex)))) (cons 42 (if (cadr x) (cadr x) 0.0))))) pbl)) (list (assoc 210 ex) (cons 62 c) ) ) ) (progn (vl-cmdf "_.3DPOLY") (foreach pb pbl (vl-cmdf "_non" (trans (car pb) 0 1)) ) (vl-cmdf "") (entupd (cdr (assoc -1 (entmod (if (assoc 62 (setq ex (entget (entlast)))) (subst (cons 62 c) (assoc 62 ex) ex) (append ex (list (cons 62 c)))))))) ) ) ) (setq xll (cons (setq pl1 (polyprocess f e p c)) xll)) (setq pxx (cons (progn (setq vl nil) (setq i (1+ (fix (+ 0.1 (vlax-curve-getendparam pl1))))) (while (<= 0 (setq i (1- i))) (setq vl (cons (vlax-curve-getpointatparam pl1 (float i)) vl)) ) ) pxx ) ) (if (and (not (equal (setq p (vlax-curve-getpointatparam pl1 0.0)) (trans bp 1 0) 1e-6)) (setq s (ssget "_C" (trans p 0 1) (trans p 0 1) (list (cons 0 "*POLYLINE")))) (> (sslength s) 1) ) (progn (gc) (if (ssmemb pl1 s) (ssdel pl1 s) ) (foreach x ell (if (and s (ssmemb x s)) (ssdel x s) ) ) (if (and s (> (sslength s) 0)) (setq ee (ssname s 0)) ) ) ) (if ee (progn (if (< (vlax-curve-getparamatpoint ee (trans bp 1 0)) (vlax-curve-getparamatpoint ee p)) (setq pl2 (polyprocess nil ee p c)) (setq pl2 (polyprocess t ee p c)) ) (vl-cmdf "_.PEDIT" "_M" (ssadd pl2 (ssadd pl1)) "" "_J" "" "") (if (vl-position pl1 xll) (setq xll (subst (entlast) pl1 xll)) (setq xll (cons (entlast) xll)) ) (setq pxx (cons (progn (setq vl nil) (setq i (1+ (fix (+ 0.1 (vlax-curve-getendparam (entlast)))))) (while (<= 0 (setq i (1- i))) (setq vl (cons (vlax-curve-getpointatparam (entlast) (float i)) vl)) ) ) pxx ) ) ) ) ) (if (setq ss (ssget "_C" (setq pt (osnap pt "_nea")) pt (list (cons 0 "*POLYLINE")))) (progn (gc) (repeat (setq i (sslength ss)) (if (and (not (vl-position (setq e (ssname ss (setq i (1- i)))) ell)) (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-curve-getstartpoint) (list e)))) (or (not (vl-some (function (lambda ( q ) (equal pt (trans q 0 1) 1e-6))) (apply (function append) pxx))) (and (setq sss (ssget "_C" pt pt (list (cons 0 "*POLYLINE")))) (progn (foreach x (append xll ell) (if (ssmemb x sss) (ssdel x sss) ) ) (and sss (> (sslength sss) 0)) ) ) ) ) (setq el (cons (list e pt) el)) ) ) (if el (progn (setq ell (append (vl-remove-if (function (lambda ( x ) (vl-position x xll))) (mapcar (function car) el)) ell)) (foreach ep el (setq f nil l nil) (setq e (car ep) pt (cadr ep)) (setq d (vlax-curve-getdistatpoint e (trans pt 1 0))) (setq len (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) (if (equal d len 1e-6) (setq d 0.0 f t) ) (setq n (fix (setq par (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e (trans pt 1 0)))))) (if f (foreach p (reverse (repeat n (setq l (cons (trans (vlax-curve-getpointatparam e (float (1+ (fix (setq par (1- par)))))) 0 1) l)))) (proclst f len dd p) ) (foreach p (reverse (repeat (- (fix (+ 0.1 (vlax-curve-getendparam e))) n) (setq l (cons (trans (vlax-curve-getpointatparam e (float (1- (fix (setq par (1+ par)))))) 0 1) l)))) (proclst f len dd p) ) ) (cond ( (and (zerop d) (= (cdr (assoc 90 (entget e))) 2) (if f (vlax-curve-getpointatdist e (- len dd)) (vlax-curve-getpointatdist e dd) ) ) (if f (progn (entmake (list (cons 0 "POINT") (cons 10 (setq p (vlax-curve-getpointatdist e (- len dd)))))) (if (= ch "Yes") (makepoly f e p c)) ) (progn (entmake (list (cons 0 "POINT") (cons 10 (setq p (vlax-curve-getpointatdist e dd))))) (if (= ch "Yes") (makepoly f e p c)) ) ) ) ( (<= 0.0 (+ d dd) len) (if f (progn (entmake (list (cons 0 "POINT") (cons 10 (setq p (vlax-curve-getpointatdist e (- len (+ d dd))))))) (if (= ch "Yes") (makepoly f e p c)) ) (progn (entmake (list (cons 0 "POINT") (cons 10 (setq p (vlax-curve-getpointatdist e (+ d dd)))))) (if (= ch "Yes") (makepoly f e p c)) ) ) ) ) ) ) ) (foreach lst processlst (process (car lst) (cadr lst)) ) ) ) ) (if (and (setq pt (getpoint "\nPick or specify main base point : ")) (setq bp pt) (not (initget 6)) (setq dd (cond ( (not (setq dd (getdist pt "\nPick or specify length from base point for spread around <1.0> : "))) 1.0 ) ( t dd ))) (not (initget "Yes No")) (setq ch (cond ( (not (setq ch (getkword "\nDo you want to overmake new polylines up to resulting points [Yes / No] <Yes> : "))) "Yes" ) ( t ch ))) (if (= ch "Yes") (progn (initget 6) (setq c (cond ( (not (setq c (getint "\nSpecify color for new polylines <3> : "))) 3 ) ( t c ))) ) t ) ) (progn (vla-zoomextents (vlax-get-acad-object)) (preprocess) (process dd pt) ) ) (princ) )
    1 point
  9. So update lido's code. ;;Changing the width of the polylines to zero if the ;;thickness of the polylines is less than zero (DEFUN C:POLY0 (/ ACDC SEL) (ssget "_X" '((0 . "*POLYLINE") (-4 . "<=") (39 . 0.1))) ;only select polylines that have widths less than or equal to 0.1 (setq ACDC (vla-get-activedocument (vlax-get-acad-object)) SEL (vla-get-activeselectionset ACDC)) (vlax-for Itm SEL (vla-put-constantwidth Itm 0) ) (princ) ) ;;C:POLY0
    1 point
  10. Autocad supports .wmf files,... clipart files with .wmf extension can imported into Autocad, they come in as outlines in true colour, can be trimmed and hatched, exploded etc. I used to do it a lot when I was bored and waiting for work.
    1 point
  11. You might have the Snap Mode on, if so then just press F9 to disable it.
    1 point
×
×
  • Create New...