TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Sam on July 20, 2012, 07:54:38 AM

Title: how to add pi symbol in autocad text
Post by: Sam on July 20, 2012, 07:54:38 AM
Dear Sir,

how to add pi symbol in autocad text
Title: Re: how to add pi symbol in autocad text
Post by: irneb on July 20, 2012, 08:02:21 AM
One way would be to add the unicode value like so:
Code: [Select]
\U+03C0In lisp you'd need to double backslash the U+.
Title: Re: how to add pi symbol in autocad text
Post by: Lee Mac on July 20, 2012, 08:03:49 AM
Use Unicode, e.g.:

Code: [Select]
(defun c:test ( )
    (entmake '((0 . "TEXT") (40 . 1.0) (10 0.0 0.0 0.0) (1 . "\\U+03C0")))
    (princ)
)

Edit: Irne beat me to it :P

Title: Re: how to add pi symbol in autocad text
Post by: CAB on July 20, 2012, 10:14:35 AM
And %%960  8-)
Title: Re: how to add pi symbol in autocad text
Post by: irneb on July 20, 2012, 10:44:23 AM
And %%960  8)
Is that for special SHX fonts? I get text displaying %%960 even if I use \960 it doesn't convert. Tried using ARIAL.TTF & Romans.SHX. The Unicode works on ARIAL.TTF, but only works on Romans.SHX if you turn on the "Use Big Font" check in the Style dialog.
Title: Re: how to add pi symbol in autocad text
Post by: CAB on July 20, 2012, 10:46:52 AM
Simplex.shx
Title: Re: how to add pi symbol in autocad text
Post by: Sam on July 21, 2012, 01:27:48 AM
Dear all sir,

Thx for reply
1) irneb sir thx nice
2) lee mac sir i use u r lisp but not create a text
3) cab sir thx its also good

Title: Re: how to add pi symbol in autocad text
Post by: CAB on July 21, 2012, 08:33:02 AM
And %%960  8)
Is that for special SHX fonts? I get text displaying %%960 even if I use \960 it doesn't convert. Tried using ARIAL.TTF & Romans.SHX. The Unicode works on ARIAL.TTF, but only works on Romans.SHX if you turn on the "Use Big Font" check in the Style dialog.
I never explored Big Fonts but maybe they are above the normal range of character codes.
It's aggravating at times when trying to use special characters as they vary from font to font.
 
Title: Re: how to add pi symbol in autocad text
Post by: irneb on July 21, 2012, 08:57:43 AM
The thing is, if my font is Romans.SHX and I want one of these unicode characters, then 9/10 times the charcter is displayed as some TTF font (usually Arial). If I set the Romans to use Big Font, then most of these characters display correctly. So it seems that BF simply implements the UniCode in the font as well, meaning instead of only 230 od characters there could be 1000's

I've not tried the Standard.SHX much. We generally don't use it. So I can't say much about its Big Font, though I think it uses the same one as for Romans.
Title: Re: how to add pi symbol in autocad text
Post by: CAB on July 21, 2012, 09:27:45 AM
Maybe a font expert will help us out.  8-)
I don't have a Standard.shx and the STANDARD style gets me into trouble as it can vary from user to user & file to file.

Looks like the Big Font is a separate file.
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS73099cc142f4875513fb5cd10c4aa30d6b-7ed8.htm,topicNumber=d0e406072
Title: Re: how to add pi symbol in autocad text
Post by: Lee Mac on July 21, 2012, 02:41:46 PM
2) lee mac sir i use u r lisp but not create a text

It should create a Text object with text height 1.0 and insertion point at the origin.

At least, it does for me :)
Title: Re: how to add pi symbol in autocad text
Post by: DEVITG on July 21, 2012, 11:19:50 PM
Lee Mac , I got a ? as text.

Title: Re: how to add pi symbol in autocad text
Post by: irneb on July 22, 2012, 01:10:01 AM
Lee Mac , I got a ? as text.
That's due to the font you're using. It has to define the character with that unicode (hex:3C0, dec:960, oct:1700). Most of the SHX fonts only define the normal ANSI codes, i.e. dec:32/hex:20 (space) through dec:255/hex:FF (ÿ). For the characters in excess of that you either need to add the bigfont option to the style, or use a TTF font in the style instead.

Note, not all TTF fonts define all unicode characters either. The easiest way to find them IMO is to check the Character Map program in windows - that's also where I find the unicode value to input into acad.
Title: Re: how to add pi symbol in autocad text
Post by: Sam on July 23, 2012, 03:27:55 AM
2) lee mac sir i use u r lisp but not create a text

It should create a Text object with text height 1.0 and insertion point at the origin.

At least, it does for me :)
Dear Sir
thxx got it
Title: Re: how to add pi symbol in autocad text
Post by: RONR on July 25, 2012, 06:42:23 PM
Change to Greeks font and use lowercase P.  Greeks is native to AutoCAD.  You can also use this method to get the Ohms symbol by using uppercase W.
Title: Re: how to add pi symbol in autocad text
Post by: irneb on July 26, 2012, 06:19:03 AM
Good idea! So inside MTexts / Dim Overrides / MLeader texts you can place the following piece of text from Lisp:
Code - Auto/Visual Lisp: [Select]
  1. "{\\Fgreeks|;p}" ;Using the Greeks.SHX font
  2. "\\U+03C0" ;Using the unicode double-byte character code
For other stuff you can do the same, e.g. micro Ohms:
Code - Auto/Visual Lisp: [Select]
  1. "{\\Fgreeks|;mW}" ;Greek font
  2. "\\U+03BC\\U+03A9" ;Unicode
Or indicating delta:
Code - Auto/Visual Lisp: [Select]
  1. "{\\Fgreeks|;D}" ;Greek font
  2. "\\U+0394" ;Unicode

The nice thing about using Greeks.SHX is the characters look as if they are the same font as the Romans.SHX font. Where the unicode uses alternative fonts if the BigFont is not turned on. And even with BigFont turned on, I like the Greeks version more.
Title: Re: how to add pi symbol in autocad text
Post by: Lee Mac on July 26, 2012, 07:50:29 AM
Great idea RONR  :-)

Greekc.shx is also rather nice:

(http://www.theswamp.org/lilly_pond/leemac/greekshx.png)
Title: Re: how to add pi symbol in autocad text
Post by: Crank on July 26, 2012, 01:01:18 PM
And %%960  8-)
Though it's still working, I believe to remember that Autodesk switched to unicode with Autocad2008. That's when I stopped using %%###.  BTW hex960 = dec03C0 (hint) ;)

The thing is, if my font is Romans.SHX and I want one of these unicode characters, then 9/10 times the character is displayed as some TTF font (usually Arial). [...]
I've never seen a different alternate font than Arial. But I just change these characters to Simplex and then you don't even notice that another font is used for these few characters.
Another thing you can try is to edit your ACAD.FMP file. If you add
Code: [Select]
Arial;ROMANEUR.shx to this file the font ARIAL should (in theory :kewl: ) be replaced with a ROMAN-font that supports the most important unicodes.
Title: Re: how to add pi symbol in autocad text
Post by: Crank on July 26, 2012, 01:28:21 PM
If you open a drawing and you get a message like:
Quote
' ** Undefined shape 8962 '
that means a character is used, but the used font doesn't support that special character.

Owen has made a tool to remove these characters:
Quote
CleanLanguage 1.0                       March 25, 2011

Copyright (C) 2011 ManuSoft (http://www.manusoft.com)
http://www.manusoft.com/software/freebies/arx.html


  ** Legal Stuff **

CleanLanguage is placed in the public domain. The
CleanLanguage binaries may be freely redistributed
or used for any purpose as long as this legal notice
accompanies all files.

ManuSoft disclaims any and all liability for your use
of this software. The software is provided "as is"
without warranty of any kind, either express or implied.


  ** What it does **

CleanLanguage makes an effort to identify and clean
objects in an AutoCAD drawing file that contain corrupt
text characters. Such corruption may cause AutoCAD to
display a warning about a "missing language pack". The
software supports AutoCAD versions 2007 through 2012.


  ** How to use it **

To load the software, drag and drop the appropriate
.arx module into your AutoCAD drawing window, then use
the CLEANLANGUAGE command to clean the drawing.


  ** Support **

ManuSoft does not offer any technical support for this
software, however we do appreciate feedback. Please
contact us with information about any problems you
encounter.


 *****************************************
 ****  ManuSoft                       ****
 ****  POB 101, 34 Maple St.          ****
 ****  Apple Creek, OH, USA 44606     ****
 ****  +1 330-698-1723 (Voice)        ****
 ****  +1 330-698-1770 (Fax)          ****
 ****  http://www.manusoft.com        ****
 ****  support@manusoft.com           ****
 *****************************************
Title: Re: how to add pi symbol in autocad text
Post by: owenwengerd on July 26, 2012, 01:54:51 PM
CleanLanguage is intended for removing corrupt text; I could be wrong, but I don't think it would remove a missing shape reference from existing text. My SuperPurge utility (https://www.manusoft.com/software/superpurge.html) can remove shape file references, though.