DAVID_OJEDA Posted March 8, 2023 Posted March 8, 2023 On 12/1/2010 at 10:46, tomjas said: Wiz - Eres mi heroe Gracias por tu ayuda Lee - Tú también eres mi héroe ¡El formateo funciona muy bien! Probablemente buscaré más propiedades, es decir. Altura del texto Si puede mirar el archivo stx.lsp, que he adjuntado, y busque 'inspiración' ya que esta rutina está haciendo esto Ustedes saben lo que significa '{' - Solo sé cómo cargar lsp a CAD stx.lsp 1,7 KB · 35 descargas Hello, I greet you with great pleasure and pleasure, while I ask for your help. The STX.lsp routine adds TEXT & MTEXT. they can modify it in such a way that it adds the TEXT or MTEXT. enclosed within a closed polyline. thanks for your help Quote
DAVID_OJEDA Posted March 8, 2023 Posted March 8, 2023 On 12/1/2010 at 5:56, tomjas said: Hola, Tengo 2 rutinas lisp: la primera es crear una etiqueta con el área de la escotilla seleccionada (como un campo de texto, por lo que si el área de la escotilla cambia, la etiqueta también cambiará). El segundo es crear una etiqueta con suma de números en textos seleccionados (como un texto estándar). Mi pregunta es: cómo editar la segunda rutina que, en lugar de crear una etiqueta como un texto estándar, creará una etiqueta usando un campo de texto, por lo que si las áreas cambian, la etiqueta con la suma de todas las áreas también cambiará. Gracias por la ayuda de antemano y perdon por mi mal ingles 1 - tarifa.zip 10,97 KB · 63 descargas 2 - stx.lsp 1,7 KB · 58 descargas Hello, I greet you with great pleasure, while I ask for your help. The STX.lsp routine adds TEXT & MTEXT. they can modify it in such a way that it adds the TEXT or MTEXT. enclosed within a closed polyline. thanks for your help Could it be done by selecting multiple polygons?. Thanks for your interest and help. EXAMPLE.dwg Quote
BIGAL Posted March 9, 2023 Posted March 9, 2023 (edited) Easy to do you want to count up items, the only issue is where to place the answer. If use geo centre on some shapes will go outside. Watch this space bit busy at moment But only a counter not a field answer. Edited March 9, 2023 by BIGAL Quote
DAVID_OJEDA Posted March 9, 2023 Posted March 9, 2023 Thanks for your attention. The center of the polygon is the ideal place. You can express the result circled in red with the "existing gain" layer. Quote
DAVID_OJEDA Posted March 9, 2023 Posted March 9, 2023 I currently use these two routines that I found on these forums, but I would like to speed up the process. stx.lsp wps.lsp Quote
BIGAL Posted March 10, 2023 Posted March 10, 2023 (edited) Working on something. Try this. ; ; https://www.cadtutor.net/forum/topic/17288-sum-text-strings-to-text-field/page/4/ ; Count object inside plines ; By AlanH March 2023 (defun ptnummakeblk ( / ) (entmake (list (cons 0 "BLOCK") (cons 2 "COUNTBUB") (cons 70 2) (cons 10 (list 0 0 0)) (CONS 8 "0") )) (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 40 3.25) ; rad (cons 210 (list 0 0 1)) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER") ) ) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 1 "1") ; default value (cons 2 "COUNTER") ; nblock name (cons 3 "Ptnum") ; tag name (cons 6 "BYLAYER") (cons 7 "STANDARD") ;text style (cons 8 "0") ; layer (cons 11 (list 0.0 0.0 0.0)) ; text insert pt (cons 39 0) (cons 40 3.5) ; text height (cons 41 1) ; X scale (cons 50 0) ; Text rotation (cons 51 0) ; Oblique angle (cons 62 256) ; by layer color (cons 70 0) (cons 71 0) ;Text gen flag (cons 72 1) ; Text Justify hor 1 center (cons 73 0) ; field length (cons 74 2) ; Text Justify ver 2 center (cons 210 (list 0 0 1)) )) (entmake (list (cons 0 "ENDBLK"))) (princ "\nBlock made ") (princ) ) (defun c:startshere ( / ) (if (tblsearch "BLOCK" "COUNTBUB") (princ "exists") (ptnummakeblk) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setvar 'attreq 1) (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "MANZANAS")(70 . 1)))) (command "zoom" "e") (if (= ss nil) (progn (alert "No objects found on layer MANZANAS ")(exit)) (progn (repeat (setq x (sslength ss)) (setq plent (ssname ss (setq x (1- x)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent)))) (setq cpt (mapcar '(lambda ( x ) (/ x (length co-ord))) (apply 'mapcar (cons '+ co-ord)))) (setq co-ord (cons (last co-ord) co-ord)) (setq ss2 (ssget "WP" co-ord '((0 . "ELLIPSE")))) (if (= ss2 nil) (princ "miss") (progn (setq cnt (sslength ss2)) (command "-insert" "countbub" "s" 1 cpt 0 (rtos cnt 2 0)) ) ) ) ) ) (setvar 'osmode oldsnap) (princ) ) (c:startshere) Edited March 11, 2023 by BIGAL Quote
DAVID_OJEDA Posted March 11, 2023 Posted March 11, 2023 17 hours ago, BIGAL said: Working on something. Try this. ; ; https://www.cadtutor.net/forum/topic/17288-sum-text-strings-to-text-field/page/4/ ; Count object inside plines ; By AlanH March 2023 (defun ptnummakeblk ( / ) (entmake (list (cons 0 "BLOCK") (cons 2 "COUNTBUB") (cons 70 2) (cons 10 (list 0 0 0)) (CONS 8 "0") )) (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 40 3.25) ; rad (cons 210 (list 0 0 1)) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER") ) ) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 1 "1") ; default value (cons 2 "COUNTER") ; nblock name (cons 3 "Ptnum") ; tag name (cons 6 "BYLAYER") (cons 7 "STANDARD") ;text style (cons 8 "0") ; layer (cons 11 (list 0.0 0.0 0.0)) ; text insert pt (cons 39 0) (cons 40 3.5) ; text height (cons 41 1) ; X scale (cons 50 0) ; Text rotation (cons 51 0) ; Oblique angle (cons 62 256) ; by layer color (cons 70 0) (cons 71 0) ;Text gen flag (cons 72 1) ; Text Justify hor 1 center (cons 73 0) ; field length (cons 74 2) ; Text Justify ver 2 center (cons 210 (list 0 0 1)) )) (entmake (list (cons 0 "ENDBLK"))) (princ "\nBlock made ") (princ) ) (defun c:startshere ( / ) (if (tblsearch "BLOCK" "COUNTBUB") (princ "exists") (ptnummakeblk) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setvar 'attreq 1) (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "MANZANAS")(70 . 1)))) (command "zoom" "e") (if (= ss nil) (progn (alert "No objects found on layer MANZANAS ")(exit)) (progn (repeat (setq x (sslength ss)) (setq plent (ssname ss (setq x (1- x)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent)))) (setq cpt (mapcar '(lambda ( x ) (/ x (length co-ord))) (apply 'mapcar (cons '+ co-ord)))) (setq co-ord (cons (last co-ord) co-ord)) (setq ss2 (ssget "WP" co-ord '((0 . "ELLIPSE")))) (if (= ss2 nil) (princ "miss") (progn (setq cnt (sslength ss2)) (command "-insert" "countbub" "s" 1 cpt 0 (rtos cnt 2 0)) ) ) ) ) ) (setvar 'osmode oldsnap) (princ) ) (c:startshere) Dear Bigal. Thank you for your help. It works excellent, but the labels to add have variable amounts. You can modify the routine, to add the numeric text quantities. I apologize for not being assertive in my request. Quote
BIGAL Posted March 11, 2023 Posted March 11, 2023 (edited) Ok its time for you to have a go at lisp, dont worry if get wrong just post here and we can help. (setq ss2 (ssget "WP" co-ord '((0 . "ELLIPSE")))) change to TEXT (setq cnt (sslength ss2)) becomes a loop (setq cnt 0.0) (repeat (setq x (sslength ss2)) get each item in selection set then get text value add text value to cnt ) If you look at code you can see a repeat example. Ps tested already is adding values but have a go 1st. Edited March 12, 2023 by BIGAL Quote
DAVID_OJEDA Posted March 12, 2023 Posted March 12, 2023 (edited) Hace 7 horas, BIGAL dijo: Ok, es hora de que pruebes lisp, no te preocupes si te equivocas, solo publica aquí y podemos ayudarte. Si observa el código, puede ver un ejemplo repetido. Ps probado ya está agregando valores, pero pruébalo primero. Bigal saludos cordiales desde México. Siento decir que no sé nada de programación. No sabría arreglar la rutina para que me diera el resultado esperado. Edited March 12, 2023 by DAVID_OJEDA Quote
BIGAL Posted March 13, 2023 Posted March 13, 2023 Post also in English please. Try this it is based on "X INFO" ; ; https://www.cadtutor.net/forum/topic/17288-sum-text-strings-to-text-field/page/4/ ; Count object inside plines ; By AlanH March 2023 (defun ptnummakeblk ( / ) (entmake (list (cons 0 "BLOCK") (cons 2 "COUNTBUB") (cons 70 2) (cons 10 (list 0 0 0)) (CONS 8 "0") )) (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 40 3.25) ; rad (cons 210 (list 0 0 1)) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER") ) ) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 1 "1") ; default value (cons 2 "COUNTER") ; nblock name (cons 3 "Ptnum") ; tag name (cons 6 "BYLAYER") (cons 7 "STANDARD") ;text style (cons 8 "0") ; layer (cons 11 (list 0.0 0.0 0.0)) ; text insert pt (cons 39 0) (cons 40 3.5) ; text height (cons 41 1) ; X scale (cons 50 0) ; Text rotation (cons 51 0) ; Oblique angle (cons 62 256) ; by layer color (cons 70 0) (cons 71 0) ;Text gen flag (cons 72 1) ; Text Justify hor 1 center (cons 73 0) ; field length (cons 74 2) ; Text Justify ver 2 center (cons 210 (list 0 0 1)) )) (entmake (list (cons 0 "ENDBLK"))) (princ "\nBlock made ") (princ) ) (defun c:startshere ( / ) (if (tblsearch "BLOCK" "COUNTBUB") (princ "exists") (ptnummakeblk) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setvar 'attreq 1) (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "MANZANAS")(70 . 1)))) (command "zoom" "e") (if (= ss nil) (progn (alert "No objects found on layer MANZANAS ")(exit)) (progn (repeat (setq x (sslength ss)) (setq plent (ssname ss (setq x (1- x)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent)))) (setq cpt (mapcar '(lambda ( x ) (/ x (length co-ord))) (apply 'mapcar (cons '+ co-ord)))) (setq co-ord (cons (last co-ord) co-ord)) (setq ss2 (ssget "WP" co-ord '((0 . "TEXT")))) (if (= ss2 nil) (princ "miss") (progn (setq cnt 0.0) (repeat (setq y (sslength ss2)) (setq ent (ssname ss2 (setq y (1- y)))) (setq val (atoi (cdr (assoc 1 (entget ent))))) (setq cnt (+ cnt val)) ) (command "-insert" "countbub" "s" 1 cpt 0 (rtos cnt 2 0)) ) ) ) ) ) (setvar 'osmode oldsnap) (princ) ) (c:startshere) Quote
DAVID_OJEDA Posted March 13, 2023 Posted March 13, 2023 5 hours ago, BIGAL said: Post also in English please. Try this it is based on "X INFO" ; ; https://www.cadtutor.net/forum/topic/17288-sum-text-strings-to-text-field/page/4/ ; Count object inside plines ; By AlanH March 2023 (defun ptnummakeblk ( / ) (entmake (list (cons 0 "BLOCK") (cons 2 "COUNTBUB") (cons 70 2) (cons 10 (list 0 0 0)) (CONS 8 "0") )) (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 40 3.25) ; rad (cons 210 (list 0 0 1)) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER") ) ) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 1 "1") ; default value (cons 2 "COUNTER") ; nblock name (cons 3 "Ptnum") ; tag name (cons 6 "BYLAYER") (cons 7 "STANDARD") ;text style (cons 8 "0") ; layer (cons 11 (list 0.0 0.0 0.0)) ; text insert pt (cons 39 0) (cons 40 3.5) ; text height (cons 41 1) ; X scale (cons 50 0) ; Text rotation (cons 51 0) ; Oblique angle (cons 62 256) ; by layer color (cons 70 0) (cons 71 0) ;Text gen flag (cons 72 1) ; Text Justify hor 1 center (cons 73 0) ; field length (cons 74 2) ; Text Justify ver 2 center (cons 210 (list 0 0 1)) )) (entmake (list (cons 0 "ENDBLK"))) (princ "\nBlock made ") (princ) ) (defun c:startshere ( / ) (if (tblsearch "BLOCK" "COUNTBUB") (princ "exists") (ptnummakeblk) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setvar 'attreq 1) (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "MANZANAS")(70 . 1)))) (command "zoom" "e") (if (= ss nil) (progn (alert "No objects found on layer MANZANAS ")(exit)) (progn (repeat (setq x (sslength ss)) (setq plent (ssname ss (setq x (1- x)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent)))) (setq cpt (mapcar '(lambda ( x ) (/ x (length co-ord))) (apply 'mapcar (cons '+ co-ord)))) (setq co-ord (cons (last co-ord) co-ord)) (setq ss2 (ssget "WP" co-ord '((0 . "TEXT")))) (if (= ss2 nil) (princ "miss") (progn (setq cnt 0.0) (repeat (setq y (sslength ss2)) (setq ent (ssname ss2 (setq y (1- y)))) (setq val (atoi (cdr (assoc 1 (entget ent))))) (setq cnt (+ cnt val)) ) (command "-insert" "countbub" "s" 1 cpt 0 (rtos cnt 2 0)) ) ) ) ) ) (setvar 'osmode oldsnap) (princ) ) (c:startshere) Bigal thank very much. I really appreciate your help. works excellent Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.