jtk07 发表于 2022-7-5 23:30:26

层状态通过lisp应用?

好的,我想做的是一个lisp文件,可以运行它来加载保存的。las(图层状态)文件,并将其设置为当前。有人对此有什么想法吗?我知道我可以手动一次处理一个文件,但是我有170多个文件,这会花费很长时间,我只是不知道命令行会是什么样子。如果有人能帮我写这篇文章,我想它真的会让layerstate自动化对每个人来说都很棒。将其设置为在夜间或空的工作站上运行,然后在早上进入,您的操作对我来说似乎很有用。
 
任何帮助都将不胜感激
 
JTK公司

alanjt 发表于 2022-7-5 23:35:10

尝试layerstate-*命令。
 
直接从帮助:


[*]layerstate-addlayers
Adds or updates aseries of layers to a layer state
[*]layerstate-compare
Compares a layerstateto the layers in the current drawing
[*]layerstate-delete
Deletes a layerstate
[*]layerstate-export
Exports a layer stateto a specified file
[*]layerstate-getlastrestored
Returns thename of the last restored layer state in the current drawing
[*]layerstate-getlayers
Returns the layerssaved in a layer state
[*]layerstate-getnames
Returns a list of thelayer state names
[*]layerstate-has
Checks if a layer state ispresent
[*]layerstate-import
Imports a layer statefrom a specified file
[*]layerstate-importfromdb
Imports a layerstate from a specified drawing file
[*]layerstate-removelayers
Removes a list oflayers from a layer state
[*]layerstate-rename
Renames a layerstate
[*]layerstate-restore
Restores a layer stateinto the current drawing
[*]layerstate-save
Saves a layer state inthe current drawing

jtk07 发表于 2022-7-5 23:37:35

这就是我得到并将继续得到的
“命令:layerstate importfromdb
未知命令“LAYERSTATE-IMPORTFROMDB”。按F1键获取帮助。"
 

Lee Mac 发表于 2022-7-5 23:43:09

 
这是一个AutoLISP函数,不是命令-请阅读VLIDE帮助文档。

jtk07 发表于 2022-7-5 23:44:50

我太迷路了哈哈!对不起大家,我确实收到了一条非常有趣的消息。我想和大家分享一下,也许会朝着这个方向发展。
 

No need to run this on another machine - ObjectDBX only needs +/-20 seconds to open, change the layer state, and save all 170 drawings.

THAT is why I suggested it... it's lightning fast!!!

However, there are some restrictions....

For example, you cannot issue normal AutoCAD commands like ._qsave, and ._close. You MUST use Visual LISP syntax functions like vla-open, and vla-close found within the ActiveX COM API.

You can read more about ObjectDBX here, as well as learn some basics for good programming:

Good Habits for Coding in Visual LISP

Here's an excerpt:

                                                      Efficiently Opening Files, or “Warp Speed, Captain!”

ObjectDBX allows you to access drawings without loading them in thedrawing editor. This results in a huge improvement in processing speedat the expense of not having the user interface. The lack of a userinterface means that you cannot use selection sets. There may also beissues when modifying objects such as attributes. It is also useful fordecomposing complex objects without the risk of modifying the originalobject or its host drawing.

The performance gains make ObjectDBX an excellent tool for queryingmultiple drawings. For example, many firms have developed applicationsthat allow them to create and maintain sheet indexes across hundreds ofdrawings in seconds rather than hours.

ObjectDBX cannot directly work on drawings that are read-only ortemplates. Therefore, a simple wrapper function that detects thoseconditions and provides a temporary drawing file to use in such a caseis useful.

Lee Mac 发表于 2022-7-5 23:47:55

如果您希望使用ObjectDBX,这可能会对您有所帮助。
 
http://lee-mac.com/odbxbase.html

alanjt 发表于 2022-7-5 23:51:38

这是一个函数,不是命令。
呼叫方式:
(layerstate-import <FileNamehere>)
 

jtk07 发表于 2022-7-5 23:53:44

是的,我理解,现在的问题是如何将其应用于lisp或objectDBX?代码是什么?请记住,我正在尝试从导入的las文件恢复layerstate
 
 
当你转到autocad 2011时,我再也看不到帮助屏幕了。你使用的在线帮助更像是没有答案的在线循环。
 

irneb 发表于 2022-7-5 23:57:25

假设您的LAS文件是c:\Test。LAS中的状态称为StateTest。您可以将其输入到当前图形,因此:
现在设置模型空间的状态测试:
如果只想将状态恢复到视口,则需要首先获取VP的ename。E、 g.如果要将状态恢复到当前DWG中的所有视口,并使用视口覆盖,而不是为所有图层设置颜色和线型:
(setq ss (ssget "_X" '((0 . "VIEWPORT"))) n (sslength ss))
(while (>= (setq n (1- n)) 0)
(layerstate-restore "StateTest" (ssname ss n) 4)
)

jtk07 发表于 2022-7-6 00:00:10

irneb,我非常感谢你的帮助。
 
首先,我将把这些更改应用于图纸文件,而不是按视口,因此我假设它是与模型空间相同的方法。
 
我需要(命令)或(defun)什么吗?或者Lisp程序需要这样吗?
 


;
(defun c:test)
(if (layerstate-import "I:\DRAWINGS\090-0056 LFMP\Common\ME_Layer_State.las")
(princ "ME_Layer_State.las has been imported.")
(princ "There was an error importing ME_Layer_State.las")
)
(if (layerstate-restore "ME_Layer_State" nil)
(princ "ME_Layer_State has been restored.")
(princ "There's an error restoring ME_Layer_State")
)
页: [1] 2
查看完整版本: 层状态通过lisp应用?