Jump to content

Recommended Posts

Posted

hello all:

I need a routine that first asks me to enter "a word"

and this word is added to the value of the dimension below the line

example

image.thumb.png.4131b4db3da4a4c9a699827f2c03b260.png

 

The modified dimension shows this

image.png.2c0bd50b3317175973052196e144208e.png

 

 

Does anyone know of any code that can help me?

 

 

thanks

Posted

Here's a quick one -

(defun c:dimsub ( / enx grp idx new pos sel str )
    (cond
        (   (= "" (setq str (getstring t "\nSpecify string: "))))
        (   (setq sel (ssget "_:L" '((0 . "*DIMENSION"))))
            (repeat (setq idx (sslength sel))
                (setq idx (1- idx)
                      enx (entget (ssname sel idx))
                      grp (assoc 1 enx)
                )
                (if (setq pos (vl-string-search "\\X" (cdr grp)))
                    (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str)))
                    (setq new (cons 1 (strcat "<>\\X" str)))
                )
                (entmod (subst new grp enx))
            )
        )
    )
    (princ)
)

 

  • Thanks 1
Posted
7 minutes ago, Lee Mac said:

Here's a quick one -

(defun c:dimsub ( / enx grp idx new pos sel str )
    (cond
        (   (= "" (setq str (getstring t "\nSpecify string: "))))
        (   (setq sel (ssget "_:L" '((0 . "*DIMENSION"))))
            (repeat (setq idx (sslength sel))
                (setq idx (1- idx)
                      enx (entget (ssname sel idx))
                      grp (assoc 1 enx)
                )
                (if (setq pos (vl-string-search "\\X" (cdr grp)))
                    (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str)))
                    (setq new (cons 1 (strcat "<>\\X" str)))
                )
                (entmod (subst new grp enx))
            )
        )
    )
    (princ)
)

 

i will try master thanks

Posted

EXCELLENT...

You can make it so that by default it suggests the word "typ" so that with just one enter I can continue the routine and if in the future I need to add another word I can change it.

Posted
36 minutes ago, leonucadomi said:

You can make it so that by default it suggests the word "typ" so that with just one enter I can continue the routine and if in the future I need to add another word I can change it.


For a "fixed" default, you can use something like the following:

(defun c:dimsub ( / enx grp idx new pos sel str )
    (if (= "" (setq str (getstring t "\nSpecify string <TYP>: ")))
        (setq str "TYP")
    )
    (if (setq sel (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat (setq idx (sslength sel))
            (setq idx (1- idx)
                  enx (entget (ssname sel idx))
                  grp (assoc 1 enx)
            )
            (if (setq pos (vl-string-search "\\X" (cdr grp)))
                (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str)))
                (setq new (cons 1 (strcat "<>\\X" str)))
            )
            (entmod (subst new grp enx))
        )
    )
    (princ)
)


For a "dynamic" default, you can use one of the methods I describe here.

  • Thanks 1
Posted

Interesting ""Windows Speech Recognition," and then use the shortcut Windows logo key + Ctrl + S to activate it.

 

Typed dimsub then spoke T Y P a box appeared then did accept. !typ = "TYP " very close.

 

It did 1st go put EYP  in command line. So I think I need to train it more. Can turn on and off microphone by voice. 

 

If I have time may play more.

 

  • Thanks 1
  • 7 months later...
Posted
On 3/7/2025 at 5:58 PM, Lee Mac said:


For a "fixed" default, you can use something like the following:

(defun c:dimsub ( / enx grp idx new pos sel str )
    (if (= "" (setq str (getstring t "\nSpecify string <TYP>: ")))
        (setq str "TYP")
    )
    (if (setq sel (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat (setq idx (sslength sel))
            (setq idx (1- idx)
                  enx (entget (ssname sel idx))
                  grp (assoc 1 enx)
            )
            (if (setq pos (vl-string-search "\\X" (cdr grp)))
                (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str)))
                (setq new (cons 1 (strcat "<>\\X" str)))
            )
            (entmod (subst new grp enx))
        )
    )
    (princ)
)


For a "dynamic" default, you can use one of the methods I describe here.

master , I am trying to do the following

 

(defun c:dimsub ( / enx grp idx new pos sel str )
(princ "\nColoca subfijo a dimension por debajo de linea con opcion de cambio")
   ; (if (= "" (setq str (getstring t "\nSpecify string <TYP>: ")))
        ;(setq str "TYP")
   ; )
    (if (setq sel (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat (setq idx (sslength sel))
            (setq idx (1- idx)
                  enx (entget (ssname sel idx))
                  grp (assoc 1 enx)
            )
            (if (setq pos (vl-string-search "\\X" (cdr grp)))
                (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str)))
                (setq new (cons 1 (strcat "+" "<>\\X" "TEXT 1")))
                
            )
            (entmod (subst new grp enx))
        )
    )
    (princ)
)

image.thumb.png.b47d2baf64fcbb9aa483d84d9398f15b.png

Posted

I NEED TO ADD A SECOND TEXT BELOW THE FIRST

Posted (edited)

Another option

(defun c:subTexta (/ e le txa tx cj para)
  (if (/= (setq tx (getstring "\nType TEXT to add?: ")) "")
    (while (setq n (not (setvar "NOMUTT" 1)) x (princ (strcat "\rAdd \'" tx "\' to DIMENSIONs...")) cj (ssget "_:L" '((0 . "*DIMENSION"))))
      (while (setq e (ssname cj (setq n (if n (1+ n) 0))))
	(entmod (subst
		  (cons 1 (cond ((or (wcmatch (setq txa (cdr (assoc 1 (setq le (entget e))))) "*<>\n*") (wcmatch txa "*<>\\X*")) (strcat txa "\n" tx)) (T (strcat txa "<>\\X" tx))))
		  (assoc 1 le)
		  le
		)
	)
      )
    )
  )
  (setvar "NOMUTT" 0) 
  (princ)
)

 

Edited by GLAVCVS
  • Thanks 1
Posted (edited)
2 minutes ago, GLAVCVS said:

Another option

(defun c:subTexta (/ e le txa tx cj para)
  (if (/= (setq tx (getstring "\nType TEXT to add?: ")) "")
    (while (setq n (not (setvar "NOMUTT" 1)) x (princ (strcat "\rAdd \'" tx "\' to DIMENSIONs...")) cj (ssget "_:L" '((0 . "*DIMENSION"))))
      (while (setq e (ssname cj (setq n (if n (1+ n) (setvar "NOMUTT" 0)))))
	(entmod (subst
		  (cons 1 (cond ((or (wcmatch (setq txa (cdr (assoc 1 (setq le (entget e))))) "*<>\n*") (wcmatch txa "*<>\\X*")) (strcat txa "\n" tx)) (T (strcat txa "<>\\X" tx))))
		  (assoc 1 le)
		  le
		)
	)
      )
    )
  )
  (princ)
)

 

 

To add all the text lines you need

Edited by GLAVCVS
  • Thanks 1
Posted

@leonucadomi

You should copy the code again.

I changed a small thing to prevent NOMUTT from staying at 1.

  • Thanks 1
Posted

@GLAVCVS IT'S OKAY, I JUST NEED IT WITHOUT HAVING TO ADD THE TEXT TO THE BEGINNING, SO TEXTS 1 AND 2 WILL ALREADY BE DEFINED WITHIN THE ROUTINE

 

I mean I just select a dimension and the result is...

true dimension accompanied by the "+" sign

and below the line "text 1" and below this "text 2"

(defun c:dimsub ( / enx grp idx new pos sel str )
(princ "\nColoca subfijo a dimension por debajo de linea con opcion de cambio")
   
    (if (setq sel (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat (setq idx (sslength sel))
            (setq idx (1- idx)
                  enx (entget (ssname sel idx))
                  grp (assoc 1 enx)
            )
            (if (setq pos (vl-string-search "\\X" (cdr grp)))
                (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str)))
                (setq new (cons 1 (strcat "+" "<>\\X" "TEXT 1)))
                
            )
            (entmod (subst new grp enx))
        )
    )
    (princ)
)

this routine is from the master @Lee Mac

image.thumb.png.58aa51ac9e45b42c7dd0f25d6f344969.png

 

I mean I'm looking to add a second line

Posted

I think the best way to explain it is to include a picture of the vote before and after it was modified.

Although perhaps other, more awake minds than mine have already understood it.

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...