Freerefill 发表于 2022-7-6 12:17:27

一批

所以,我看到了几个请求(它们似乎经常弹出!)对于允许用户将某些功能应用于集合中的多个图形的程序/工具/脚本/whathaveyous。
 
很多建议都被传开了,一直以来,我都在使用我自己的一个作品,这是我几乎整整一年前创作的。我相信我在不久前发布了一个版本,但即使在那时,我也不满意。这并没有达到这个论坛的标准,也没有达到我自己不断提高的标准。它起作用了,所以被使用了。这差不多就是它的意义所在。
 
然而,批处理程序的请求不断涌现,我对一年多的工作越来越不满,这促使我咬紧牙关,从头开始重新编写。我花了一个月的时间,但我对结果很满意。您可以将几乎任何功能或功能集应用于任意数量图形上的任意数量的选项卡,任意次数。
 
因此,我谦恭地介绍FinalBlitz。我真的希望每个人都觉得它有用。
 
该程序当前设置为查找。dcl文件,尽管您可以根据需要对其进行修改。如果有人需要帮助,请随时给我留言。
 
此外,请对此进行评论。这是我第一次尝试DCL,我承认,它相当破旧。
 
这也是第一个版本,随着时间的推移,我会对其进行改进。
 
非常感谢。
 
~~~***~~~
 
*编辑*版本4现已上载。
 
以下是程序中的第二个标头,为方便起见复制到此处。它确实存在于代码中,因此如果需要帮助,您可以查看它。现在提供了解释和示例。
 
黄铜钉:
只要上述标题保持不变,该程序就可以自由使用和分发。
修改代码的用户有权修改上述标题以反映其工作
只要标题保留所有以前的信息。
问题、建议和意见可发送至:
oofreerefilloo@gmail.com
 
我会非常乐意帮忙做任何事。
 
说明:
该程序旨在成为一个准批处理引擎,目标是允许
用户可以以某种“宏”样式运行任意数量的命令或函数
AutoCAD图形集。
 
该程序在一个简单的前提下运行:如果没有选择图纸列表,则应用
当前图形的选定功能。否则,创建一个脚本,该脚本将
打开列表中的第一个图形,并在其上运行所选函数。只要
文件保留在列表中,在所有函数完成后,脚本将
重新编写并再次运行,从而关闭受影响的图形并打开
列表中的下一个,依此类推。
 
请注意,该程序创建了两个文件:
最终LitzScript。可控硅
最终文件列表。txt文件
默认情况下,它将位于用户C:驱动器中。
 
还请注意,该程序使用DCL文件。这个文件的默认位置是你的C:驱动器,但是你可以把它放在任何地方
只要您更改tabDia和dwgDia函数中的代码。
 
用法:
数据以以下形式传递给(finalblitz)函数:
(finalblitz)
哪里:
-用户希望应用的所有功能及其适当输入的列表
-选项卡的数字列表或适当的字符串,定义要操作的选项卡集
-图纸列表,格式正确,包含完整目录和扩展名
-在继续操作之前强制检查的可选切换
-一个数字指示器,用于确定该过程应重复多少次
 
请注意,所有输入都可以为零。程序将首先检查传递的输入,只要输入为零或格式不正确,
程序将继续提示用户输入上述信息。一旦所有输入都令人满意,程序将继续运行。
 
对于所有传递的为零或格式不正确的数据,导航提示菜单以定义所需的数据。
菜单的格式是,前四个选项将允许您浏览菜单和所有其他选项
选项是可选的。这一点很快就会变得更加清晰。
 
如果要传递所有nil输入(finalblitz nil nil nil nil nil),您将看到以下提示:
>>选择选项或[选项卡/绘图/检查/重复][多个]:
这是初始提示。菜单分为两部分。
前四个是导航选项。同样,这些允许您在菜单系统中导航并选择选项。
剩下的是允许您设置的特殊选项。
 
选项选择:
>>选择选项或[选项卡/绘图/检查/重复][多个]:
对于选项选择,只需键入与所需选项对应的字符串。可用选项位于optSel函数中。
对于optSel函数中条件语句的一部分以外的任何选择,系统将提示您再次选择。
如果您希望使用多个选项,可以通过键入“M”来切换
 
选项卡选择:
>>选择选项卡或:
对于选项卡选择,您有熟悉的导航选项(参见“选项卡”现在如何消失,以及“选项”如何回来?),这一次,还有其他几个。
“布局”将选择所有布局选项卡,如果您选择一个集合,这将适用于所有图形。
“This”将适用于当前查看的选项卡。
“模型”将仅将功能应用于模型选项卡。
“特殊”将允许您键入格式正确的字符串,以数字方式选择布局选项卡。
字符串必须以特定样式格式化,例如:1,2,4-6将选择“模型”选项卡以及第一、第三、第四和第五个布局选项卡。
“对话框”将打开一个小对话框,供您选择所需的所有选项卡。
请注意,您必须键入“DIA”,因为只需键入“D”即可打开图形选择菜单。
 
图纸选择:
>>选择图形或[选项/选项卡/检查/重复][对话框/文件/清除]:
默认情况下,图形选择可能为“无”,但在此处可以更改。
“对话框”将打开一个对话框,允许您导航和创建图纸列表。
“文件”将允许您以列表格式查看文件。
“清除”将清除您的选择,并且您的功能将仅在活动文档上运行。
 
检查切换:
>>切换检查或[选项/选项卡/绘图/重复][是/否]:
非常简单。如果“检查”处于启用状态,则在程序运行之前会提示您接受或放弃您的设置。
如果“Check”没有打开,它只会继续执行。
 
重复选择:
>>选择重复或[选项/选项卡/绘图/检查][重置/无限]:
输入任意整数以指定所选函数应重复自身的次数。
如果必须打印图形的多个副本,这一点尤其有用。
“重置”将重复数重置为1,“无尽”将永远重复(或直到你逃脱)。
请注意,您不能输入零次重复。
 
要创建唯一的函数,只需复制现有条件并编辑数据。
每个条件中都有一个条件。这些嵌套条件表示每个函数的各个部分。
第一个条件在所有情况下都返回True。这样程序就可以检查该选项是否可用。
第二个条件是测试。可以在此处检查所有传递的输入,以确定传递的输入是否正确。
请注意,此检查是可选的,如果您不希望设计检查,则可以简单地返回True。
第三个条件以以下格式返回列表:(…)
您可以创建一个自定义函数,该函数以这种形式返回数据,第二个条件可以检查该函数,第四个条件可以使用该函数。
第四个函数按预期使用传递的数据。这将在示例中变得更清楚。
 
示例:
要了解选项选择在FinalBritz中的工作方式,请尝试运行以下例程:
注意,您只需复制并粘贴(finalblitz…)函数输入到命令行中。
(defun c:cir1(/)(finalblitz’(((“CMD”(vl cmdf“circle”(getpoint)5)))'(“THIS”)t t 1))
注意所有参数是如何设置的。运行此功能不会提示用户。
本例使用“CMD”函数,将列表中的第二项作为单个命令进行计算。但事实并非如此
必须是vl cmdf表达式,但任何单个LISP表达式,包括LISP本身,例如(c:LISP)。
运行此表达式将提示用户输入一个点,并在该点上创建一个圆。
 
稍微混合一下,
(defun c:cir2(/)(finalblitz’(((“CMD”(vl cmdf“circle”(getpoint)5)))'(“THIS”)t t 3))
请注意,唯一的区别是“重复”因子已更改。现在,系统将提示您创建三个圆。
还请注意,当您运行此命令时,vl cmdf表达式只是整体重复了三次。
 
要更好地了解此函数的强度,请尝试以下方法:
(defun c:cir3(/)(finalblitz’((“CMD”(vl cmdf“circle”(getpoint)5)))'(“LAYOUTS”)t t 1)
同样,这就像第一次一样,只是这一次,您的图形将切换到所有布局选项卡并提示您
创建圆。
 
现在,让我们玩一玩。是时候探索一下菜单选项,真正了解它的功能了。
 
运行此函数。现在你会看到,它提示你提供更多信息。
(定义c:cir4(/)(finalblitz nil nil t t 1))
第一个提示让您选择一个选项。键入“CMD”并点击“回车”
您将看到的下一个提示是输入Visual LISP代码。类型:
(vl cmdf“圆形”(getpoint)5)
然后点击“回车”。您将返回选项菜单,但您将看到您的选项打印在表单中
您可以在前面的示例中看到。现在,键入“T”进入“Tab”菜单,再次键入“T”选择“This”
单击enter键后,系统将提示您输入一个点,然后再次创建一个圆。
 
对于最后一个示例,请确保已下载。dcl文件并编辑此代码以正确引用它。
为了使其尽可能简单,我们将返回第一个示例,进行一个小的编辑:
(defun c:cir5(/)(finalblitz’(((“CMD”(vl cmdf“circle”(getpoint)5)))'(“THIS”)nil nil 1)
你可以在这里看到,这次唯一的区别是两个“t”现在是“零”。这

Small Fish 发表于 2022-7-6 12:27:44

Just some constructive critism:
 
I find it very hard to work out what it does?
 
The first thing is: what does
Select Option or mean ?
I would expect a dialog box to appear first after internal checking.
Also the dialog box is very cryptic.
 
In the line - you can not have an argument and a declared local variable on the same line:

(defun dwgDia(filLst / diaID1 endWhl root dirLst filLst addLst remLst lstClk rotLst chTile lstIni);
 
Just my 2 cents worth......

Freerefill 发表于 2022-7-6 12:31:12

 
I explained what it does, it allows you to run commands in a batch format, mainly on several files.
 
And yes, there are two dialog boxes in the program, one is for tab selection and one is for file selection. I don't think the dialog box is -that- cryptic, though I'm sure a few labels here and there couldn't hurt.
 
The opening dialog.. well, you choose what you want. Here, I'll try to give a rundown. I'm not at my terminal at the moment so it'll have to be mainly from memory.
 
There are five main selections: Option, Tab, Drawing, Check, Repeat
 
Option lets you select which function you want. I suppose a list of what functions are available would be helpful... I'll add that in.
Tab lets you select which tabs you want. So far there's no default selection, but you can select the Model tab, Layout tabs (as a group), a numerical input (1,2,4-6 that sort of thing) or open up the tab dialog box.
Drawing lets you select which drawings you want.
By default, once those three options are selected, the function will run. You can, however, turn Check on (the fourth option) so that it will only run once you approve of your settings.
Repeat is how many times it will repeat your function
 
As for the passed argument, yeah, I didn't spot that. Mainly because I spent the last two weeks getting the bloody thing to work. I've never used DCL before, it was my first attempt. I'll fix that.
 
To get an idea of what it's useful for, try this:
1. Open up a new drawing.
2. Draw something, or some things. Anything random will do.
3. Copy the stuff to your clipboard (Ctrl+C)
4. Run the program
5. Select, as your option (that is to say, type it at the first prompt), 400
6. Hit "T" to switch to the Tab option set
7. Type "L" for all layouts
 
Once you enter "L", the program should automatically run through all the tabs in your drawing, and paste your clipboard selection at basepoint 0,0.
 
Try creating a few blank drawings, and testing out the Drawing option. Note that by default, nothing is saved. So, you will have to turn on the Multiple toggle in your option selection, and you can select option 400, as well as "Save".
 
If you have any other questions, feel free to ask.

rustym 发表于 2022-7-6 12:39:54

Can you explain the option "400"? Where does this come from?
 
(sorry for silly looking questions, I'm hoping to get into the lisp world soon.)

Freerefill 发表于 2022-7-6 12:46:52

All the options are in the "optsel" function. That function is a condition statement which first checks the option (you'll note that all options are lists, and each list starts with a string, which indicates the option you wish. All other items in the list are pieces of information that that option will use.) and then returns a value depending on what value you're looking for (the "op" variable that gets passed is used in the nested condition statements, and that decides which value is returned by those nested statements.).
 
As for the actual name of it, in my previous batch program (which is too much of a mess to bother posting here), my initial options were for printing/plotting, and those were all numerical between 1 and 100. As I began to realize its flexibility, I decided to organize the numbers between 1 and 1000 into groups of 100, each group with a unique task (global plot functions, modified plot functions, drawing manipulation, etc). In the early stages of this batch program, I took the same theory, but since I was focused more on the program and not on the options, I tended to go with the first thing that popped into my head. In this case, "400", "401" and "402" were all "paste clipboard" functions, which I later found I could combine into a single "400".

rustym 发表于 2022-7-6 12:54:36

o alright, thanx. Lets play some more with this and see what I can achieve.

SteveK 发表于 2022-7-6 13:02:57

Hi Mark,
 
First of all thanks for sharing, that looks like it would have taken ages and I reckan with a bit of polishing you could make it a pro product.
Secondly, can you help me with this? I'm wanting to run simple code with your program.
And to do this I've put in
(finalblitz '(("CMD" ChAtt)) nil nil nil 1)
Then selected the drawings, and then tried to select all tabs ("T" for tabs then "L" Layouts then "y" for accept). Aside: How can I skip this step? (as my code doesn't use layouts)
Then it goes to work but nothing changes. Does it save? I've made sure the block and tag exist.
Here's the function:

(defun c:ChAtt (/ blkname attTag ss newStr subEn) (if (AND ;(not (eq         (setq blkname "Border 0") ;(getstring "\nEnter Block Name: ")) ""))      ;(not (eq         (setq attTag "TITLE1") ;(getstring "\nEnter Attribute Tag: ")) ""))      (setq newStr "HELLO") ;(getstring "\nEnter New String: "))      (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 blkname))))      )(foreach en (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))    (setq subEn en)    (while (AND (setq subEn (entnext subEn))      (eq (cdr (assoc 0 (entget subEn))) "ATTRIB"))      (If (eq (cdr (assoc 2 (entget subEn))) attTag)    (entmod (subst (cons 1 newStr) (assoc 1 (entget subEn)) (entget subEn)))    )      )    )) (princ) )Thanks

Freerefill 发表于 2022-7-6 13:09:22

 
Thank you for your kind words. You are absolutely correct, it does need a fair deal of polishing. I've been very much focused on the functionality and, since I don't have much spare time for this, actually putting it to use. As such, cleaning it up to make it user friendly is an aspect I am sadly lacking, but am aware of. I will try harder. ^.^
 
The aside first.. you can put the text '("LAYOUTS") in place of the first 'nil', and the last nil (before the 1) is there to provide a last "check" to make sure your settings are correct, you can bypass that by setting that 'nil' to 'T'. It'll look something like this:
 
(finalblitz '(("CMD" ChAtt)) '("LAYOUTS") nil T 1)
 
The way the program works is sort of like this: you pass input to it, and if the input is not valid or doesn't exist, it'll bring you into a text-based interface that prompts you for said input. If you wish, you can pass a full set of input to finalblitz and not have a prompt at all! Currently that won't work for a drawing set (only the current drawing), but I'm working on that~
 
As for your second question regarding saving.. finalblitz is the "big brother" of my previous batch LISP, called blitzprint. As its name implies, blitzprint was initially used for printing layout tabs. After I hit the limits of its functionality, I made finalblitz. However, there were a few carry-overs, namely, blitzprint didn't save the drawing. I didn't see the need to open a drawing, print it, then save it if no changes were made.. so by default, it didn't save. Finalblitz is the same.
 
However, finalblitz is delightfully more robust, and I included an option to save your drawing after making your changes. You can include that option by simply adding it to the option list, like so:
 
(finalblitz '(("CMD" ChAtt)("SAVE")) '("LAYOUTS") nil T 1)
 
Finalblitz will run all options in the option list, so you can do many things at once. You are, however, limited. There is a 255 character limit I believe, when sending things to the command line. So you cannot string too many options together. You can, however, craft your own options or sub-functions, so you can combine many into one. In that regard, it's quite customizable.
 
A final word, most LISPs I've run into that are to be run via another LISP have difficulties using the actual command of the LISP (that sounds kind of confusing.. imagine trying to use (command "chatt"), it won't work). You can get them to work, however, if you turn the command into a function, like so: (command (c:chatt)). So if your function isn't running each time a drawing is opened, try this:
 
(finalblitz '(("CMD" (c:ChAtt))("SAVE")) '("LAYOUTS") nil T 1)
 
I hope this answers all your questions, and thank you again for your kind words. If you need any more help, don't hesitate to ask. ^.^

SteveK 发表于 2022-7-6 13:15:00

That's excellent, it works! thanks Mark
 
I'm not sure if you've detailed it but I realized finalBlitz.lsp and whatever other lisps the user runs with it need to be loaded into the startup suite so that they'll load with each drawing. This is correct?
 
Anyways, I think I'll find plenty of further use for a robust program like this.

Freerefill 发表于 2022-7-6 13:18:48

I'm very glad it works, Steve. I do hope it will come in good use in the future. If you have any ideas or suggestions, please let me know. I currently want to work on a more advanced dynamic command check, a way to automatically import a file list, and I know I gotta clean up those dialog boxes. I'm also trying to think of a way to run scripts, and I think I know of a good one, although it's a little hack. At any rate, I'm overjoyed (and more than a little relieved) that it works. Thank you. ^_^
 
Finalblitz.lsp does indeed need to be loaded with every drawing, since the program writes a script which, in turn, runs the program (itself), so naturally it needs to always be loaded, otherwise it won't be able to run itself. Think of it like this: the program is split into two parts, first the data collection, then using the data. If you write that data to, say, a .scr file, you can then run that script, which will let you open a new drawing, and run your saved data on that new drawing. The way it does this is by simply skipping the "data collection" part and feeding the data directly into the "using the data" part. I should point out that, in that regard, only Finalblitz.lsp needs to be loaded, as "using the data" doesn't bother with either of the dialog boxes. Textfind2.lsp is just an outside function that I included as an example, a way to batch replace text (also to batch an outside function), so that doesn't need to be in your startup suite either, unless you want to use it.
页: [1]
查看完整版本: 一批