Yes Lee, that is one of the reasons I asked. I couldn't see that I was doing anything special between the two branches but couldn't get it to work with just the simple line. Which was the original code Michael Puckett gave me.
I was receiving the
Error: divide by zero message
I believe from this line
max
-width
(* 5.25 (getvar 'dimscale
));;multiply 5.25 dimscale
I added
max-width1 5.25 here(setq
block-spec "TBLK_ATT_CTL"
max-width (* 5.25 (getvar 'dimscale));;multiply 5.25 dimscale
max-width1 5.25 )
(setq tag-spec (entsel "\nselect TitleLine: ") ;;removed tag-spec "TitleLine#"
)
(if
(= 1 (getvar 'tilemode))
(progn
(setq ss (ssget "x" (list '(0 . "insert")'(66 . 1)(cons 2 block-spec))))
(repeat (setq i (sslength ss))
(mpx-restrict-attrib-widths
(vlax-ename->vla-object (ssname ss (setq i (1- i))))
tag-spec
max-width
)
)
)
(progn
(setq ss (ssget "x" (list '(0 . "insert")'(66 . 1)(cons 2 block-spec))))
(repeat (setq i (sslength ss))
(mpx-restrict-attrib-widths
(vlax-ename->vla-object (ssname ss (setq i (1- i))))
tag-spec
max-width1 )
)
)
)
(setvar "cmdecho" oldecho)
(princ)
)
Ribarm:
I started out with your suggestion and it worked fine under certain circumstances. As I mention above, I kept getting the Divide by Zero error with your suggestion too. I reverted back to my "IF" statement approach and was able to get it to work in a real world application for both title blocks.
I'm sure there's a method for addressing the "divide by zero" using your method, but it is out of my brain's reach.
Lee:
I don't know if that was the correct approach add the extra setq "max width1" but it seemed to work appropriately in both title blocks.
As usual if you or anyone has any other suggestions, I'm listening.