乐筑天下

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

[编程交流] Utilizing AutoCAD's FIND

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:31:19 | 显示全部楼层
 
I would be inclined to use the power of Regular Expressions for this task:
 
  1. ([color=BLUE]defun[/color] c:FindStacked   [color=GREEN];; Find Stacked  -  Lee Mac 2011  -  www.lee-mac.com[/color]   ( [color=BLUE]/[/color] *error* _prompt _replace _dissect _textstring ent inc new old rgx sel str )   ([color=BLUE]defun[/color] *error* ( msg )       ([color=BLUE]if[/color] ([color=BLUE]and[/color] rgx ([color=BLUE]not[/color] ([color=BLUE]vlax-object-released-p[/color] rgx))) ([color=BLUE]vlax-release-object[/color] rgx))       ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg) [color=MAROON]"*BREAK,*CANCEL*,*EXIT*"[/color]))           ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nError: "[/color] msg))       )       ([color=BLUE]princ[/color])   )   ([color=BLUE]defun[/color] _prompt ( msg [color=BLUE]/[/color] var )       ([color=BLUE]while[/color] ([color=BLUE]not[/color] ([color=BLUE]vl-string-position[/color] 47 ([color=BLUE]setq[/color] var ([color=BLUE]getstring[/color] msg))))           ([color=BLUE]princ[/color] [color=MAROON]"\nPlease Enter a Fractional String."[/color])       )       ([color=BLUE]if[/color] ([color=BLUE]vla-object[/color] ent) str)               )           )           ([color=BLUE]vlax-release-object[/color] rgx)       )   )   ([color=BLUE]princ[/color]))
I have retained simplicity in the above code for clarity and consequently it is by no means bullet-proof. For a full application, I would include code to account for literal occurrences of "\\S" in the MText string, and occurrences of "/" amongst other characters in the numerator and denominator of the fraction; but above all, the code demonstrates the method I would follow.
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 09:33:36 | 显示全部楼层
Regular Expressions..
 
I never did get around exploring that method... yeah why not.
 
BTW: with codes utilizing VBScript and also ActiveX, would it still work for Autocad MAC versions?
 

EDIT: wrong Expression (pun)
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 09:39:30 | 显示全部楼层
Definitely no. There won't be any ActiveX over there so the vlax-get-or-create-object would already fail. Never mind that there also isn't anything like VBScript.RegExp to play with.
 
Edit: Painful ain't it? Another reason I'd like to see a Common Lisp interpreter inside AutoCAD: http://www.cliki.net/regular%20expression
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:42:21 | 显示全部楼层
 
Eye-roll?
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 09:43:16 | 显示全部楼层
 
Oh... i meant
 
I never did once use RegEx, even though i'm aware of it for sometime now
 
Humble apoligies Lee
 
EDIT: POST updated
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 09:48:38 | 显示全部楼层
 
Will it be the same case for NET?
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 09:49:11 | 显示全部楼层
Well, "at present" yes. 
If you glance at the video tutorial for making stuff in OSX: http://wikihelp.autodesk.com/AutoCAD_for_Mac/enu/2011/Help/Developer_Documentation/Migrating_Windows_Applications/ObjectARX_-_Mac_OS_X_Migration_Guide/Required_Development_Tools
 
You'll note they "glance over" the fact that none of DotNet works anywhere else than in Windows! Though they mention something about "AutoDesk is working on resolving this". I just wonder how long they've been "working" on it? And if there's any sort of progress. I know the biggest reason behind most programs not running in Linux through WINE is due to DotNet requirements, and WINE has been going at it for some years already. So I'm not holding my breath on the DotNet in OSX score!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:52:43 | 显示全部楼层
 
lol, no worries dude, just couldn't work out the tone of your original response was all
 
For tasks like these, Regular Expressions are well worth studying though - string substitution becomes a lot easier.
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 09:57:59 | 显示全部楼层
 
Thanks for the info Irneb.
 
 
I'll start reading on RegEx this week.
Thanks my friend
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:00:05 | 显示全部楼层
 
You're very welcome
 
To get you started, here is the MSDN reference for the RegExp object itself:
 
http://msdn.microsoft.com/en-us/library/yab2dx62%28VS.85%29.aspx
 
And here is one of the very best RegEx tutorials I've seen:
 
http://www.theswamp.org/index.php?topic=37030.msg420224#msg420224
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 06:15 , Processed in 0.705694 second(s), 70 queries .

© 2020-2025 乐筑天下

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