Jump to content

dimjogline plus in dimension ... help


Recommended Posts

Posted

hello all:

There are dimensions I need to do this to.

image.thumb.png.572731c5645aad88071b9907f6d0803c.png

I have a routine to do this

image.png.25a3cb26372ec4e0c063a7b8e59bf50f.png

It would be possible to do everything in a single selection

I mean select the dimension and place the break and the line over the text

I await comments and here I put the code, thank you

; Original by RonJonP, edited by P. Kenewell
(defun c:ltx (/ o s)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (cond
         ((= "TEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "%%O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "%%O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "MTEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "\\O"
                  (vl-string-subst "" "" 
                     (vl-string-subst "" "\\O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "DIMENSION" (cdr (assoc 0 (entget e))))
            (if (= (vla-get-textoverride o) "")
               (vla-put-textoverride o "\\O<>")
               (vla-put-textoverride o
                  (strcat "\\O"
                     (vl-string-subst "" "" 
                        (vl-string-subst "" "\\O" (vla-get-textoverride o))
                     )
                  )
               )
            )
         )
      )
    )
  )
  (command "._undo" "_end")
  (setvar "cmdecho" 1)
  (princ)
)

 

 

 

 

 

 

 

 

Posted (edited)

Also you can return the vla-object list with foreach by wrapping it in mapcar.  eliminating having to use (setq o (vlax-ename->vla-object e)).  Pulling the vla-object name before the cond means your checking the variable rather then check the entity up to 3 times.

 

; Original by RonJonP, edited by P. Kenewell, updated by Mhupp
(defun c:ltx (/ D O S)
  (vl-load-com)
  (setq D (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark D)
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach o (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
      (setq typ (vla-get-ObjectName o))
      (cond
        ((= typ "AcDbText")   
          (vla-put-textstring o (strcat "%%O" (vl-string-subst "" "" (vl-string-subst "" "%%O" (vla-get-textstring o)))))
        )
        ((= typ "AcDbMText")  
          ...
        )
        ((= typ "AcDbDimension")
          ...
        )
      )
    )
  )
  (vla-endundomark D)
  (princ)
)

 

-edit

also useing the (vla-startundomark allows you to have things selected before you run the command.

Edited by mhupp
  • Like 1
  • Thanks 1
Posted
On 9/22/2025 at 10:32 PM, leonucadomi said:

hello all:

There are dimensions I need to do this to.

image.thumb.png.572731c5645aad88071b9907f6d0803c.png

I have a routine to do this

image.png.25a3cb26372ec4e0c063a7b8e59bf50f.png

It would be possible to do everything in a single selection

I mean select the dimension and place the break and the line over the text

I await comments and here I put the code, thank you

; Original by RonJonP, edited by P. Kenewell
(defun c:ltx (/ o s)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (cond
         ((= "TEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "%%O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "%%O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "MTEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "\\O"
                  (vl-string-subst "" "" 
                     (vl-string-subst "" "\\O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "DIMENSION" (cdr (assoc 0 (entget e))))
            (if (= (vla-get-textoverride o) "")
               (vla-put-textoverride o "\\O<>")
               (vla-put-textoverride o
                  (strcat "\\O"
                     (vl-string-subst "" "" 
                        (vl-string-subst "" "\\O" (vla-get-textoverride o))
                     )
                  )
               )
            )
         )
      )
    )
  )
  (command "._undo" "_end")
  (setvar "cmdecho" 1)
  (princ)
)

 

 

 

 

 

 

 

 

 

Hi


Do you want to place the 'jog', indicating its location in each case, or in a predetermined location?

 

Posted

To indicate the 'jog' position 1 to 1, insert this code after the clause ((= "DIMENSION"... (entget e) ))))

 

      (if (not (tblsearch "APPID" "ACAD_DSTYLE_DIMJAG_POSITION"))
	    (regapp "ACAD_DSTYLE_DIMJAG_POSITION")
	  )
	  (if (setq pt (getpoint "\nJOG: Pick a point on the DIMENSION line"))
	    (entmod (append (entget e) (list (list -3 (list "ACAD_DSTYLE_DIMJAG_POSITION" '(1070 . 387) '(1070 . 3) '(1070 . 389) (cons 1010 pt))))))
	  )

 

  • Thanks 1
Posted

I think I forgot something important: when there are multiple selections, it's necessary to show the user which object will be modified in each case.
Below, I've included the complete code with a zoom utility to show the user the next object to modify.

 

; Original by RonJonP, edited by P. Kenewell and GLAVCVS
(defun c:ltx (/ o s pt i p1 p2 le)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (cond
         ((= "TEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "%%O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "%%O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "MTEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "\\O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "\\O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "DIMENSION" (cdr (assoc 0 (entget e))))
	  (if (not (tblsearch "APPID" "ACAD_DSTYLE_DIMJAG_POSITION"))
	    (regapp "ACAD_DSTYLE_DIMJAG_POSITION")
	  )
	  (command "_zoom" "_w" (setq i (cdr (assoc 10 (setq le (entget e))))) (polar i (angle (setq p2 (cdr (assoc 14 le))) (setq p1 (cdr (assoc 13 le)))) (distance p1 p2)))
	  (if (setq pt (getpoint "\rJOG: Pick a point on the DIMENSION line"))
	    (entmod (append (entget e) (list (list -3 (list "ACAD_DSTYLE_DIMJAG_POSITION" '(1070 . 387) '(1070 . 3) '(1070 . 389) (cons 1010 pt))))))
	  )
	  (if (= (vla-get-textoverride o) "")
	    (vla-put-textoverride o "\\O<>")
	    (vla-put-textoverride o
	      (strcat "\\O"
		      (vl-string-subst "" ""
			(vl-string-subst "" "\\O" (vla-get-textoverride o))
		      )
	      )
	    )
          )
         )
      )
    )
  )
  (command "._undo" "_end")
  (setvar "cmdecho" 1)
  (princ)
)

 

  • Like 2
  • Thanks 1
Posted (edited)
1 hour ago, GLAVCVS said:
; Original by RonJonP, edited by P. Kenewell and GLAVCVS
(defun c:ltx (/ o s pt i p1 p2 le)
 (setvar "cmdecho" 0)
 (command "._undo" "_be")

Is it possible not to specify breakpoints, but just make a break to the right of the text? 😉

Edited by Nikon
  • Thanks 1
Posted
On 9/22/2025 at 6:04 PM, mhupp said:

Also you can return the vla-object list with foreach by wrapping it in mapcar.  eliminating having to use (setq o (vlax-ename->vla-object e)).  Pulling the vla-object name before the cond means your checking the variable rather then check the entity up to 3 times.

 

; Original by RonJonP, edited by P. Kenewell, updated by Mhupp
(defun c:ltx (/ D O S)
  (vl-load-com)
  (setq D (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark D)
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach o (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
      (setq typ (vla-get-ObjectName o))
      (cond
        ((= typ "AcDbText")   
          (vla-put-textstring o (strcat "%%O" (vl-string-subst "" "" (vl-string-subst "" "%%O" (vla-get-textstring o)))))
        )
        ((= typ "AcDbMText")  
          ...
        )
        ((= typ "AcDbDimension")
          ...
        )
      )
    )
  )
  (vla-endundomark D)
  (princ)
)

 

-edit

also useing the (vla-startundomark allows you to have things selected before you run the command.

image.png.a784687f92c1e96ca39d46156be96d79.png something is wrong

Posted
4 hours ago, GLAVCVS said:

 

Hi


Do you want to place the 'jog', indicating its location in each case, or in a predetermined location?

 

a default location near any arrow

Posted
2 hours ago, GLAVCVS said:

I think I forgot something important: when there are multiple selections, it's necessary to show the user which object will be modified in each case.
Below, I've included the complete code with a zoom utility to show the user the next object to modify.

 

; Original by RonJonP, edited by P. Kenewell and GLAVCVS
(defun c:ltx (/ o s pt i p1 p2 le)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (cond
         ((= "TEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "%%O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "%%O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "MTEXT" (cdr (assoc 0 (entget e))))
            (vla-put-textstring o
               (strcat "\\O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "\\O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "DIMENSION" (cdr (assoc 0 (entget e))))
	  (if (not (tblsearch "APPID" "ACAD_DSTYLE_DIMJAG_POSITION"))
	    (regapp "ACAD_DSTYLE_DIMJAG_POSITION")
	  )
	  (command "_zoom" "_w" (setq i (cdr (assoc 10 (setq le (entget e))))) (polar i (angle (setq p2 (cdr (assoc 14 le))) (setq p1 (cdr (assoc 13 le)))) (distance p1 p2)))
	  (if (setq pt (getpoint "\rJOG: Pick a point on the DIMENSION line"))
	    (entmod (append (entget e) (list (list -3 (list "ACAD_DSTYLE_DIMJAG_POSITION" '(1070 . 387) '(1070 . 3) '(1070 . 389) (cons 1010 pt))))))
	  )
	  (if (= (vla-get-textoverride o) "")
	    (vla-put-textoverride o "\\O<>")
	    (vla-put-textoverride o
	      (strcat "\\O"
		      (vl-string-subst "" ""
			(vl-string-subst "" "\\O" (vla-get-textoverride o))
		      )
	      )
	    )
          )
         )
      )
    )
  )
  (command "._undo" "_end")
  (setvar "cmdecho" 1)
  (princ)
)

 

This is what I need, I just would like it to be for selecting a single selection (entsel)  and not zoom, 

Just select a dimension and a point for the jogline and repeat the routine.

Posted (edited)

Its incomplete code and only uses vla-object names showing best practice for using cond. Use the original code setting e type outside the cond to check instead of using enget for each cond check. with dimensions you use entget three times, mtext two times. its probably only saving ms of  time. 

 

; Original by RonJonP, edited by P. Kenewell and GLAVCVS
(defun c:ltx (/ o s pt i p1 p2 le typ)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq typ (cdr (assoc 0 (entget e))))
      (setq o (vlax-ename->vla-object e))
      (cond
         ((= "TEXT" typ)
           ...
         )

 

Every time you are using enget its returning something like this. 

(
  (0 . "MTEXT")                         ; saving this bit
  (5 . "1F2")                           
  (330 . <owner>)                      
  (100 . "AcDbEntity")                 
  (67 . 0)                             
  (8 . "TextLayer")                    
  (100 . "AcDbMText")                  
  (10 100.0 200.0 0.0)                 
  (40 . 2.5)                           
  (41 . 50.0)                          
  (71 . 1)                             
  (72 . 5)                             
  (1 . "This is a multiline text")     
  (7 . "Standard")                     
  (210 0.0 0.0 1.0)                    
  (11 100.0 200.0 0.0)                 
  (42 . 1.0)                           
  (43 . 1.0)                           
  (50 . 0.0)                           
  (73 . 1)                             
  (44 . 0.0)                           
  (45 . 0.0)                           
  (90 . 0)                             
  (91 . 1)                             
  (92 . 0)                             
  (93 . 0)                             
  (94 . 0)                             
  (95 . 0)                             
)

 

Edited by mhupp
  • Agree 1
  • Thanks 1
Posted

I have already managed to change the selection to individual and cancel the zoom but

to repeat the routine I use repeat 100 (....) I don't know any other way  :(

Posted (edited)
9 minutes ago, leonucadomi said:

to repeat the routine I use repeat 100 (....) I don't know any other way  :(

 

Change if to while.

(if (setq s (ssget ""_+.:E:S" '((0 . "*TEXT,DIMENSION"))))
  .. runs once
)

(while (setq s (ssget "_+.:E:S" '((0 . "*TEXT,DIMENSION"))))
  ... repeats while you have an entity selected. have to right click or enter to exit loop
)

 

Edited by mhupp
Posted

This will do what you want by selecting multiple objects in the selection set.

; Original by RonJonP, edited by P. Kenewell and GLAVCVS
(defun c:ltx (/ o s le to p1 p2 pIns)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (cond
         ((= "TEXT" (setq to (cdr (assoc 0 (setq le (entget e))))))
            (vla-put-textstring o
               (strcat "%%O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "%%O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "MTEXT" to)
            (vla-put-textstring o
               (strcat "\\O"
                  (vl-string-subst "" ""
                     (vl-string-subst "" "\\O" (vla-get-textstring o))
                  )
               )
            )
         )
         ((= "DIMENSION" to)
	  (if (not (tblsearch "APPID" "ACAD_DSTYLE_DIMJAG_POSITION"))
	    (regapp "ACAD_DSTYLE_DIMJAG_POSITION")
	  )
	  (setq p1 (cdr (assoc 13 le))
		p2 (cdr (assoc 14 le))
		pIns (polar (cdr (assoc 10 le)) (angle p2 p1) (* (distance p1 p2) 0.8))
		x (entmod (append (entget e) (list (list -3 (list "ACAD_DSTYLE_DIMJAG_POSITION" '(1070 . 387) '(1070 . 3) '(1070 . 389) (cons 1010 pIns))))))
	  )
	  
	  (if (= (vla-get-textoverride o) "")
	    (vla-put-textoverride o "\\O<>")
	    (vla-put-textoverride o
	      (strcat "\\O"
		      (vl-string-subst "" ""
			(vl-string-subst "" "\\O" (vla-get-textoverride o))
		      )
	      )
	    )
          )
         )
      )
    )
  )
  (command "._undo" "_end")
  (setvar "cmdecho" 1)
  (princ)
)

 

  • Like 1
Posted (edited)

And this is the small variation that best fits what @leonucadomi is asking for, I think.
With the peculiarity that the "jog" will be placed where the selection is made with the pickbox.

 

; Original by RonJonP, edited by P. Kenewell and GLAVCVS
(defun c:ltx (/ e o s le to l)
  (setvar "cmdecho" 0)
  (command "._undo" "_be")
  (while (and (setq e (car (setq l (entsel "\rSelect a TEXT, MTEXT or DIMENSION...")))) (wcmatch (cdr (assoc 0 (setq le (entget e)))) "*TEXT,DIMENSION"))
    (setq o (vlax-ename->vla-object e))
    (cond
      ((= "TEXT" (setq to (cdr (assoc 0 le))))
       (vla-put-textstring o
	 (strcat "%%O"
		 (vl-string-subst "" ""
		   (vl-string-subst "" "%%O" (vla-get-textstring o))
		 )
         )
       )
      )
      ((= "MTEXT" to)
       (vla-put-textstring o
	 (strcat "\\O"
		 (vl-string-subst "" ""
		   (vl-string-subst "" "\\O" (vla-get-textstring o))
                 )
	 )
       )
      )
      ((= "DIMENSION" to)
       (if (not (tblsearch "APPID" "ACAD_DSTYLE_DIMJAG_POSITION"))
	 (regapp "ACAD_DSTYLE_DIMJAG_POSITION")
       )
       (entmod (append le (list (list -3 (list "ACAD_DSTYLE_DIMJAG_POSITION" '(1070 . 387) '(1070 . 3) '(1070 . 389) (cons 1010 (cadr l)))))))
       (if (= (vla-get-textoverride o) "")
	 (vla-put-textoverride o "\\O<>")
	 (vla-put-textoverride o
	   (strcat "\\O"
		   (vl-string-subst "" ""
		     (vl-string-subst "" "\\O" (vla-get-textoverride o))
		   )
	   )
	 )
       )
      )
    )
  )
  (command "._undo" "_end")
  (setvar "cmdecho" 1)
  (princ)
)

 

Edited by GLAVCVS

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