我很乐意帮助史蒂夫,
至于你的问题,我想这取决于你想要什么样的数据。一些函数使用列表,而其他函数使用变体作为输入。
例如
如果您想在移动操作中使用圆心(设置为变量obj),可以使用类似的方法来获取中心点:
17
将返回一个列表:
18
然后在移动操作中使用它:
19
但是,正如我们所知:
20
是一个变体,那么我们不需要在移动操作中使用(vlax-3D-point pt)将其转换为一个:
21
所以,你看,有时我们想要处理列表,有时我们想要坚持变体。
希望这能让事情变得更清楚。
李 是的,很好的例子,这很有道理,李。我想,虽然我是vlisp新手,但我可能会坚持使用它。
这与线程主题有点相切,但我有另一个一般的vlisp问题,我已经查找了这些函数的帮助文件,虽然这很有意义,但如果有人能用虚拟语言告诉我它们的必要性,那就太好了。
我注意到,在许多vlisp程序中,一开始就有以下功能:
22
这些功能(尤其是后两个)如何影响输出?例如,Patrick在代码开头编写的程序似乎适用于paperspace,即使我从modelspace运行它。。。
这个函数的必要性是另一个函数(),我无法集中注意力,但只有当有人不太忙的时候。
非常感谢你的帮助。 好的,史蒂夫。。。一次一个
首先,“doc”调用。
好的,VLisp中的许多函数引用document对象,并通过以下方式检索该对象:
多次对程序来说不仅非常慢,而且被认为是不好的做法。因此,对于大多数程序员来说,如果他们知道他们将不止一次使用document对象,那么他们只需首先调用它,并将其设置为变量,以保存多次调用(vlax get acad object)。
好啊现在进入paperspace和modelspace对象。
使用以下功能时:
这些函数将执行操作的块作为其第一个参数。现在,不要将此处与AutoCAD“块”混淆。
VL块可以是块定义(AutoCAD块定义),也可以是图纸空间/模型空间对象。
因此,程序需要知道用户当前在哪个空间工作,以便函数可以将对象插入正确的空间。因此,程序员通常会执行某种条件检查,要么使用TILEMODE sys var,要么使用vla get ActiveSpace函数,返回类似的结果,然后相应地调用Paperspace或Modelspace块。
我想我会在另一个帖子中解释这个函数,以免混淆问题。
李 好的,函数函数。
这告诉解释器/编译器(将代码转换为机器对话的东西),您提供的参数将被视为函数。
您可能已经在许多mapcar/lambda表达式中看到了这一点:
25
这相当于写:
26
[除了功能的使用对于程序来说更快]
因此,正如撇号告诉解释器不要计算它后面的表达式,而是将其作为参数。函数符号,告诉解释者将表达式本身视为函数,并进一步将其视为参数。
有关撇号的更多信息,请参见此处:
http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20
希望这有帮助,
李 谢谢李。我仍然有点不确定哪些函数需要引用
但是我相信随着我研究更多的vlisp程序,它会变得更加明显。
有趣的是,我知道这句话,但我不知道功能更快。
Woah....
You can only use "function" when you are declaring a function....
The list that you are using in ssgetis not a function, but a list.
The alternative to the apostrophe in that case is:
(ssget "_X" (quote ((0 . "LINE")(62 . 3))))
Sorry, for the confusion - I should've made that clearer.
Just to clarify, in the mapcar call for example, you could use:
(mapcar (function +) (quote (1 2 3)) (quote (4 5 6)))
[ Just as an aside, I don't think the quote function is any quicker than the apostrophe ] As for functions that use the document object.
You provided two of them yourself:
(vla-get-paperspace doc)(vla-get-modelspace doc)
Others can be:
(vla-get-layers doc)(vla-get-layouts doc)(vla-get-linetypes doc)(vla-get-blocks doc)etc etc
Lee Thanks for clarifying. And sorry, what was I thinking... function on a list.
...I wish there was a way of collating all these theory lessons into one place; they always seem to come around off the back of a program thread.
I know what you mean - I think there is going to soon be a section in the FAQ for LISP tutorials, but at the moment, I am just keeping a log of the links to each post for future reference. Hello,
I don't really want to start a new thread with this question, I was just wondering how I find what layout an object is on? (vla-get-layout obj) doesn't seem to be recognized.
页:
1
[2]