TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on October 24, 2021, 03:52:02 AM

Title: Dimension Manager lisp
Post by: PM on October 24, 2021, 03:52:02 AM
Hi. I have a problem with dimensions. I am searching for a lisp to change Arrow size, Text size and text offset from selected dimensions based on drawing scale. I attach brawing with the dimension sizes for scales (1:50,1:100,1:200,1:250,1:500,1:1000,1:5000 in meters).

with my calculations  Arrow size = scale x 0.002
                                 Text size = scale x 0,00175
                                 text offset = scale x 0.001


Can any one help  ?

Thanks
Title: Re: Dimension Manager lisp
Post by: tombu on October 24, 2021, 08:48:41 AM
You do know with Annotative Dimensions all of that is done automatically?
Title: Re: Dimension Manager lisp
Post by: PM on October 24, 2021, 08:54:30 AM
I stop using annotation dimensions,text and block because i have problems with this drawings. When i give them to others the say to me that they can not save the drawings . The problem solved when i stop using annotations. That's why i need this lisp.

Thanks
Title: Re: Dimension Manager lisp
Post by: BIGAL on October 24, 2021, 08:06:21 PM
Run Dumpit.lsp on a dim and it will show you all the properties you can get at, for a DIM its big.

;   ArrowheadSize = 3.0
;   TextHeight = 2.5

(vla-put-ArrowheadSize obj 5)
Title: Re: Dimension Manager lisp
Post by: PM on October 25, 2021, 06:45:12 AM
I try this but is not working !!!! I have to click 2 times the same dimension to change text and arrow size. The text Gap not working. I want to select multiple dimension and do the changes. Any ideas?

Code - Auto/Visual Lisp: [Select]
  1. (defun C:test (/ ss n th ars tof);
  2.  (setq scl (getint "\n select scale (50,100,200,250,500,etc) :"))
  3.  (setq th (* scl 0.00175))
  4.  (setq ars (* scl 0.002))
  5.  (setq tof (* scl 0.001))
  6.   (if (setq ss (ssget '((0 . "DIMENSION"))))
  7.     (repeat (setq n (sslength ss))
  8.       (vla-put-TextHeight (vlax-ename->vla-object (ssname ss (setq n (1- n)))) th)
  9.       (vlax-put-property (vlax-ename->vla-object (car (entsel))) 'ArrowheadSize ars)
  10.       (vla-put-TextGap obj tof)
  11.     ); repeat
  12.   ); if
  13. ); defun
  14.  
  15.  



Can any one help ?

Thanks
Title: Re: Dimension Manager lisp
Post by: ribarm on October 25, 2021, 07:39:57 AM
You haven't declared obj variable with VLA-OBJECT argument - it should break at that line - last one (IMHO)...
Title: Re: Dimension Manager lisp
Post by: mhupp on October 25, 2021, 09:38:26 AM
The reason you have to double select to change arrow size is your using (car (entsel)) in the vlax-put rather then ssname.
This would also fix the text gap like ribarm said obj is undeclared.
Code: [Select]
(vla-put-TextHeight (vlax-ename->vla-object (ssname ss (setq n (1- n)))) th)
(vlax-put-property (vlax-ename->vla-object (ssname ss n)) 'ArrowheadSize ars)
(vla-put-TextGap (vlax-ename->vla-object (ssname ss n)) tof)




I use foreach instead so you don't have to keep calculating the n # updating to either will get what you want.
Code: [Select]
(defun C:test (/ scl th ars tof ss)  ;was missing scl, n nolonger needed
  (vl-load-com) ;needed for vla or vlax functions
  (initget 7)
  (setq scl (getint "\n Select Scale (50,100,200,250,500,etc) :"))
  (setq th (* scl 0.00175))
  (setq ars (* scl 0.002))
  (setq tof (* scl 0.001))
  (if (setq ss (ssget '((0 . "DIMENSION"))))
    (foreach dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (vla-put-TextHeight (vlax-ename->vla-object dim) th)
      (vla-put-ArrowheadSize (vlax-ename->vla-object dim) ars)
      (vla-put-TextGap (vlax-ename->vla-object dim) tof)
    )  ; foreach
  )    ; if
)      ; defun
Title: Re: Dimension Manager lisp
Post by: ribarm on October 25, 2021, 10:20:30 AM
No need for check (> scl 0)... (initget) is enough...

Code: [Select]
(initget 7)
(setq scl (getint "\n Select Scale (50,100,200,250,500,etc) :"))

 :wink:
Title: Re: Dimension Manager lisp
Post by: PM on October 25, 2021, 11:30:07 AM
This code work fine. Thanks you all  :smitten: :smitten:

I want to ask samething similar to this. Is any command like DIMGAP (set  the TextGap) ,for TextHeight and ArrowheadSize?

Thanks
Title: Re: Dimension Manager lisp
Post by: PM on October 25, 2021, 11:36:39 AM
iI find

DIMGAP (TextGap)
DIMTXT (TextHeight)
DIMASZ (ArrowheadSize)

Thanks
Title: Re: Dimension Manager lisp
Post by: mhupp on October 25, 2021, 03:01:47 PM
DIMGAP (TextGap)
DIMTXT (TextHeight)
DIMASZ (ArrowheadSize)

(setvar 'DIMGAP 5)

Those are variables changing them won't change any existing dimensions. only when you create a new dimension the new variables/sizes.
you would then have to use another command to update the dimensions with the new variables. i guess you could skip all the vla-put's

Code: [Select]
(defun C:test (/ scl th ars tof ss)  ;was missing scl, n nolonger needed
  (vl-load-com) ;needed for vla or vlax functions
  (setq scl (getint "\n Select Scale (50,100,200,250,500,etc) :"))
  (setvar 'DIMTXT (* scl 0.00175))
  (setvar 'DIMASZ (* scl 0.002))
  (setvar 'DIMGAP (* scl 0.001))
  (if (setq ss (ssget '((0 . "DIMENSION"))))
    (command "DIM1" "UPDATE" SS "")
  )
)




Title: Re: Dimension Manager lisp
Post by: PM on October 26, 2021, 02:14:54 AM
Yes mhupp iknow. I use them to set the simension style before use it .
Title: Re: Dimension Manager lisp
Post by: PM on October 26, 2021, 08:02:10 AM
I want to add a check fillter from linetype scale .

If dimstyle is TOPO then line type   (setvar "celtscale" (* scl 0.00025)) else  (setvar "celtscale" 1)

Can any one help?

Thanks
Title: Re: Dimension Manager lisp
Post by: mhupp on October 26, 2021, 04:28:05 PM
If dimstyle is TOPO then line type   (setvar "celtscale" (* scl 0.00025)) else  (setvar "celtscale" 1)

(or (setvar "celtscale" (* scl 0.00025)) (setvar "celtscale" 1))
If scl isn't defined it will set celtscale to 1
Title: Re: Dimension Manager lisp
Post by: PM on October 26, 2021, 04:34:14 PM
I can not see any ware the dimstyle TOPO
Title: Re: Dimension Manager lisp
Post by: mhupp on October 26, 2021, 04:51:27 PM
oops posted the wrong thing.

Code: [Select]
(if (eq (getvar 'dimstyle) "TOPO")
  (setvar "celtscale" (* scl 0.00025))
  (setvar "celtscale" 1)
)

Title: Re: Dimension Manager lisp
Post by: PM on October 26, 2021, 07:14:59 PM
Thanks mhupp  :smitten: :smitten:
Title: Re: Dimension Manager lisp
Post by: PM on December 04, 2021, 04:57:39 AM
I use this code to change the scale of the dimensions.

I want to add an update to this code and if the dimension style have the name TOPO to change the linetype scale to "celtscale" (* scl 0.00025) unless  the "celtscale" 1. I try to add

Code - Auto/Visual Lisp: [Select]
  1. (if (eq (getvar 'dimstyle) "TOPO")
  2.   (setvar "celtscale" (* scl 0.00025))
  3.   (setvar "celtscale" 1)
  4. )

in the code but is not change the linetype scale. Can any one help me?

Thanks


Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:dimfixscl (/ scl th ars tof ss)  ;was missing scl, n nolonger needed
  3.   (vl-load-com) ;needed for vla or vlax functions
  4.   (initget 7)
  5.   (setq scl (getint "\n Select Scale (50,100,200,250,500,etc) :"))
  6.   (setq th (* scl 0.00175))
  7.   (setq ars (* scl 0.002))
  8.   (setq tof (* scl 0.001))
  9. )
  10.   (if (and (setq ss (ssget '((0 . "DIMENSION")))) (> scl 0)) ;checks if you inputted a number greater than 0 for scale
  11.     (foreach dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  12.       (vla-put-TextHeight (vlax-ename->vla-object dim) th)
  13.       (vlax-put-property (vlax-ename->vla-object dim) 'ArrowheadSize ars)
  14.       (vla-put-TextGap (vlax-ename->vla-object dim) tof)
  15.     )  ; foreach
  16.   )    ; if
  17. )      ; defun
  18.  
  19.  
Title: Re: Dimension Manager lisp
Post by: mhupp on December 04, 2021, 07:20:32 AM
This should get it working.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:dimfixscl (/ scl th ars tof ss)  ;was missing scl, n nolonger needed
  2.   (vl-load-com)  ;needed for vla or vlax functions
  3.   (initget 7)
  4.   (setq scl (getint "\n Select Scale (50,100,200,250,500,etc) :")
  5.         th (* scl 0.00175) ars (* scl 0.002) tof (* scl 0.001)
  6.   )
  7.   (if (setq ss (ssget '((0 . "DIMENSION"))))
  8.     (foreach dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  9.       (setq dim (vlax-ename->vla-object dim))
  10.       (vla-put-TextHeight dim th)
  11.       (vlax-put-property dim 'ArrowheadSize ars)
  12.       (vla-put-TextGap dim tof)
  13.       (if (= (vlax-get-property dim 'StyleName) "TOPO")
  14.         (vla-put-linetypescale dim (* scl 0.00025))
  15.         (vla-put-linetypescale dim 1)
  16.       )
  17.     )
  18.   )
  19.   (princ)
  20. )
Title: Re: Dimension Manager lisp
Post by: PM on December 04, 2021, 09:59:31 AM
Hi mhupp . I try your code but not change the linetype scale.
 Lookk the dwg file with the dimension styles and the test i did.

Thanks
Title: Re: Dimension Manager lisp
Post by: mhupp on December 04, 2021, 12:15:15 PM
Sorry I didn't understand what you wanted. The code is updated and will do what you want now.
Title: Re: Dimension Manager lisp
Post by: PM on December 04, 2021, 01:03:21 PM
Thanks mhupp   now works fine  :smitten: :smitten: