Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/30/2023 in all areas

  1. Ok my take on question 1 redid code to cater for text color is by layer. There is no 62 dxf for bylayer. (defun c:textprop( / textobj textinfo textvalue textcolor textlayer) (setq textobj (ssname (ssget "_+.:E:S" (list (cons 0 "TEXT,MTEXT"))) 0)) (if (= textobj nil) (alert "A text type object was not picked ") (progn (setq textinfo (entget textobj)) (setq textvalue (cdr (assoc 1 textinfo))) (setq textheight (cdr (assoc 40 textinfo))) (setq textlayer (cdr (assoc 8 textinfo))) (if (= (setq textcolor (cdr (assoc 62 textinfo))) nil) (alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight 2 1) "\nColor: " "Bylayer" "\nLayer: " textlayer)) (alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight 2 1) "\nColor: " (rtos textcolor 2 0) "\nLayer: " textlayer)) ) ) ) (princ) ) (c:textprop) Re do a color need a cond. So replace the 2nd Alert with a cond, have a go. Inside a progn so 2nd alert still works inside that progn. Noticed the 1st attempt did not have the cdr's. If your happy can use "*TEXT" but it will find Dtext and Rtext. But we never used them so maybe ok. I have a get properties lisp, just pick an object and you determine what you want returned so for say a circle would be centre point and radius, like you for a text return what is needed, there is another lisp out there that returns more items than I have done. Pline line arc props.lsp
    2 points
  2. Wow, you are amazing, that means, thank you so much for your help
    1 point
  3. (setq l '("A-4" "A-5")) (setq ssl (ssget "_X" (list '(8 . "A-*") '(-4 . "<NOT") (cons 8 (apply 'strcat (mapcar '(lambda (x) (strcat x ",")) l))) '(-4 . "NOT>") '(410 . "Model") ) ) )
    1 point
  4. @pkenewell for sure , my first ACAD was 2.16 on a AT , circa 1991 . amber screen .
    1 point
  5. I found several problems and confusion with your code so I just rewrote it. Give this a try (minimally tested): NOTES: I changed variable names for 1) don't make variable names the same as an existing command, and 2) keep them shorter; they take up less memory. (defun c:MTP (/ cEnt elst txt clr ss i txtsz) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB")) ) (progn (setq elst (entget cEnt) txt (assoc 1 elst) ; Get Text content clr (cond ((assoc 62 elst))(T '(62 . 256))); Get ACI color txtsz (assoc 40 elst) ; get text size ) (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (repeat (setq i (sslength ss)) (setq elst (entget (ssname ss (setq i (1- i)))) ;Get Entity List elst (subst txt (assoc 1 elst) elst) ;Substitute test content in elist elst (if (assoc 62 elst) (subst clr (assoc 62 elst) elst)(append elst (list clr))) ;Substitute ACI color in elist elst (if (assoc 40 elst) (subst txtsz (assoc 40 elst) elst)(append elst (list txtsz))) ;substitute Text Height in elist ) (entmod elst) ; Modify new list ) ) ) ) (command "_regenall") (princ) )
    1 point
  6. I noticed you have been trying to have a go so some hints (defun c:d200 Get pt1 pt2 the dim points ask for a 3rd point for direction in or out. Near to pt1. You can use the angle pt1 pt2 to work out 2 new offset points say from pt1 at 90 angle to the points, the closest distance to the pt3 is the one to use. ie the new pt4 Use (command "dim" "align" pt1 pt2 pt4 "" "exit") Just redo pt4 again for second dim (command "dim" "align" pt1 pt2 pt4 "" "exit") Have ago we are here to help.
    1 point
  7. Ok this is version 1 for plines with straights only. Ver 2 would add circles, ver 3 would add ellipses and ver 4 would add plines with arcs. (defun c:wow ( / plent co-ord ss tot txt) (setq plent (entsel "\nPick pline ")) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))) (setq co-ord (cons (last co-ord) co-ord)) (setq ss (ssget "WP" co-ord '(( 0 . "*TEXT")))) (setq tot 0.0) (if (= ss nil) (alert "No text selected will now exit ") (repeat (setq x (sslength ss)) (setq txt (cdr (assoc 1 (entget (ssname ss (setq x (1- x))))))) (setq tot (+ (atof txt) tot)) ) ) (alert (strcat "Total is " (rtos tot 2 2 ) " for " (rtos (sslength ss) 2 0) " Items")) (princ) ) (c:wow) I think this is being missed will fix next version.
    1 point
  8. Coming along way @AeJay for only 22 posts. to simplify things (setq textobj (ssname (ssget "_+.:E:S" (list (cons 0 "TEXT,MTEXT"))) 0)) (if (= textobj nil) >> (if (setq textobj (ssname (ssget "_+.:E:S" (list (cons 0 "TEXT,MTEXT"))) 0)) or (if textobj with two or more string side by side you can just join them into one ...(rtos textheight 2 1) "\nColor: " "Bylayer" "\nLayer: " textlayer)) ...(rtos textheight 2 1) "\nColor: Bylayer \nLayer: " textlayer)) I think your code would error or not display if selecting text that its color isn't 1-7 again from above join strings into one. ((= nColor 1)(strcat "\nColor: " "RED")) can just be ((= nColor 1) "\nColor: RED") My code keeps everything in a list. so their is only the selection set and the data variable. Entget ((-1 . <Entity name: 3eed7ec0>) (0 . "TEXT") (5 . "71") (330 . <Entity name: 3e488ae0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (62 . 1) (370 . -1) (100 . "AcDbText") (10 5.59944594793636 4.30743710947954 0.0) (40 . 0.2) (1 . "asdfasdfsdaf") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 0)) Becomes (8 . "0") (62 . 1) (40 . 0.2) (1 . "asdfasdfsdaf") Then values are put into list data '("0" 1 0.2 "asdfasdfsdaf") '(Layer color height textstring) finally (defun c:ttp (/ ss data) (while (setq ss (ssget "_+.:E:S" '((0 . "TEXT,MTEXT")))) ;while to allow you to keep selecting in the same command. (setq data (mapcar 'cdr (vl-remove-if-not '(lambda (x) (or (= (car x) 1) (= (car x) 40) (= (car x) 62) (= (car x) 8))) (entget (ssname ss 0))))) (if (= (length data) 3) (alert (strcat "Text: " (last data) "\nHeight: " (rtos (cadr data) 2 2) "\nColor: ByLayer \nLayer: " (car data))) (alert (strcat "Text: " (last data) "\nHeight: " (rtos (caddr data) 2 2) (cond ((= (cadr data) 1) "\nColor: RED") ((= (cadr data) 2) "\nColor: YELLOW") ((= (cadr data) 3) "\nColor: GREEN") ((= (cadr data) 4) "\nColor: CYAN") ((= (cadr data) 5) "\nColor: BLUE") ((= (cadr data) 6) "\nColor: MAGENTA") ((= (cadr data) 7) "\nColor: WHITE") (t (strcat "\nColor: " (itoa (cadr data)))) ;their are over 256 colors so if it isn't the first 7 display number ) "\nLayer: " (car data))) ) ) (princ) )
    1 point
  9. Regarding int to color. I am again having the stringp nil error with this code I tried: (defun c:textprop( / textobj textinfo textvalue textcolor textlayer nColor) (setq textobj (ssname (ssget "_+.:E:S" (list (cons 0 "TEXT,MTEXT"))) 0)) (if (= textobj nil) (alert "A text type object was not picked ") (progn (setq textinfo (entget textobj)) (setq textvalue (cdr (assoc 1 textinfo))) (setq textheight (cdr (assoc 40 textinfo))) (setq textlayer (cdr (assoc 8 textinfo))) (if (= (setq textcolor (cdr (assoc 62 textinfo))) nil) (alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight 2 1) "\nColor: " "Bylayer" "\nLayer: " textlayer)) (alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight 2 1) (setq nColor(itoa textcolor)) (cond ((= nColor 1)(strcat "\nColor: " "RED")) ((= nColor 2)(strcat "\nColor: " "YELLOW")) ((= nColor 3)(strcat "\nColor: " "GREEN")) ((= nColor 4)(strcat "\nColor: " "CYAN")) ((= nColor 5)(strcat "\nColor: " "BLUE")) ((= nColor 6)(strcat "\nColor: " "MAGENTA")) ((= nColor 7)(strcat "\nColor: " "WHITE")) ) "\nLayer: " textlayer)) ) ) ) (princ) ) I also tried with same error of stringp nil: (defun c:textpropz( / textobj textinfo textvalue textcolor textlayer nColor) (setq textobj (ssname (ssget "_+.:E:S" (list (cons 0 "TEXT,MTEXT"))) 0)) (if (= textobj nil) (alert "A text type object was not picked ") (progn (setq textinfo (entget textobj)) (setq textvalue (cdr (assoc 1 textinfo))) (setq textheight (cdr (assoc 40 textinfo))) (setq textlayer (cdr (assoc 8 textinfo))) (if (= (setq textcolor (cdr (assoc 62 textinfo))) nil) (alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight 2 1) "\nColor: " "Bylayer" "\nLayer: " textlayer)) (alert (strcat "Text contents: " textvalue "\nHeight: " (rtos textheight 2 1) (setq nColor(itoa textcolor)) (cond ((equal nColor 1)("\nColor: " "RED")) ((equal nColor 2)("\nColor: " "YELLOW")) ((equal nColor 3)("\nColor: " "GREEN")) ((equal nColor 4)("\nColor: " "CYAN")) ((equal nColor 5)("\nColor: " "BLUE")) ((equal nColor 6)("\nColor: " "MAGENTA")) ((equal nColor 7)("\nColor: " "WHITE")) ) "\nLayer: " textlayer)) ) ) ) (princ) )
    1 point
  10. Another way to do this is create a copy then use the break command. Guess that would only work on closed polylines though.
    1 point
  11. @AeJay The error comes from this line (entmod (subst textSize (assoc 40 elst) elst)) Not know how to fix If you look earlier in the code: "textSize (cdr (assoc 40 elst))" returns only the value and not the association list. You have to plug the value back in as an equivalent dotted pair, so change: "(entmod (subst textSize (assoc 40 elst) elst))" to "(entmod (subst (cons 40 textSize) (assoc 40 elst) elst))" ALTERNATELY, you can just change: "textSize (cdr (assoc 40 elst))" to "textSize (assoc 40 elst)"
    1 point
  12. is this method done in all layout one by one?
    1 point
  13. Slightly off topic, for me Electrical Single Lines I make up a blank layout via a LISP and add the texts in after, something that could be done here but would need a change of philosophy from having the data in the format above. Was just posting this to amuse RLX.... made this up a while ago, the output below contains the default texts - something that would never be in a finished drawing and is easy to spot if I miss something:
    1 point
  14. Not sure if this is what you want but my appie returns this : BlockByBlock.lsp
    1 point
  15. My Sincere Greetings to Everyone ((Room walls Unfold )) please I want to add a new mission To complete the interest in the quantity of the room Files have been attached The target 1-After the program completes the basic mission ، The user is asked to write the name of the room. 2-The user is asked to choose the closed object to find area and perimeter , as indicated by color 3-The user is asked to choose the closed objects to find cumultive area of walls , as indicated by color 4-The user is asked to choose the closed objects to find cumultive area of windows , as indicated by color 5-The user is asked to choose the closed objects to find cumultive area of doors , as indicated by color 6-The user is asked to pick the doors widths point to find cumultive width of doors , as indicated by points and color 7-finaly , lisp generate table after ask text hight , with informations , as shown in figuer attached . Anyway, my expectations are great Thank you for your cooperation and assistance room-unfold.lsp
    1 point
×
×
  • Create New...