Getting text height from "standard" text style
I am using the below code snippet to get text heights. This code fails only when the current dimension style is "standard"
Any insight as to why?
Code:
(defun c:sth ()
(setq txttype (getstring "\n\"alt\" or [\"reg\"]"))
(cond ((/= txttype "alt") (setq txttype "reg")))
(if (= (getvar 'ctab) "Model")
(setq dimsc (getvar 'dimscale))
(setq dimsc 1)
)
(setq txtheight
(cdr
(assoc 140
(entget (tblobjname "dimstyle" (getvar 'dimstyle)))
)
)
)
(setq txtheight (* txtheight dimsc))
(cond
(
(= txttype "alt")
(setq txtheight (* txtheight 0.6))
)
)
(setvar "textsize" txtheight)
)
Re: Getting text height from "standard" text style
Hi,
Nothing to let the codes to fail even if the current active dimension style is Standard, so you may have another part of codes cause that error.
And what's the error message you receive by the way? ;)
1 Attachment(s)
Re: Getting text height from "standard" text style
As an alternative this lisp gives you multiple options for setting text height. You can select any Text, Mtext or Attribute even in an xref to get it's height. Pressing Enter instead will use the current annotation scale to get the text height required to plot text at a height of 0.1. You're then given the option to either set that as the text height, enter a different value, or pick two points to set the value. For a different default height for plotting text change the two 0.1 values to whatever you want.
As I use Annotative Dimensions I haven't used "dimscale" for anything in quite a while.
Re: Getting text height from "standard" text style
Quote:
Originally Posted by
Tharwat
Hi,
Nothing to let the codes to fail even if the current active dimension style is Standard, so you may have another part of codes cause that error.
And what's the error message you receive by the way? ;)
The error is: ; error: bad argument type: numberp: nil
and happens with the ..(cdr (assoc 140... there doesn't appear to be a "140" associated with
the "standard" dimstyle dxf. That's what I was wondering about...
Re: Getting text height from "standard" text style
Hi,
Try it this way.
Code:
(cdr (assoc 140 (entget (cdr (assoc -1 (entget (tblobjname "dimstyle" "Standard")))))))
Re: Getting text height from "standard" text style
Quote:
Originally Posted by
Frank Dux
I am using the below code snippet to get text heights. This code fails only when the current dimension style is "standard"
Any insight as to why?
Code:
(assoc 140 (entget (tblobjname "dimstyle" (getvar 'dimstyle))))
If you create a copy of Standard it will not have a value until it's changed from the Standard value either. Apparently most of those DXF values are overrides of Standard and simply don't exist unless they've been set different than the Standard dimension style.
I couldn't find any info on where the Standard dimension values are stored, if anyone figures where that is let us know.