Leaderboard
Popular Content
Showing content with the highest reputation on 11/27/2024 in all areas
-
@Steven P Yeah, right now I am adding the formatting code in the text, but its a problem If you use it multiple times. It will currently just stack color codes in. I could search for them and remove old color codes, but the code could get a bit lengthy for this; it depends on the OP's intent. Another way would be to copy the style of the Mleader, then make a new style and set all the colors, then change the Mleader to the new style. There is probably some way to dig through the DXF codes to bypass the Mleader Style Text color, but I haven't had time yet to dig. EDIT - I think I found it - DXF code 90 in the context data. I'll have to try it and get back. I will still have to strip formatting color codes out of the text. This code keeps getting bigger LOL.2 points
-
You can not use that code this will always Fail its not supported in LT2024 25, you can not do a vlax-get-or-create-object (vlax-get-or-create-object "Excel.Application") Ok what will work is to write a csv file. Then read that file into Excel. Not sure if "Shell" function is supported, then can as last line start excel and open the csv. Try this change path and filename to one you have. If you dont have a csv just save one from Excel for test. (startapp "Excel.exe" "D:\\acadtemp\\tags.csv") Let us know if it works.2 points
-
just googled 'tip1566' make sure that this line : (setq DCL_ID (load_dialog "dimnote.dcl")) is used in the right way : - either dimnote.dcl lives in one of your support paths else add complete path to name in above line. - if you use the one from zipfile rename it to dimnote.dcl if you use your own lisp file because it looks for this name else it uses (exit) I would prefere to use (progn (alert "unable to load dialog")(exit)) you can't have enough / too much alert (or princ) functions in your apps to find out where somethings has gone wrong (usually , where you messed up) Tip1566.zip1 point
-
@Ashishs This is not perfect, but it attempts to strip out any color codes from the Text in the Mleader before replacing with the new color code. Try the updated code. ;|============================================================== dimcol.lsp by Phil Kenewell - 11/25/2024 Description: By request of a user on CADTutor.com https://www.cadtutor.net/forum/topic/94150-looking-for-a-lsp-to-select-a-dimension-in-the-drawing-and-change-the-color-to-red-for-any-type-of-dimension-be-it-a-rotated-aligned-or-angular/ This program allows you to change the color of all selected Dimensions and Leaders, QLeader, Mleaders. Last Update: 11/27/2024 = Added variable cl and (acad_colordlg) to select the color at start instead of hardcoding. ===============================================================|; (defun c:dimcol (/ cl co e e2 i l l2 n o ss tx) (vl-load-com) ;----------------------------- ;; Change this variable to Change the color. ACI color number integer: (setq cl 5); 1=RED, 2=YELLOW, 3=GREEN, 4=CYAN, 5=BLUE, 6=MAGENTA etc... ;(setq cl (acad_colordlg cl)); Alternately select color at beginning. ;--------------------------------------------------------------------- (command "._undo" "_Begin") (if (setq ss (ssget '((0 . "DIMENSION,*LEADER")))) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) l (entget e) ) (cond ((wcmatch (cdr (assoc 0 l)) "DIMENSION,LEADER,QLEADER") (command "._dimoverride" "_dimclre" cl "_dimclrd" cl "_dimclrt" cl "" e "") (if (assoc 340 l) (progn (setq l2 (entget (setq e2 (cdr (assoc 340 l))))) (if (assoc 62 l2) (progn (entmod (subst (cons 62 cl) (assoc 62 l2) l2))(entupd e2)) (progn (entmod (append l2 (list (cons 62 cl))))(entupd e2)) ) ) ) ) ((= (cdr (assoc 0 l)) "MULTILEADER") (if (assoc 62 l) (progn (entmod (subst (cons 62 cl) (assoc 62 l) l))(entupd e)) (progn (entmod (append l (list (cons 62 cl))))(entupd e)) ) (setq o (vlax-ename->vla-object e) co (vla-get-leaderlinecolor o) tx (vla-get-textstring o) ) (vla-put-colorindex co cl) (vla-put-leaderlinecolor o co) (while (wcmatch tx "*\\C*;*") (setq n 0) (repeat 257 (setq tx (vl-string-subst "" (strcat "\\C" (itoa n) ";") tx) n (1+ n) ) ) ) (vla-put-textstring o (strcat "\\C" (itoa cl) ";" tx) ) ) ) ) ) (command "._Undo" "_End") (princ) )1 point
-
Here is a handy translation guide for AutoCAD commands in several languages. The Spanish equivalent of EXTEND is ALARGA, and MOVE is DESPLAZA. Edit: Use the three dots in the upper right corner to pull up the menu. Edit will be on it.1 point
-
@Ashishs Try the updated code below. You can set the variable at the top (see comments in code) to the ACI color number (5 is BLUE) to what you want. (setq cl 5); 1=RED, 2=YELLOW, 3=GREEN, 4=CYAN, 5=BLUE, 6=MAGENTA etc... Optionally, you can uncomment the line below it (remove the ";" in front) to interactively select the color you want at the start. NOTE - this will not use RGB True colors or Colorbook colors, only ACI colors. ;|============================================================== dimcol.lsp by Phil Kenewell - 11/25/2024 Description: By request of a user on CADTutor.com https://www.cadtutor.net/forum/topic/94150-looking-for-a-lsp-to-select-a-dimension-in-the-drawing-and-change-the-color-to-red-for-any-type-of-dimension-be-it-a-rotated-aligned-or-angular/ This program allows you to change the color of all selected Dimensions and Leaders, QLeader, Mleaders. Last Update: 11/27/2024 = Added variable cl and (acad_colordlg) to select the color at start instead of hardcoding. ===============================================================|; (defun c:dimcol (/ cl co e e2 i l l2 o ss) ;----------------------------- ;; Change this variable to Change the color. ACI color number integer: (setq cl 5); 1=RED, 2=YELLOW, 3=GREEN, 4=CYAN, 5=BLUE, 6=MAGENTA etc... ;(setq cl (acad_colordlg cl)); Alternately select color at beginning. ;--------------------------------------------------------------------- (command "._undo" "_Begin") (if (setq ss (ssget '((0 . "DIMENSION,*LEADER")))) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) l (entget e) ) (cond ((wcmatch (cdr (assoc 0 l)) "DIMENSION,LEADER,QLEADER") (command "._dimoverride" "_dimclre" cl "_dimclrd" cl "_dimclrt" cl "" e "") (if (assoc 340 l) (progn (setq l2 (entget (setq e2 (cdr (assoc 340 l))))) (if (assoc 62 l2) (progn (entmod (subst (cons 62 cl) (assoc 62 l2) l2))(entupd e2)) (progn (entmod (append l2 (list (cons 62 cl))))(entupd e2)) ) ) ) ) ((= (cdr (assoc 0 l)) "MULTILEADER") (if (assoc 62 l) (progn (entmod (subst (cons 62 cl) (assoc 62 l) l))(entupd e)) (progn (entmod (append l (list (cons 62 cl))))(entupd e)) ) (setq o (vlax-ename->vla-object e) co (vla-get-leaderlinecolor o) ) (vla-put-colorindex co cl) (vla-put-leaderlinecolor o co) (vla-put-textstring o (strcat "\\C" (itoa cl) ";" (vla-get-textstring o) ) ) ) ) ) ) (command "._Undo" "_End") (princ) )1 point
-
Colours are set as numbers, 1 for red, 2 for blue and so on up to 256 for the index colour... so change colour '1' to whatever colour you want in the above. In pkenewells code you might be looking for lines such as: (vla-put-colorindex co 1) (progn (entmod (subst (cons 62 1) (assoc 62 l) l))(entupd e)) (progn (entmod (subst (cons 62 1) (assoc 62 l2) l2))(entupd e2)) (command "._dimoverride" "_dimclre" 1 "_dimclrd" 1 "_dimclrt" 1 "" e "") c:dimred to c:dimblue of course changing 1 to what you want it to be. If it was me for future versatility I might set the value, 1, above as a variable and set that variable at the start of the routine - that way you only need to make one change to change them all. Then you can just copy, paste, adjust to any colour you like. pkenewell... I might have something that changes leader text colour will have a think this afternoon Quick nentsel on a leader: (304 . "{\\C6;Here is a leader}") Colour code might be in the text1 point
-
I moved your thread to the AutoLISP, Visual LISP & DCL Forum. Please place your code in code tags!1 point
-
This solutions is working for me so far, even on the mulileaders. Thanks a lot.1 point
-
If the angle of the arc is alays less than 180 degrees, then use length = rad*angle so you can get angle if its more than 180 use PI in lisp, then reverse the order of the start and end points. Ie erase arc and do again. Its hard to tell what is correct so will leave it to you to test.1 point
-
See this page. You can add a formula to the field and use it to convert your number. If that doesn't work, please give us more information.1 point
-
@Ashishs OK. Multileaders are a bit harder. With the code below. I can set the leader line color different than the Mleaderstyle, but I don't know how to change the implicit color of the text (also set in the Mleaderstyle), other than to put a color formatting code into the text content. If someone else knows how to change the Text color outside of the Mleaderstyle, then I welcome their input. Try this new version: (defun c:dimred (/ co e e2 i l l2 o ss) (if (setq ss (ssget '((0 . "DIMENSION,*LEADER")))) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) l (entget e) ) (cond ((wcmatch (cdr (assoc 0 l)) "DIMENSION,LEADER,QLEADER") (command "._dimoverride" "_dimclre" 1 "_dimclrd" 1 "_dimclrt" 1 "" e "") (if (assoc 340 l) (progn (setq l2 (entget (setq e2 (cdr (assoc 340 l))))) (if (assoc 62 l2) (progn (entmod (subst (cons 62 1) (assoc 62 l2) l2))(entupd e2)) (progn (entmod (append l2 (list (cons 62 1))))(entupd e2)) ) ) ) ) ((= (cdr (assoc 0 l)) "MULTILEADER") (if (assoc 62 l) (progn (entmod (subst (cons 62 1) (assoc 62 l) l))(entupd e)) (progn (entmod (append l (list (cons 62 1))))(entupd e)) ) (setq o (vlax-ename->vla-object e) co (vla-get-leaderlinecolor o) ) (vla-put-colorindex co 1) (vla-put-leaderlinecolor o co) (vla-put-textstring o (strcat "\\C1;" (vla-get-textstring o) ) ) ) ) ) ) (princ) ) FWIW - with Mleaders, you could create a style that is all RED, then easily use properties to change the Mleader style.1 point
-
I think that AutoCAD 2024 LT don't support Visual LISP extension functions, only Vanilla LISP functions... So, I strongly suggest that you get rid of AutoCAD LT software and use just AutoCAD, or better yet BricsCAD if you are searching for speed of LISP routine execution...1 point
-
In the future please place your code in code tags. (<> in the editor toolbar)1 point
-
I've been experimenting with a method to give greater user control in the conversion of a 2D spline to a polyline. The following program enables the user to specify the maximum number of vertices for the resulting polyline from a selected spline. The program calculates the instantaneous radius of curvature for points along the spline. If the magnitude of the radius is above a specified threshold then a vertex for the polyline is not created at that point. The image below shows the results of using the splinedit commad (left column) and the program (right column). The radius of curvature is output to aid the user in determining an appropriate threshold for successive runs of the program. Note that the program creates vertices closer together where the spline radius is small and further apart for flatter sections of the spline. The splines are red and polylines yellow in the image below. (defun C:SmartSPL2POLY (/ spl ptList i n maxCurva smax ds s pOld der1 der2 d p ) ; Creates a polyline from a 2D spline. The user can control the number of vertices in ; the resulting polyline and omit vertices that have a radius of curvature greater ; than a specifed threshold. ; Lee Minardi 9/22/2024 ; (setq spl (car (entsel "\nSelect Spline.")) ptList nil i 0 n (getint "\nEnter maximum number of vertices for polyline: ") maxCurva (getreal "\nEnter maximum curvature: ") smax (vlax-curve-getEndParam spl) ds (/ smax n) s ds ) (setq pOld (vlax-curve-getPointAtParam spl 0.0)) (setq ptlist (list pOld)) (repeat (+ n 1) (setq der1 (vlax-curve-getfirstDeriv spl s) der2 (vlax-curve-getSecondDeriv spl s) ) ; calculate curvature at point p (setq d (distance '(0 0 0) (cross der1 der2))) (setq curva (/ (expt (distance '(0 0 0) der1) 3) d)) (princ "\nVertex #") (princ i) (princ " curvature = ") (princ curva) (if (< curva maxcurva) (setq p (vlax-curve-getPointAtParam spl s) ptList (append ptList (list p)) pOld p ) ) ; end if (setq i (1+ i) s (+ s ds) ) ) ; end repeat (setq p (vlax-curve-getPointAtParam spl smax) ptList (append ptList (list p)) ) (lwpoly ptList 0) (princ) ) (defun LWPoly (lst cls) ; Lee Mac's entmake functions (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls) ) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) ) ;;; Compute the cross product of 2 vectors a and b (defun cross (a b / crs) (setq crs (list (- (* (nth 1 a) (nth 2 b)) (* (nth 1 b) (nth 2 a)) ) (- (* (nth 0 b) (nth 2 a)) (* (nth 0 a) (nth 2 b)) ) (- (* (nth 0 a) (nth 1 b)) (* (nth 0 b) (nth 1 a)) ) ) ) )1 point
-
I have this, but the straighter parts also slightly arced. Works for my uses, if I have time, I'll look at something to make the straighter parts non-arcs. ;;; Convert 2D splines to polyline arcs. ;;; ;;; https://www.cadtutor.net/forum/topic/91181-convert-spline-to-polyline/?do=findComment&comment=651477 ;;; ;;; By SLW210 (Steve Wilson) ;;; ;;; (defun c:S2CP ( / ss i ent precision) (SETVAR "PLINECONVERTMODE" 1) (setq precision 5) ;; Set default precision (princ "\nSelect splines to convert to polylines: ") (setq ss (ssget '((0 . "SPLINE")))) ;; Ensure selection is valid (if (and ss (> (sslength ss) 0)) (progn (setq i 0) ;; Initialize counter ;; Loop through each selected spline (while (< i (sslength ss)) (setq ent (ssname ss i)) ;; Use the SPLINEDIT command with the correct options (command "_SPLINEDIT" ent "_P" precision) (setq i (1+ i)) ;; Increment counter ) (princ "\nSplines converted to polylines.") ) (princ "\nNo valid splines selected.") ) (princ) )1 point