Jump to content

SELECT TEXTS OTHER THAN 3.5..HELP


Recommended Posts

Posted

hello guys:

I need a selection filter to select texts and mtext other than 3.5 in size

try this code from Master Lee 

(ssget '((0 . "CIRCLE") (-4 . "<>") (40 . 5.0)))

modified

 

(defun c:pru (/ ss )
(ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) 
  (princ)
)

 

 

I need to identify texts other than 3.5 with some color.

 

help please  thanks

 

 

Posted (edited)
7 hours ago, leonucadomi said:

hello guys:

I need a selection filter to select texts and mtext other than 3.5 in size

 

Try this: 

;; Modified by DV. Visit my page at: https://lispautocad.gumroad.com/

(defun c:PRU (/ ss)
  (if (setq ss (ssget '((0 . "TEXT,MTEXT") (-4 . "<>") (40 . 3.5))))
    (progn
      (sssetfirst nil ss)
      (princ (strcat "\nSelecting: " (itoa (sslength ss)) " objects."))
    )
    (princ "\nNo Object.")
  )
  (princ)
)

 

Edited by DATVO
  • Thanks 1
Posted
7 hours ago, DATVO said:

 

Try this: 

;; Modified by DV. Visit my page at: https://lispautocad.gumroad.com/

(defun c:PRU (/ ss)
  (if (setq ss (ssget '((0 . "TEXT,MTEXT") (-4 . "<>") (40 . 3.5))))
    (progn
      (sssetfirst nil ss)
      (princ (strcat "\nSelecting: " (itoa (sslength ss)) " objects."))
    )
    (princ "\nNo Object.")
  )
  (princ)
)

 

I ALREADY TRIED IT AND IT SELECTED THEM ALL FOR ME, I DON'T KNOW WHAT HAPPENS

:(

My purpose is to detect all texts that do not have a desired height, in this case 3.5

Posted
(defun c:pru2 ( / ss alturaColor colorNuevo)
  (setq alturaColor 3.5) ; Define la altura a verificar
  (setq colorNuevo 1)  ; Define el color a aplicar (ej. rojo)
  (setq ss (ssget "X" '((0 . "TEXT,MTEXT")))) ; Selecciona todos los textos
  (if ss
    (progn
      (setq i 0)
      (while (setq en (ssname ss i))
        (setq obj (vlax-ename->vla-object en))
        (if (/= (vla-get-height obj) alturaColor)
          (vlax-put-property obj 'color colorNuevo) ; Cambia el color
        )
        (setq i (1+ i))
      )
    )
  )
  (princ)
)

This routine does what I need, but it has a problem that I cannot understand, I have objects in the paperspace that have a height of 3.5 and it recognizes them as if they did not have it and changes them to red. :(

can someone help? thanks

Posted (edited)

This

 

(ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) 

 

should work. You can change "TEXT" to "*TEXT" to also capture MText

 

Though looking at the code you have, I am assuming that is just a snippet of what you want to do. Here are a couple of hints:

(defun c:pru ( / ss )   ;;Yup localised variables, C: prompt, all good
  (setq ss (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) ) ;; ADDED (SETQ SS ... ) so that you can use the selection set later

  (princ (sslength ss)) ;; Added this in to show the result of the selection set

  (princ)               ;;Exit quietly
)

 

Edited by Steven P
  • Agree 1
  • Thanks 1
Posted
6 hours ago, Steven P said:

This

 

(ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) 

 

should work. You can change "TEXT" to "*TEXT" to also capture MText

 

Though looking at the code you have, I am assuming that is just a snippet of what you want to do. Here are a couple of hints:

(defun c:pru ( / ss )   ;;Yup localised variables, C: prompt, all good
  (setq ss (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) ) ;; ADDED (SETQ SS ... ) so that you can use the selection set later

  (princ (sslength ss)) ;; Added this in to show the result of the selection set

  (princ)               ;;Exit quietly
)

 

thanks, 

now I explain

In the modelspace I have texts of different height

in paperspace 

in the paperspace I have viewports of different scales

If I use the chspace command and take those texts to paper space they should be 3.5 height

I'm looking for a routine that helps me detect which texts do not meet that height in each viewport

 

(defun c:test (/ EscVP StrScale2 StrScale)


 (setq old_err *error*)(defun *error* ( a / )(princ "") (setq *error* old_err)(princ))
(setvar "cmdecho" 0) 
(if (and (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) 
(= (cdr (assoc 0 (entget EntVP))) "VIEWPORT")) 
(progn 
(setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP)))
(setq StrScale2 (rtos (* 3.5 (/ 1 EscVP)) 2 1)) 
(setq StrScale (rtos (/ 1 EscVP) 2 2)
) 

(setq vpnum (cdr (assoc 69 (entget EntVP ) )  ) )
(vl-cmdf "_.mspace")
(setvar "CVPORT" vpnum)

 (setq ss (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) )


(Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale))
(princ "\nLos textos de 3.5 en el interior de la ventana deben ser de: ")
(princ StrScale2)

) 
)
(setvar "cmdecho" 1)
(princ) 

  );fin defun

I am looking to enter this calculated value here

image.thumb.png.878194e871fb83dc0d6034b5a7ddbf92.png

 

but it doesn't work :(

 

Posted

Hi

I think it would be easier to find the problem if you attached an example drawing.

Posted (edited)

To enter the value into your selection set see below. In LISP the '( ... ) lists mean it is a static list, it is read exactly as it is written, (list ... ) means that CAD will create the list if for example variables are a part of the list, and (cons ... ), also used to create a list - in this case relevant to create a dotted pair.

 

(setq MyThing 5)

'(1 2 3 4 MyThing) is read as 1 2 3 4 MyThing - and an error since it is looking for MyThing to be a string, "MyThing"

(list 1 2 3 4 MyThing) is read as 1 2 3 4 5 - list has been created by the LISP

(cons 1 MyThing) is read as (1 . 5)

 

So this might help...

 

As above though you select the text with the selection set ss, but haven't done anything with it - if you are a part way through the LISP that is all good, but just put a report in so you can see it is working as it should as you go along perhaps (sslength SS) maybe.

 

(Oh, just me, I also amended the indents, and added where commands end if over a few lines, I find it easier to read LISPs as below, that's all)

 

(defun c:test (/ old_err EscVP StrScale2 TxtHt StrScale ss)

  (setq old_err *error*)

  (defun *error* ( a / ) ;; Add here return cmdecho to as it was, cmdecho 1
    (princ "")
    (setq *error* old_err)
    (princ)
  ) ; End Error Defun

  (setvar "cmdecho" 0) ; perhaps record the state of cmdecho before here, and reset to that value at the end
  (if (and 
      (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) 
      (= (cdr (assoc 0 (entget EntVP))) "VIEWPORT")
    ) ; end and
    (progn 
      (setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP)))
      (setq StrScale2 (rtos (* 3.5 (/ 1 EscVP)) 2 1))


      (setq TxtHt (* 3.5 (/ 1 EscVP)) ) ; a number not a string ;; added this


      (setq StrScale (rtos (/ 1 EscVP) 2 2))
      (setq vpnum (cdr (assoc 69 (entget EntVP ))))
      (vl-cmdf "_.mspace")
      (setvar "CVPORT" vpnum)


      (setq ss (ssget (list(0 . "TEXT") (-4 . "<>") (cons 40 TxtHt))) )


;;What are you doing with ss now?


      (Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale))
      (princ "\nLos textos de 3.5 en el interior de la ventana deben ser de: ")
      (princ StrScale2)
    ) ; end progn
  ) ; end if
  (setvar "cmdecho" 1)
  (princ) 

);fin defun

 

Edited by Steven P

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...