Jump to content

Recommended Posts

Posted (edited)

I am looking for a way to find ALL text that does not have a TEXT WIDTH FACTOR (TWF) = 1.0. Then I want to evaluate the current TEXT WIDTH FACTOR setting and substitute a different font with a TWF = 1.0.

 

 

EDITED POST AND ADDED THE FOLLOWING

The program needs to do this for all text including mtext, text in blocks, dynamic blocks, attributed text, text in nested blocks, etc.

 

 

I am trying to replace existing SHX or TT fonts where text length has been changed for whatever reason to a TT font with a Text Width Factor of 1.0. The resulting text must still fit within the overall length of the original text. If there were a way to measure the length of existing text and then use that to determine what font to use that would work also. Or maybe look at the available area that exists for the text and use that to determine new font??

 

 

We have text in BOM, title block, etc. that must fit within a given space which is why past users have used the Text Width Factor to "make it fit" or used the fit-justified text.

Rules:

1.) If TWF is between 0.96 and 1.04 then change font to Arial Regular and set TWF = 1.0

2.) If TWF is between 0.85 and 0.95 then change font to Arial Narrow Bold and set TWF = 1.0

2.) If TWF is between 0.75 and 0.84 then change font to Arial Narrow and set TWF to 1.0

 

I found Lee Mac's FixAllText which works great for changing all text. However, after using it I have found some text that over flows past its "bounding box" or into other text. Thus, I need to edit his code to do this but don't know that much about LISP yet.

 

Thanks for any help you can Provide.

711-24977 Text Width Factor & Font Change Example.DWG

FixAllText.lsp

Edited by THansen
Add Needed Information
Posted

Ran out of time, have to actually do some work

 

1 ssget all text

2 look at each text using vla-get-scalefactor

3 cond

0.96-1.04 arial twf=1 use vla-put-stylename & vla-put saclefactor

cond 0.85-.95 arial narrow twf=1

cond 0.96-1.04 arial twf=1

Posted (edited)

Attach a sample drawing (to test the codes on) please.

EDIT:

Heres a suggestion, build up on BIGAL's steps (probably it needs corrections):


[b][color=BLACK]([/color][/b]defun C:test [b][color=FUCHSIA]([/color][/b] / SS i ent vla-obj scf[b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]if
	[b][color=NAVY]([/color][/b]and
		[b][color=MAROON]([/color][/b]princ [color=#2f4f4f]"\nSelect text: "[/color][b][color=MAROON])[/color][/b]
		[b][color=MAROON]([/color][/b]setq SS [b][color=GREEN]([/color][/b]ssget [color=#2f4f4f]"_:L"[/color] [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
	[b][color=NAVY])[/color][/b][color=#8b4513];and		[/color]
	[b][color=NAVY]([/color][/b]repeat [b][color=MAROON]([/color][/b]setq i [b][color=GREEN]([/color][/b]sslength SS[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
		[b][color=MAROON]([/color][/b]setq ent [b][color=GREEN]([/color][/b]ssname SS [b][color=BLUE]([/color][/b]setq i [b][color=RED]([/color][/b]1- i[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
		[b][color=MAROON]([/color][/b]setq vla-obj [b][color=GREEN]([/color][/b]vlax-ename->vla-object ent[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
		[b][color=MAROON]([/color][/b]setq scf [b][color=GREEN]([/color][/b]vla-get-scalefactor vla-obj[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
		[b][color=MAROON]([/color][/b]cond
			[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]<= 0.96 scf[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]>= 1.04 scf[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
				[b][color=BLUE]([/color][/b]vla-put-stylename vla-obj 'ArialRegular[b][color=BLUE])[/color][/b]
			[b][color=GREEN])[/color][/b]
			[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]<= 0.85 scf[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]>= 0.95 scf[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
				[b][color=BLUE]([/color][/b]vla-put-stylename vla-obj 'ArialNarrowBold[b][color=BLUE])[/color][/b]
			[b][color=GREEN])[/color][/b]
			[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]<= 0.75 scf[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]>= 0.84 scf[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
				[b][color=BLUE]([/color][/b]vla-put-stylename vla-obj 'ArialNarrow[b][color=BLUE])[/color][/b]
			[b][color=GREEN])[/color][/b]
		[b][color=MAROON])[/color][/b][color=#8b4513]; cond[/color]
		[b][color=MAROON]([/color][/b]if 
			[b][color=GREEN]([/color][/b]and
				[b][color=BLUE]([/color][/b]not [b][color=RED]([/color][/b]= scf 1.0[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
				[b][color=BLUE]([/color][/b]and
					[b][color=RED]([/color][/b]>= 1.04 scf[b][color=RED])[/color][/b]
					[b][color=RED]([/color][/b]<= 0.75 scf[b][color=RED])[/color][/b]
				[b][color=BLUE])[/color][/b]
			[b][color=GREEN])[/color][/b]
			[b][color=GREEN]([/color][/b]vla-put-scalefactor vla-obj 1.0[b][color=GREEN])[/color][/b]
		[b][color=MAROON])[/color][/b][color=#8b4513]; if[/color]
	[b][color=NAVY])[/color][/b][color=#8b4513];repeat[/color]
[b][color=FUCHSIA])[/color][/b][color=#8b4513]; if SS[/color]
[b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b]
[b][color=BLACK])[/color][/b][color=#8b4513];defun	[/color]

Edited by Grrr
Posted

The OP has posted the same problem @theswamp.org but with one important additional sentence:

This includes text in mtext, attributes, blocks, dynamic blocks, etc.
Posted

Roy_043, thanks for pointing this out. I forgot to edit the post to add that.

 

 

Thanks for all the help. So that everyone understands the goal.....

We are trying to get our DWG files updated to use TT fonts with Width Factor = 1.0 and Oblique Angle = 0.0. This is all so that we can get fully searchable PDF files, even from older versions of AutoCAD. We use the Autodesk Vault which creates the DWFx visualization file and places a copy of it in a network folder. We then process the DWFx into PDF using Design Review batch plot feature. The fonts being used in DWG files now are mix of SHX and TT. We need all TT. So I am trying to develop a LISP that we can BATCH run on the files in chunks......like 1000 at a time.

 

 

The use of SHX fonts, text width factor not equal to 1.0 and oblique angle not equal to 0.0 prevent fully searchable text. Thus, we are trying to fix the root problem rather than try and use OCR and other things.

Posted

I am looking for someone willing to do some LISP or VBA or .net OR combination of these to do some programming for my company. Is there a forum on this site for "Consulting" or "developing"?

Posted

I have tried contacting Lee but got no response.

Posted

Writing a script to do a 1000 is not hardI would not do that many in one go in case something goes wrong. You would need to add the (load "chgtext") to say acaddoc.lsp startup so its preloaded

 

2 changes to Grr code
(defun c:grrchgtext [b][color=#ff00ff]([/color][/b] / SS i ent vla-obj scf[b][color=fuchsia])[/color][/b]
[b][color=#800000]([/color][/b]setq SS [b][color=green]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=blue]([/color][/b]list [b][color=red]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=red])[/color][/b][b][color=blue])[/color][/b][b][color=green])[/color][/b][b][color=maroon])[/color][/b]
[b][color=#800000]

[/color][/b]

the script just repeat for as many as required

 

open dwg1 (c:grrchgtext) close Y

open dwg2 (c:grrchgtext) close Y

 

Posted

Update on this.......I have found an alternate way to get fully searchable PDF provided Text Width Factor and/or Oblique angle are at default values.

 

This is done by FORCING AutoCAD to substitute ttf for all the shx fonts.

 

1.) Delete the shx fonts from your workstation, including AutoCAD's default simplex.SHX. You have to delete....I tried renaming the font file like TAH-romans.shx and AutoCAD still found it. Then I renamed the folder to TAH-fonts and again AutoCAD still found it. I just DELETED all *.SHX files I found from the C: search.

 

2.) Edit the acad.fmp file and remove all entries. Save file as a blank file.

 

3.) Set the AutoCAD system variable FONTALT to your desired font. I used Arial.ttf.

 

4.) When AutoCAD loads it will try to find the fonts used in the dwg file using the path specified in the support search path settings. Since it cannot find them it will look at the acad.fmp file. Since this file is empty it will then look at the font defined in the text style again and attempt to find it in other places (folders). Since it still cannot find the file it will used the font stored in the AutoCAD FONTALT system variable which is Arial.ttf.

 

Mtext is shown in the text editor using the ttf equivalent of the shx font. For .ttf fonts it will first look in the acad.fmp which is empty, then at the font defined in the text style, then Windows will substitute a similar font which in my case is Arial.ttf.

 

Once the drawing is opened, fonts have been substituted, and any file output is done using the true type font(s). This works for DWF / DWFx to PDF or directly to PDF using simple PDF print drivers.

 

HOWEVER, if you have text with the Text Width Factor not equal to 1.0 and/or Text Oblique Angle not equal to 0.0 this text is still not searchable.

 

In our case 90% of our SHX based text becomes fully searchable where non of it did before :)

 

Hopefully this helps someone!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...