Jump to content

Recommended Posts

Posted

Does anyone have a LISP that will toggle dimensions with a leader into different quadrants?

image.png

Posted

When you do a dimension it will default to the position of the dim text, but you can override it and change the dim text point. So its a 2 step process. If you look at the 15 & 25 they have been moved.

image.png.c92d6007e0194da29bc9713ae1b235bc.png

 

What do you know about lisp ? This is sample code you would have 4 versions of this to move the dim text. So for me a dcl with choice orientation also.

; do a dim
(setq obj (vlax-ename->vla-object (entlast)))
(setq tpos (mapcar '+ (vlax-get obj 'TextPosition) (list 125.0 (- 120.0) 0.0)))
(vlax-put obj 'TextPosition tpos)

Could do as 4 defuns but stored in one lisp program. DUL, DUR, DLL, DLR

Posted

BIGAL
I'm not at all good with writing LISPs. It is all Greek to me.  Can you write one that has the 4 functions in one LISP?

Posted

Ok I have something but I can not post, the move values for the dim text depends on your dimension style, so I need a real dwg so can work out these offset values.

 

Part 2 the code at moment links to the mid point is that OK, not sure have to dig deeper to see if can move it closer to an end.

 

Please post a dwg.

 

image.png.d5eed3d43c2e70127dde13726f9648ab.png

Posted (edited)
  On 4/9/2025 at 2:42 PM, jrr114 said:

Does anyone have a LISP that will toggle dimensions with a leader into different quadrants?

Expand  

Is such an algorithm possible for this task?

Select dimension:
1st click on the dimension - dimtext moves along with the leader Top Left
2 st click                           - dimtext moves along with the leader Top right 
3 st click                           - dimtext moves along with the leader Bottom left
4 st click                           - dimtext moves along with the leader Bottom right.
The offset from the dimension line should be equal to the height of the text (or two text heights).

Edited by Nikon
Posted

Multi radio buttons.lspGive this a try.

 

; https://www.cadtutor.net/forum/topic/97280-toggle-dimension-lisp/
; dim_sample.dwg move dime to one of the 4 quadrants
; By AlanH April 2025


(defun c:dodimcorner ( / ent obj dotl dotr dobl dobr)

(defun dotl ( / )
(setq tpos (mapcar '+ (cdr (assoc 13 entg))(list 0 dimsc 0.0)))
(vlax-put obj 'TextMovement 1)
(vlax-put obj 'TextPosition tpos)
)

(defun dotr ( / )
(setq tpos (mapcar '+ (cdr (assoc 14 entg))(list 0.5 dimsc 0.0)))
(vlax-put obj 'TextMovement 1)
(vlax-put obj 'TextPosition tpos)
)

(defun dobl ( / )
(setq tpos (mapcar '+ (cdr (assoc 13 entg))(list 0.0 (- dimsc) 0.0)))
(vlax-put obj 'TextMovement 1)
(vlax-put obj 'TextPosition tpos)
)

(defun dobr ( / )
(setq tpos (mapcar '+ (cdr (assoc 14 entg))(list 0.0 (- dimsc) 0.0)))
(vlax-put obj 'TextMovement 1)
(vlax-put obj 'TextPosition tpos)
)


(if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already

(setq ent (car (entsel "\nPick a dim ")))

(setq entg (entget ent))
(setq obj (vlax-ename->vla-object ent))
(setq dimsc (vlax-get obj 'scalefactor))

(if (= but nil)(setq but 1))
(ah:butts but "V" '("Choose a corner" "Top Left" "Top right" "Bottom left" "Bottom right" ))

(cond 
((= but 1)(dotl))
((= but 2)(dotr))
((= but 3)(dobl))
((= but 4)(dobr))
)

(princ)
)

(c:dodimcorner)

 

  • Like 1
Posted (edited)
  On 4/12/2025 at 11:01 PM, BIGAL said:
; dim_sample.dwg move dime to one of the 4 quadrants
; By AlanH April 2025


(defun c:dodimcorner ( / ent obj dotl dotr dobl dobr)
Expand  

This is great code, but Top Left and 
Top right does not move the leader up.
Is it possible to sort through the placement options by clicking on the dimension (without using the dialog box)?

 

Image 1.png  Image 2.png  Image 3.png Image 4.png

Edited by Nikon
Posted

While the sun floats around the globe till BIgAl wakes again, look into his code, there is a section 

 

(cond 
((= but 1)(dotl))
((= but 2)(dotr))
((= but 3)(dobl))
((= but 4)(dobr))
)

 

that can be changed to a while loop, something like below for the order of things: (Sunday, CAD is off, no testing or checks from me today)

 

(setq counter 1)

(While ((ssget '((0 . "*DIM*"))) : +E+S ; select any dimension else do by entity name from previous dimension, (car entg )

(cond

((= counter 1)(dotl))

.....

)

setq counter (+ counter 1)

(if (= counter 5)(setq counter 1)

) ; end while

 

Pretty sure you can have a go at that today, then show off later

 

 

Posted
  On 4/13/2025 at 7:57 AM, Steven P said:

that can be changed to a while loop

Expand  

I refuse the dialog box, but I have to select the same size twice, then I can change the leader position in the loop by pressing lmb/rmb...
The problem with the top location remains...

(defun c:dodimcorner-while (/ ent obj entg dimsc but counter)
  (defun dotl (/)
    (setq tpos (mapcar '+ (cdr (assoc 13 entg)) (list 0 dimsc 0.0)))
    (vlax-put obj 'TextMovement 1)
    (vlax-put obj 'TextPosition tpos)
  )

  (defun dotr (/)
    (setq tpos (mapcar '+ (cdr (assoc 14 entg)) (list 0.5 dimsc 0.0)))
    (vlax-put obj 'TextMovement 1)
    (vlax-put obj 'TextPosition tpos)
  )

  (defun dobl (/)
    (setq tpos (mapcar '+ (cdr (assoc 13 entg)) (list 0.0 (- dimsc) 0.0)))
    (vlax-put obj 'TextMovement 1)
    (vlax-put obj 'TextPosition tpos)
  )

  (defun dobr (/)
    (setq tpos (mapcar '+ (cdr (assoc 14 entg)) (list 0.0 (- dimsc) 0.0)))
    (vlax-put obj 'TextMovement 1)
    (vlax-put obj 'TextPosition tpos)
  )

  (if (not AH:Butts)
    (load "Multi radio buttons.lsp")
  )

  (setq ent (car (entsel "\nPick a dim ")))
  (setq entg (entget ent))
  (setq obj (vlax-ename->vla-object ent))
  (setq dimsc (vlax-get obj 'scalefactor))

  (if (= but nil) (setq but 1))
 ; (ah:butts but "V" '("Choose a corner" "Top Left" "Top right" "Bottom left" "Bottom right"))

  (setq counter 1)

  (while (ssget '((0 . "*DIMENSION*")))
    (cond
      ((= counter 1) (dotl))
      ((= counter 2) (dotr))
      ((= counter 3) (dobl))
      ((= counter 4) (dobr))
    )
    (setq counter (+ counter 1))
    (if (= counter 5) (setq counter 1))
  )
  (princ)
)

 

Posted

Try setting (setq counter ... ) to 2 - I'm assuming here that the initial text position is top left, so when you click dimension to move it on, the first position change will be to set position to top left - the third click will move it on to TR.

  • Thanks 1
Posted (edited)

 

  On 4/13/2025 at 11:12 AM, Steven P said:

Try setting (setq counter ... ) to 2

Expand  

It doesn't change anything...
Probably, the program contains only these 4 positions of the text with the leader 

depending on the distance from the dimension line.

4-1.png     4-2.png

 

that will be best.png

Edited by Nikon
Posted (edited)

I dont know why its not working this is what I got just now copied code from here as an extra check.

image.png.0e52b6bc2f30bcbbd193ddda13fb1b7a.png

 

There is some code out there for use arrows I will leave that for you to find.

Edited by BIGAL

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