Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify Text Style - bug?

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
495 Views, 6 Replies

Modify Text Style - bug?

I'm trying to change the font and rename a text style. All these will do is
rename though. If you (entget (tblobjname "style" "Arial-Bold")) the change
shows up, but the changed font doesn't show up in the STYLE dialog box or on
the monitor. Is it a bug or am I?

(defun c:ct (/ st)
(setq st (entget (tblobjname "style" "Arial-Bold")))
(setq st (subst '(3 . "ARIALNB.TTF")(assoc 3 st) st))
(entmod st)
(command "rename" "style" "Arial-Bold" "Arial-Narrow-Bold")(princ)
)

(defun c:ct (/ st)
(setq st (entget (tblobjname "style" "Arial-Bold")))
(setq st (subst '(3 . "ARIALNB.TTF")(assoc 3 st) st))
(setq st (subst '(2 . "Arial-Narrow-Bold")(assoc 2 st) st));
(entmod st)
)
--

Regards,
Eric S.
A2k/W2k
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Eric,
I have has this same sort of problem previously (posted quite some time ago
I think)
I think the problem lies with true-type fonts.
If you try a similar thing with shx fonts it should work OK.
cheers
Steve

"Eric Schneider" wrote in message
news:D2C98656B202D44B73884A735F328C91@in.WebX.maYIadrTaRb...
> I'm trying to change the font and rename a text style. All these will do
is
> rename though. If you (entget (tblobjname "style" "Arial-Bold")) the
change
> shows up, but the changed font doesn't show up in the STYLE dialog box or
on
> the monitor. Is it a bug or am I?
>
> (defun c:ct (/ st)
> (setq st (entget (tblobjname "style" "Arial-Bold")))
> (setq st (subst '(3 . "ARIALNB.TTF")(assoc 3 st) st))
> (entmod st)
> (command "rename" "style" "Arial-Bold" "Arial-Narrow-Bold")(princ)
> )
>
> (defun c:ct (/ st)
> (setq st (entget (tblobjname "style" "Arial-Bold")))
> (setq st (subst '(3 . "ARIALNB.TTF")(assoc 3 st) st))
> (setq st (subst '(2 . "Arial-Narrow-Bold")(assoc 2 st) st));
> (entmod st)
> )
> --
>
> Regards,
> Eric S.
> A2k/W2k
>
>
Message 3 of 7
Anonymous
in reply to: Anonymous

😞
Bummer. If that's the case, I guess I'll have to do it the old fashioned
way.

Thanks.
--

Regards,
Eric S.
A2k/W2k
Message 4 of 7
Anonymous
in reply to: Anonymous

Eric

This may sound stupid, but have you copied the ARIALNB.TTF into the autocad font directory. I had all sorts of problems with arial narrow, even though all the paths were setup in my preferences etc. I then copied the ttf into the acad font directory and it worked fine.
Message 5 of 7
Anonymous
in reply to: Anonymous

Still didn't work for me. I guess I'll try ActiveX.

Thanks.
--

Regards,
Eric S.
A2k/W2k
Message 6 of 7
Anonymous
in reply to: Anonymous

Eric Schneider,

I found one for you made by John Uhden

(defun sa:CreateTextStyle (name font height width / TextStyles TextStyle
file)
(if
(and
(= (type name) 'STR)
(= (type font) 'STR)
(numberp height)
(> height 0)
(numberp width)
(> width 0)
(setq doc (vla-get-activedocument *acad*)) ; I added this because it
wasn't global here
(setq TextStyles (vla-get-TextStyles doc))
(not
(vl-catch-all-error-p
(setq TextStyle
(vl-catch-all-apply 'vla-Add (list TextStyles name))
)
)
)
;; BTW, if a .TTF file is in the AutoCAD search path,
;; it's full path is not required (at least in 2000i/SP2)
(cond
((setq file (findfile font))(setq file font))
((setq file (findfile (strcat (getenv "windir") "\\fonts\\" font))))
)
(not
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-put-FontFile (list TextStyle file))
)
)
(not
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-put-Width (list TextStyle width))
)
)
(not
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-put-Height (list TextStyle height))
)
)
(not
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-put-ActiveTextStyle (list doc TextStyle))
)
)
;; Actually, these probably don't have to be released
;; if they are local to the function.
(vlax-release-object TextStyle)
(vlax-release-object TextStyles)
)
name
)
)

NOTE: I had copied the Arial.ttf file to my AutoCAD Fonts folder

Command: (sa:createtextstyle "Arial" "Arial.ttf" 2.0 1.5)
"Arial"

Command: (tblsearch "Style" "Arial")
((0 . "STYLE") (2 . "Arial") (70 . 0) (40 . 2.0) (41 . 1.5) (50 . 0.0) (71 .
0)
(42 . 25.8585) (3 . "Arial.ttf") (4 . ""))

--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juhden@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
Message 7 of 7
Anonymous
in reply to: Anonymous

Nice. Thank you Luis. I'll give it a try.
--

Regards,
Eric S.
A2k/W2k

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost