Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/20/2022 in all areas

  1. ; Equation Graph by autolisp - 2022.06.20 exceed ; command list : yx1, yx2, yx3, yx4, yx5, yx6, y2x2 (circle) ; not a complete routine just for fun ; https://www.cadtutor.net/forum/topic/75463-equation-graph-by-autolisp/ ; If it's for your homework, it's not a good choice to use it. ; Use a program that draws accurate graphs. matlab, etc. Excel is also good. (defun c:yx1 ( / a b startx endx steps deltax ptlist pt mspace tmp myobj ylist ) (princ "\n y = Ax + B ") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq startx (getreal "\n Input Start X = ")) (setq endx (getreal "\n Input End X = ")) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (* a x) b)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ylist (vl-sort ylist '<)) (setq ymin (car ylist)) (setq ymax (last ylist)) (setq ptlist (reverse ptlist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis startx endx ymin ymax steps) (princ) ) (defun c:yx2 ( / a b c startx endx steps deltax ptlist pt mspace tmp myobj ylist ) (princ "\n y = Ax^2 + Bx + C") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq c (getreal "\n Input C = ")) (setq startx (getreal "\n Input Start X = ")) (setq endx (getreal "\n Input End X = ")) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (* a x x) (* b x) c)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ylist (vl-sort ylist '<)) (setq ymin (car ylist)) (setq ymax (last ylist)) (setq ptlist (reverse ptlist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis startx endx ymin ymax steps) (princ) ) (defun c:yx3 ( / a b c d startx endx steps deltax ptlist pt mspace tmp myobj ylist ) (princ "\n y = Ax^3 + Bx^2 + Cx + D") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq c (getreal "\n Input C = ")) (setq d (getreal "\n Input D = ")) (setq startx (getreal "\n Input Start X = ")) (setq endx (getreal "\n Input End X = ")) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (* a x x x) (* b x x) (* c x) d)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ylist (vl-sort ylist '<)) (setq ymin (car ylist)) (setq ymax (last ylist)) (setq ptlist (reverse ptlist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis startx endx ymin ymax steps) (princ) ) (defun c:yx4 ( / a b c d e startx endx steps deltax ptlist pt mspace tmp myobj ylist ) (princ "\n y = Ax^4 + Bx^3 + Cx^2 + Dx + E ") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq c (getreal "\n Input C = ")) (setq d (getreal "\n Input D = ")) (setq e (getreal "\n Input E = ")) (setq startx (getreal "\n Input Start X = ")) (setq endx (getreal "\n Input End X = ")) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (* a x x x x) (* b x x x) (* c x x) (* d x) e)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ylist (vl-sort ylist '<)) (setq ymin (car ylist)) (setq ymax (last ylist)) (setq ptlist (reverse ptlist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis startx endx ymin ymax steps) (princ) ) (defun c:yx5 ( / a b c d e f startx endx steps deltax ptlist pt mspace tmp myobj ylist ) (princ "\n y = Ax^5 + Bx^4 + Cx^3 + Dx^2 + Ex + F ") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq c (getreal "\n Input C = ")) (setq d (getreal "\n Input D = ")) (setq e (getreal "\n Input E = ")) (setq f (getreal "\n Input F = ")) (setq startx (getreal "\n Input Start X = ")) (setq endx (getreal "\n Input End X = ")) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (* a x x x x x) (* b x x x x) (* c x x x) (* d x x) (* e x) f)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ylist (vl-sort ylist '<)) (setq ymin (car ylist)) (setq ymax (last ylist)) (setq ptlist (reverse ptlist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis startx endx ymin ymax steps) (princ) ) (defun c:yx6 ( / a b c d e f g startx endx steps deltax ptlist pt mspace tmp myobj ylist ) (princ "\n y = Ax^6 + Bx^5 + Cx^4 + Dx^3 + Ex^2 + Fx + G ") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq c (getreal "\n Input C = ")) (setq d (getreal "\n Input D = ")) (setq e (getreal "\n Input E = ")) (setq f (getreal "\n Input F = ")) (setq g (getreal "\n Input G = ")) (setq startx (getreal "\n Input Start X = ")) (setq endx (getreal "\n Input End X = ")) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (* a x x x x x x) (* b x x x x x) (* c x x x x) (* d x x x) (* e x x) (* f x) g)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ylist (vl-sort ylist '<)) (setq ymin (car ylist)) (setq ymax (last ylist)) (setq ptlist (reverse ptlist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis startx endx ymin ymax steps) (princ) ) (defun c:y2x2 ( / a b c startx endx steps deltax ptlist pt mspace tmp myobj xlist ylist xmin xmax ymin ymax ) (princ "\n (x - A)^2 + (y - B)^2 = C^2") (setq a (getreal "\n Input A = ")) (setq b (getreal "\n Input B = ")) (setq c (getreal "\n Input C = ")) (setq startx (- a c)) (setq endx (+ a c)) (setq steps 100) (cond ((<= startx endx) (setq x startx) ) ((> startx endx) (setq x endx) (setq endx startx) (setq startx x) ) ) (setq deltax (/ (- endx startx) steps)) (setq xlist '()) (setq ylist '()) (setq ptlist '()) (repeat (+ steps 1) (setq y (+ (sqrt (abs (- (+ (- (* c c) (* x x)) (* 2 a x)) (* a a)))) b)) (setq xlist (cons x xlist)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq ptlist (reverse ptlist)) (setq x startx) (repeat (+ steps 1) (setq y (+ (sqrt (abs (- (+ (- (* c c) (* x x)) (* 2 a x)) (* a a)))) b)) (setq y (- (* 2 b) y)) (setq xlist (cons x xlist)) (setq ylist (cons y ylist)) (setq pt (list x y 0.0)) (setq ptlist (cons pt ptlist)) (setq x (+ x deltax)) ) (setq xlist (vl-sort xlist '<)) (setq ylist (vl-sort ylist '<)) (setq xmin (car xlist)) (setq xmax (last xlist)) (setq ymin (car ylist)) (setq ymax (last ylist)) ; https://www.afralisp.net/archive/methods/list/addpolyline_method.htm (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq ptlist (apply 'append ptlist)) (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) (vlax-put-property myobj 'color 3) (ex:drawaxis xmin xmax ymin ymax steps) (princ) ) (defun ex:drawaxis ( xmin xmax ymin ymax steps / deltax xaxisline yaxisline xaxisarrow1 xaxisarrow2 xaxisarrow3 xaxisarrow4 yaxisarrow1 yaxisarrow2 yaxisarrow3 yaxisarrow4 xaxistext1 xaxistext2 yaxistext1 yaxistext2 ) (setq deltax (/ (- xmax xmin) steps)) (setq xaxisline (vla-addline mspace (vlax-3d-point (list (- xmin (* (/ steps 10) deltax)) 0 0))(vlax-3d-point (list (+ xmax (* (/ steps 10) deltax)) 0 0)))) (setq yaxisline (vla-addline mspace (vlax-3d-point (list 0 (- ymin (* (/ steps 10) deltax)) 0))(vlax-3d-point (list 0 (+ ymax (* (/ steps 10) deltax)) 0)))) (setq xaxisarrow1 (vla-addline mspace (vlax-3d-point (list (- xmin (* (/ steps 20) deltax)) (- 0 (* (/ steps 100) deltax)) 0))(vlax-3d-point (list (- xmin (* (/ steps 10) deltax)) 0 0)))) (setq xaxisarrow2 (vla-addline mspace (vlax-3d-point (list (- xmin (* (/ steps 20) deltax)) (+ 0 (* (/ steps 100) deltax)) 0))(vlax-3d-point (list (- xmin (* (/ steps 10) deltax)) 0 0)))) (setq xaxisarrow3 (vla-addline mspace (vlax-3d-point (list (+ xmax (* (/ steps 20) deltax)) (- 0 (* (/ steps 100) deltax)) 0))(vlax-3d-point (list (+ xmax (* (/ steps 10) deltax)) 0 0)))) (setq xaxisarrow4 (vla-addline mspace (vlax-3d-point (list (+ xmax (* (/ steps 20) deltax)) (+ 0 (* (/ steps 100) deltax)) 0))(vlax-3d-point (list (+ xmax (* (/ steps 10) deltax)) 0 0)))) (setq yaxisarrow1 (vla-addline mspace (vlax-3d-point (list (- 0 (* (/ steps 100) deltax)) (- ymin (* (/ steps 20) deltax)) 0))(vlax-3d-point (list 0 (- ymin (* (/ steps 10) deltax)) 0)))) (setq yaxisarrow2 (vla-addline mspace (vlax-3d-point (list (+ 0 (* (/ steps 100) deltax)) (- ymin (* (/ steps 20) deltax)) 0))(vlax-3d-point (list 0 (- ymin (* (/ steps 10) deltax)) 0)))) (setq yaxisarrow3 (vla-addline mspace (vlax-3d-point (list (- 0 (* (/ steps 100) deltax)) (+ ymax (* (/ steps 20) deltax)) 0))(vlax-3d-point (list 0 (+ ymax (* (/ steps 10) deltax)) 0)))) (setq yaxisarrow4 (vla-addline mspace (vlax-3d-point (list (+ 0 (* (/ steps 100) deltax)) (+ ymax (* (/ steps 20) deltax)) 0))(vlax-3d-point (list 0 (+ ymax (* (/ steps 10) deltax)) 0)))) (setq xaxistext1 (vla-AddText mspace "+x" (vlax-3d-point (list (+ xmax (* (/ steps 8) deltax)) 0 0)) (* (/ steps 20) deltax))) (vlax-put-property xaxistext1 'alignment 9) (setq xaxistext2 (vla-AddText mspace "-x" (vlax-3d-point (list (- xmin (* (/ steps 8) deltax)) 0 0)) (* (/ steps 20) deltax))) (vlax-put-property xaxistext2 'alignment 11) (setq yaxistext1 (vla-AddText mspace "-y" (vlax-3d-point (list 0 (- ymin (* (/ steps 8) deltax)) 0)) (* (/ steps 20) deltax))) (vlax-put-property yaxistext1 'alignment 7) (setq yaxistext2 (vla-AddText mspace "+y" (vlax-3d-point (list 0 (+ ymax (* (/ steps 8) deltax)) 0)) (* (/ steps 20) deltax))) (vlax-put-property yaxistext2 'alignment 13) (setq bar (* (/ steps 10) deltax)) (setq barlen (/ bar 6)) (setq index2 0) (repeat 11 (setq xbar (vla-addline mspace (vlax-3d-point (list (+ xmin (* bar index2)) barlen 0))(vlax-3d-point (list (+ xmin (* bar index2)) (* barlen -1) 0)))) (setq xbartext (vla-AddText mspace (rtos (+ xmin (* bar index2)) 2 0) (vlax-3d-point (list (+ (+ xmin (* bar index2)) (/ barlen 2)) (- 0 (/ barlen 2)) 0)) (/ (* (/ steps 20) deltax) 2))) (vlax-put-property xbartext 'alignment 6) (setq index2 (+ index2 1)) ) (setq index2 0) (repeat 11 (setq ybar (vla-addline mspace (vlax-3d-point (list barlen (+ ymin (* bar index2)) 0))(vlax-3d-point (list (* barlen -1) (+ ymin (* bar index2)) 0)))) (setq ybartext (vla-AddText mspace (rtos (+ ymin (* bar index2)) 2 0) (vlax-3d-point (list (- 0 (/ barlen 2)) (+ (+ ymin (* bar index2)) (/ barlen 4)) 0)) (/ (* (/ steps 20) deltax) 2))) (vlax-put-property ybartext 'alignment 14) (setq index2 (+ index2 1)) ) ) command list yx1 - linear equation y = Ax + B yx2 - quadratic equation y = Ax^2 + Bx + C yx3 - cubic equation y = Ax^3 + Bx^2 + Cx + D yx4 - biquadratic equation y = Ax^4 + Bx^3 + Cx^2 + Dx + E yx5 - quintic equation y = Ax^5 + Bx^4 + Cx^3 + Dx^2 + Ex + F yx6 - 6th y = Ax^6 + Bx^5 + Cx^4 + Dx^3 + Ex^2 + Fx + G y2x2 - circle equation (x-a)^2 + (y-b)^2 = c^2 This is a simple routine that just connects points with polylines and no curves. This is not an exact graph.
    2 points
  2. You could also use the MOCORO (Express Tool) command.
    1 point
  3. Came at it a bit different. used entsel as to limit the selection to one entity (assumes if multiple are selected with ssget they will all have different angles) since limited to one entity selections use while function to allow user to repeat command. like using the copy command with pauses so the user can see the entity moving. like @Steven P did with this. ;;----------------------------------------------------------------------------;; ;; Copy, Scale, & Rotate Entity (defun C:FOO (/ ss pt1 pt2 ang s) (while (setq ent (entsel "\nSelect entity: ")) (setvar 'cmdecho 0) (command "_.Undo" "Be") (setvar 'cmdecho 1) (command ".copy" ent "" pause pause) (setvar 'cmdecho 0) (setq pt1 (getvar 'lastpoint) pt2 (getpoint pt1 "\nHorizontal alignment: ") ang (- (angle pt1 pt2)) ) (command "_.rotate" (entlast) "" pt1 (* (/ ang pi) 180.0)) (setq s (getreal "\nScale Factor: ")) (command "_.scale" (entlast) "" pt1 s) ) (command "_.Undo" "E") (setvar 'cmdecho 1) (princ) )
    1 point
  4. yes, LW is in 'parent' list, thank you again for your explanation
    1 point
  5. I based this on somebody's code that combines a copy with align. Link in the code. Command SCS (for Copy Scale) - set scale. - select polyline. (if you want it will permit you to select multiple objects) Then select 3 points (see attached picture) - point 2 is the source base. - point 3 is the base point of the destination. - point 4. that's the end of your long line. It will be set horizontal on the destination. The distance of that long line will be used to calculate the scale of the pasted object. ;; based on c:COPYALIGN ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/combining-copy-amp-align-command/m-p/800575/highlight/true#M26233 ;; ;; Copy SCale (defun c:CSC (/ sc sSet P11 P12 P21 P22 1st 2nd) (setq sc (getreal "\Set scale factor: ")) ;;Combines COPY and ALIGN commands ;;by Jim Smith 2002 (or(member "geom3d.arx" (arx))(arxload "geom3d" nil)) (command "_.undo" "_be") (setq sSet (ssget)) (if sSet (progn (setq P11 (getpoint "Specify first source point: ") P12 (getpoint P11 "\nSpecify first desintation point: ") 1st (cons 256 (list P11 P12)) ) (grvecs 1st) (setq P21 (getpoint "\nSpecify second source point: ") ;; now we calculate P22. P22 is horizontal to the right of P12. ;; how much to the right? distance of P11-P21 X the scale factor ;; (polar pt ang dist) P22 (polar P12 0.0 (* sc (distance P11 P21))) 2nd (cons 256 (list P21 P22)) ) (grvecs 2nd) (command "_.COPY" sSet "" "0,0,0" "@") (align sSet P11 P12 P21 P22 "" "Y") ) ) (setq sSet nil) (grvecs (list P11 P12)) (grvecs (list P21 P22)) (command "_.undo" "_e") (princ) )
    1 point
  6. A quick modification to the link I posted, Same result, slightly different method to exceed - though a blatant copy here for the 'cond' part of his code. (defun c:layerElev ( / ss i pline elevation MyColour) (setq ss (ssget '((0 . "LWPOLYLINE")))) (if ss (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) pline (ssname ss i) elevation (cdr (assoc 38 (entget pline))) ) (cond ((= (rem elevation 5) 0)(setq MyColour 1)) ((= (rem elevation 1) 0)(setq MyColour 2)) ((= (rem elevation 0.5) 0)(setq MyColour 3)) (t (setq MyColour 1)) ) (command "chprop" pline "" "c" MyColour "") ) ) ) (princ) )
    1 point
  7. ; ELPOLY - 2022.06.20 exceed ; https://www.cadtutor.net/forum/topic/75461-help-lisp-set-color-for-polyline-based-on-elevation/ ; change lwpolyline's color by it's elevation ; 0, 5, 10, 15, 20... - change to red ; 1, 2, 3, 4, 5, 6, 7... - change to purple ; 1.5, 2.5, 3.5, 4.5, 5.5 ... - change to green ; 1.xxx, 2.xxx, 3.xxx ..... - change to green anyway ; if you want to change 4th option, just change ; (t ; (princ " , so change to green anyway") ; (vlax-put-property obj 'color 3) ; ) ; "3" of this part's after 'color. ; this is autocad indexed color number (vl-load-com) (defun c:ELPOLY ( / ss ssl index obj objelevation ) (if (setq ss (ssget ":L" '((0 . "LWPOLYLINE")))) (progn (setq ssl (sslength ss)) (setq index 0) (repeat ssl (setq obj (vlax-ename->vla-object (ssname ss index))) (setq objelevation (vlax-get-property obj 'elevation)) (princ "\n it's elevation is = ") (princ objelevation) (cond ((= (rem objelevation 5) 0) (princ " , so change to red") (vlax-put-property obj 'color 1) ) ((= (rem objelevation 1) 0) (princ " , so change to purple") (vlax-put-property obj 'color 6) ) ((= (rem objelevation 0.5) 0) (princ " , so change to green") (vlax-put-property obj 'color 3) ) (t (princ " , so change to green anyway") (vlax-put-property obj 'color 3) ) ) (setq index (+ index 1)) ) ) (progn (princ "\n there's nothing to change") ) ) (princ) ) you can start with this
    1 point
  8. 1 point
  9. ssget doesn't work on nested entity's you have to step through each xref's entity's one by one. and add them to a list if that match. This makes a copy of polylines you want and moves them outside the xref. (defun C:XREFEnts (/ blk NextEnt EntLst Lst) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (eq (vla-get-isXref blk) :vlax-true) (progn (setq blkname (cdr (assoc 2 (entget (vlax-vla-object->ename blk))))) (setq NextEnt (tblobjname "BLOCK" blkname)) (while (setq NextEnt (entnext NextEnt)) (setq Ent (entget NextEnt)) (if (and (wcmatch (cdr (assoc 0 Ent)) "LWPOLYLINE") (wcmatch (cdr (assoc 8 Ent)) (strcat blkname "|B-B-E--2"))) (setq Lst (cons (cdr (assoc -1 Ent)) Lst)) ) ) ) ) ) (command "_.ncopy" Lst "" "_non" '(0 0) "_non" '(0 0)) )
    1 point
  10. Why not just copy and paste all 3 into one lisp ? 1 Hint centroid can be 1 line of code using a inbuilt function. (setq obj (vlax-ename->vla-object (entlast))) (setq cpt (osnap (vlax-curve-getStartPoint obj) "gcen")) 2 lot of code for insert block ? Just check does exist if not make it as you only need 1 att. I would remove (getstring "\nName of block to insert: ") use a hard coded block name so exists in your DWT. 3 Lee's code is great but as you know the block that you inserted step 2 just edit the attribute with the field answer no need for a total 3rd program. The answer for the att string is in Lee's code. So the steps Select all plines making selection set Loop through selection Insert block at centroid Amend block attribute string value to field Repeat for all plines. Maybe 100 lines of code probably less. I have not posted any code as did you google "label area multiple pline autocad lisp"
    1 point
  11. It's the leader index since an mleader can have multiple leaders.
    1 point
×
×
  • Create New...