乐筑天下

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

[编程交流] Change %% in autocad

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 17:18:27 | 显示全部楼层 |阅读模式
Hey guys, i have searched this forum in hope for something to help me.
What's my problem :
I have many drawings each day (100-500) and i have to load them into a database. But the database gives errors if it finds %% in the drawing.
How can i make a simple script to auto search and replace %%C into Ø , %%D into º and %%p into ±
 
I'm searching for 3 days now and no result.
And something else, how can i add to the batch to auto delete any layout he finds in the drawing and to center the layout?
this would help me VERY VERY much with my tasks every day becouse it tend to repeat...and it's a time killer thing.
 
I know that I should use Lisp, i fould that Lisp is installed on my machine but i dont know the syntax of doing such things...
 
Thanks in advance !!!
回复

使用道具 举报

4

主题

940

帖子

961

银币

初来乍到

Rank: 1

铜币
12
发表于 2022-7-6 17:31:52 | 显示全部楼层
I don't know if this will work for but try Find/Replace...
 
From Help
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 17:38:50 | 显示全部楼层
Yes i know, but how do I make this into a command so I can include into an existing batch script?
I dont need a new script to do that, i can add this to a Save-as acad 2000 script and while the script will save as acad , it will change the %% also.
Many thanks for the quick response!
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 17:51:49 | 显示全部楼层
So , in autocad exists a find/replace command?
just a line of command to find a certain thing and a second command to replace the thing?
回复

使用道具 举报

0

主题

132

帖子

198

银币

限制会员

铜币
-21
发表于 2022-7-6 17:52:48 | 显示全部楼层
Here is a VB version
 
  1. Public Function MText_Unformat(ByVal sTxt As String) As String'------------------------------------------------------------------------------'Remove formatting strings''Value Examples:' \A Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top)' \Cvalue; Changes to the specified color' \Hvalue; Changes to the specified text height' \Hvaluex; Changes to multiple of mtext object's property' \L...\l Turns underline on and off' \O...\o Turns overline on and off' \P Ends paragraph/Carriage return' \Qangle; Changes obliquing angle' \S...^...; Stacks the subsequent text at the \ or ^ symbol' \Tvalue; Adjusts the space between characters' \Wvalue; Changes width factor to produce wide text' \~ Inserts a nonbreaking space' \\ Inserts a backslash' \{...\} Inserts an opening and closing brace' \File name; Changes to the specified font file''------------------------------------------------------------------------------Dim P1 As IntegerDim P2 As IntegerDim P3 As IntegerDim iStart As IntegerDim sComp As StringDim sReplace As StringDim sLittle As String'''''''''''''''''''''''''''''''''''''''Debug.Print sTxt'------------------------------------------------------------------------------'Remove alignment codes'------------------------------------------------------------------------------Select Case Left(sTxt, 4)Case "\A0;", "\A1;", "\A2;"   sTxt = Mid(sTxt, P1 + 5)End SelectiStart = 1'------------------------------------------------------------------------------'Replace octal code values with strings'------------------------------------------------------------------------------Do   P1 = InStr(sTxt, "%%")   If P1 = 0 Then       Exit Do   Else       Select Case Mid(sTxt, P1 + 2, 1)       Case "P"           sTxt = Replace(sTxt, "%%P", "+or-")       Case "D"           sTxt = Replace(sTxt, "%%D", " deg")       End Select   End IfLoopDo   P1 = InStr(iStart, sTxt, "", vbTextCompare)   If P1 = 0 Then Exit Do   sComp = Mid(sTxt, P1, 2)   Select Case sComp   Case "\p"       P2 = InStr(1, sTxt, ";")       sTxt = Mid(sTxt, P2 + 1)   Case "\A", "\C", "\f", "\F", "\H", "\Q", "\T", "\W"       P2 = InStr(P1 + 2, sTxt, ";", vbTextCompare)       P3 = InStr(P1 + 2, sTxt, sComp, vbTextCompare)       If P3 = 0 Then           sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P2 + 1)       End If       Do While P3 > 0           P2 = InStr(P3, sTxt, ";", vbTextCompare)           sTxt = Left(sTxt, P3 - 1) & Mid(sTxt, P2 + 1)           'Debug.Print sTxt, sComp           P3 = InStr(1, sTxt, sComp, vbTextCompare)       Loop           'sTxt = Left(sTxt, P3 - 1) & mid(sTxt, P3 + 1)   Case "\L", "\O"       sLittle = LCase(sComp)       P2 = InStr(P1 + 2, sTxt, sLittle, vbTextCompare)       If P2 = 0 Then           sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P1 + 2)       Else           sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P1 + 2, P2 - (P1 + 2)) & Mid(sTxt, P2 + 2)       End If   Case "\S"       P2 = InStr(P1 + 2, sTxt, ";", vbTextCompare)       P3 = InStr(P1 + 2, sTxt, "/", vbTextCompare)       If P3 = 0 Or P3 > P2 Then           P3 = InStr(P1 + 2, sTxt, "#", vbTextCompare)       End If       If P3 = 0 Or P3 > P2 Then           P3 = InStr(P1 + 2, sTxt, "^", vbTextCompare)       End If       sTxt = Left(sTxt, P1 - 1) & Mid(sTxt, P1 + 2, P3 - (P1 + 2)) _               & "/" & Mid(sTxt, P3 + 1, (P2) - (P3 + 1)) & Mid(sTxt, P2 + 1)                  Case "\U" 'Replace symbols with text       sLittle = Mid(sTxt, P1 + 3, 4)       Debug.Print sLittle       Select Case sLittle       Case "2248"           sReplace = "ALMOST EQUAL"       Case "2220"           sReplace = "ANGLE"       Case "2104"           sReplace = "CENTER LINE"       Case "0394"           sReplace = "DELTA"       Case "0278"           sReplace = "ELECTRIC PHASE"       Case "E101"           sReplace = "FLOW LINE"       Case "2261"           sReplace = "IDENTITY"       Case "E200"           sReplace = "INITIAL LENGTH"       Case "E102"           sReplace = "MONUMENT LINE"       Case "2260"           sReplace = "NOT EQUAL"       Case "2126"           sReplace = "OHM"       Case "03A9"           sReplace = "OMEGA"       Case "214A"           sReplace = "PROPERTY LINE"       Case "2082"           sReplace = "SUBSCRIPT2"       Case "00B2"           sReplace = "SQUARED"       Case "00B3"           sReplace = "CUBED"       End Select       sTxt = Replace(sTxt, "\U+" & sLittle, sReplace)   Case "\~"       sTxt = Replace(sTxt, "\~", " ")   Case "\"       iStart = P1 + 2       sTxt = Replace(sTxt, "\", "")       GoTo Selectagain   Case "\P"       iStart = P1 + 1       GoTo Selectagain   Case Else       Exit Do   End SelectSelectagain:Loop'------------------------------------------------------------------------------'Replace \P with vbCrLf'------------------------------------------------------------------------------Do   P1 = InStr(1, sTxt, "\P", vbTextCompare)   If P1 = 0 Then       Exit Do   Else       sTxt = Left(sTxt, P1 - 1) & vbCrLf & Mid(sTxt, P1 + 2)   End IfLoopFor iStart = 0 To 1   If iStart = 0 Then       sComp = "}"   Else       sComp = "{"   End If   P2 = InStr(1, sTxt, sComp)      Do While P2 > 0       sTxt = Left(sTxt, P2 - 1) & Mid(sTxt, P2 + 1)       P2 = InStr(1, sTxt, sComp)   LoopNext iStartMText_Unformat = sTxtEnd Function
回复

使用道具 举报

4

主题

28

帖子

27

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 18:02:59 | 显示全部楼层
Just type FIND in the command line.
回复

使用道具 举报

0

主题

132

帖子

198

银币

限制会员

铜币
-21
发表于 2022-7-6 18:17:48 | 显示全部楼层
Look for reptext.lsp
 
http://www.74mph.com/lisp.asp
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 18:19:22 | 显示全部楼层
I like zypa would be interested if anyone knows how to pass the "Find" Command the two lines it needs to work, I have asked this before I want to use it in a script.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 16:25 , Processed in 0.462213 second(s), 68 queries .

© 2020-2025 乐筑天下

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