乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 9|回复: 9

[编程交流] 查找所有不可用的文本

[复制链接]

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:21:10 | 显示全部楼层 |阅读模式
我正在寻找一种方法来查找所有没有文本宽度因子(TWF)=1.0的文本。然后我想评估当前的文本宽度因子设置,并用TWF=1.0替换不同的字体。
 
 
规则:
1)如果TWF在0.96和1.04之间,则将字体更改为Arial Regular,并将TWF设置为1.0
2)如果TWF在0.85和0.95之间,则将字体更改为Arial Narrow Bold,并将TWF设置为1.0
2)如果TWF在0.75和0.84之间,则将字体更改为Arial Narrow,并将TWF设置为1.0
 
我发现李·麦克的FixAllText非常适合更改所有文本。然而,在使用它之后,我发现一些文本越过它的“边界框”或流入其他文本。因此,我需要编辑他的代码来完成这项工作,但我对LISP还不太了解。
 
谢谢你能提供的任何帮助。
711-24977文本宽度因子和字体更改示例。图纸
固定文本。lsp
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:32:48 | 显示全部楼层
时间不多了,还得做些工作
 
1获取所有文本
2使用vla get scalefactor查看每个文本
3秒
0.96-1.04 arial twf=1使用vla put stylename和vla put saclefactor
条件0.85-。95 arial窄twf=1
cond 0.96-1.04 arial twf=1
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 17:36:33 | 显示全部楼层
请附上样本图纸(用于测试代码)。
编辑:
下面是一个建议,以比加尔的步骤为基础(可能需要纠正):
  1. [b][color=BLACK]([/color][/b]defun C:test [b][color=FUCHSIA]([/color][/b] / SS i ent vla-obj scf[b][color=FUCHSIA])[/color][/b]
  2. [b][color=FUCHSIA]([/color][/b]if
  3.         [b][color=NAVY]([/color][/b]and
  4.                 [b][color=MAROON]([/color][/b]princ [color=#2f4f4f]"\nSelect text: "[/color][b][color=MAROON])[/color][/b]
  5.                 [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]
  6.         [b][color=NAVY])[/color][/b][color=#8b4513];and                [/color]
  7.         [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]
  8.                 [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]
  9.                 [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]
  10.                 [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]
  11.                 [b][color=MAROON]([/color][/b]cond
  12.                         [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]
  13.                                 [b][color=BLUE]([/color][/b]vla-put-stylename vla-obj 'ArialRegular[b][color=BLUE])[/color][/b]
  14.                         [b][color=GREEN])[/color][/b]
  15.                         [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]
  16.                                 [b][color=BLUE]([/color][/b]vla-put-stylename vla-obj 'ArialNarrowBold[b][color=BLUE])[/color][/b]
  17.                         [b][color=GREEN])[/color][/b]
  18.                         [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]
  19.                                 [b][color=BLUE]([/color][/b]vla-put-stylename vla-obj 'ArialNarrow[b][color=BLUE])[/color][/b]
  20.                         [b][color=GREEN])[/color][/b]
  21.                 [b][color=MAROON])[/color][/b][color=#8b4513]; cond[/color]
  22.                 [b][color=MAROON]([/color][/b]if
  23.                         [b][color=GREEN]([/color][/b]and
  24.                                 [b][color=BLUE]([/color][/b]not [b][color=RED]([/color][/b]= scf 1.0[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
  25.                                 [b][color=BLUE]([/color][/b]and
  26.                                         [b][color=RED]([/color][/b]>= 1.04 scf[b][color=RED])[/color][/b]
  27.                                         [b][color=RED]([/color][/b]<= 0.75 scf[b][color=RED])[/color][/b]
  28.                                 [b][color=BLUE])[/color][/b]
  29.                         [b][color=GREEN])[/color][/b]
  30.                         [b][color=GREEN]([/color][/b]vla-put-scalefactor vla-obj 1.0[b][color=GREEN])[/color][/b]
  31.                 [b][color=MAROON])[/color][/b][color=#8b4513]; if[/color]
  32.         [b][color=NAVY])[/color][/b][color=#8b4513];repeat[/color]
  33. [b][color=FUCHSIA])[/color][/b][color=#8b4513]; if SS[/color]
  34. [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b]
  35. [b][color=BLACK])[/color][/b][color=#8b4513];defun        [/color]
[/color
脚本只需根据需要重复多次
 
打开dwg1(c:grrchgtext)关闭Y
打开dwg2(c:grrchgtext)关闭Y
 
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 17:42:15 | 显示全部楼层
更新。。。。。。。我找到了另一种获得完全可搜索PDF的方法,前提是文本宽度因子和/或倾斜角度为默认值。
 
这是通过强制AutoCAD用ttf替换所有shx字体来实现的。
 
1)从工作站中删除shx字体,包括AutoCAD的默认单工。SHX。您必须删除。。。。我试着像TAH romans一样重命名字体文件。shx和AutoCAD仍然找到了它。然后我将文件夹重命名为TAH fonts,AutoCAD再次找到了它。我刚刚删除了所有*。我从C:搜索中找到的SHX文件。
 
2)编辑acad。fmp文件并删除所有条目。将文件另存为空白文件。
 
3.)将AutoCAD系统变量FONTALT设置为所需的字体。我用Arial。ttf。
 
4.)当AutoCAD加载时,它将尝试使用支持搜索路径设置中指定的路径查找dwg文件中使用的字体。由于无法找到它们,它将查看acad。fmp文件。由于此文件为空,它将再次查看在文本样式中定义的字体,并尝试在其他位置(文件夹)中找到它。由于仍无法找到文件,因此将使用存储在AutoCAD FONTALT系统变量(Arial)中的字体。ttf。
 
多行文字使用与shx字体等效的ttf显示在文本编辑器中。对于ttf字体它将首先在acad中查找。fmp是空的,然后在文本样式中定义的字体,然后Windows将替换一个类似的字体,在我的例子中是Arial。ttf。
 
打开图形后,将替换字体,并使用true type字体完成任何文件输出。这适用于使用简单的PDF打印驱动程序将DWF/DWFx转换为PDF或直接转换为PDF。
 
但是,如果文本宽度因子不等于1.0和/或文本倾斜角度不等于0.0,则仍然无法搜索该文本。
 
在我们的例子中,90%基于SHX的文本变得完全可搜索,而以前没有
 
希望这对别人有帮助!
回复

使用道具 举报

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:52:50 | 显示全部楼层
回复

使用道具 举报

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:56:38 | 显示全部楼层
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"?
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:07:33 | 显示全部楼层
Haven't tested it but is Grrr's code not working? But if you want a lisp guru to do some programming why not ask Lee Mac?
 
http://www.lee-mac.com/index.html
 
 
 
gr. Rlx
回复

使用道具 举报

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 18:12:43 | 显示全部楼层
I have tried contacting Lee but got no response.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:16:24 | 显示全部楼层
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
 
  1. 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]

the script just repeat for as many as required
 
open dwg1 (c:grrchgtext) close Y
open dwg2 (c:grrchgtext) close Y
 
回复

使用道具 举报

2

主题

9

帖子

7

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 18:21:54 | 显示全部楼层
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!
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 08:40 , Processed in 0.642701 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表