乐筑天下

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

[编程交流] DCL/LSP开发-Consta

[复制链接]

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 15:52:16 | 显示全部楼层
感谢您的反馈。在过去的一个月里,我得到了许多在这个帖子中发布的相同的结论/解决方案,我只是希望得到一些我很愚蠢的东西,忽略了一些可以使我在lisp/dcl中的编码生活更容易的东西。
 
我一直在研究的DCL有大约40个不同类型的控件,作为我在17年前的2001年编写的控件分析的UI。
 
在这段经历之后,我的下一步是学习如何在Visual Studio/C中执行此操作。
 
实施的一些具体步骤:
1) 创建了一个包含所有DCL控件名称的字典,以进行验证-避免拼写错误
2) 编写了“get\u tile”、“set\u tile”、“tile\u mode”等的包装函数,以确保使用正确的键和值。
3) 使用控件名称字典来存储值,以及“enabled”或“disabled”(因为我还没有找到一种方法来获取键的当前“tile\u模式”)。
4) 编写了一些调试函数来记录整个代码中的状态和错误,此外还有一个推堆栈(在函数的开头)和弹出堆栈(在函数的末尾),用于跟踪代码路径并将其记录到文件中。
5) 尽量为可重用的小任务抽象函数。
6) 写入包含VL-BT命令的*错误*处理程序以“转储”调用堆栈。
7) 打开autocad日志文件,这样如果autocad确实崩溃,我至少有一个指示,说明在哪里可以纠正问题(VL-BT写入日志文件)
6) 对于我的DCL前端,设置默认值、控制验证、控制事件逻辑、存储/恢复设置等。我使用了80多个函数和1600多行代码。当我找到更好的实现方法时,我认为相对简单的更新几次变成了完全重写。
 
遗留的一般问题:
1) 在执行期间将日志信息写入文件-如何强制写入文件,而不是缓存数据并稍后写入。
2) 将VL-BT输出写入日志文件(而不是主autocad日志文件)的方法
 
我希望这可能对其他人有用。
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 15:57:46 | 显示全部楼层
@Grrr和TOTAL oftopic
  1. (defun tst ( / start a b c d e f g h i j k l m)
  2. (defun nonil (%vl) (mapcar '(lambda (x) (if (null (vl-symbol-value x))(set (read (vl-symbol-name x)) ""))) %vl))
  3. (defun nil->dquote ( nil->dquote:L )
  4.    (foreach nil->dquote:x nil->dquote:L (set nil->dquote:x (cond ((vl-symbol-value nil->dquote:x)) (""))))
  5.    (mapcar 'eval nil->dquote:L))
  6. (setq start (car (_vl-times)))
  7. (repeat 10000
  8.    (mapcar 'set '(a b c d e f g h i j k l m) '(1 2 3 4 5 6 7 8 9 0 nil nil nil))
  9.    (nonil '(a b c d e f g h i j k l m)))
  10. (princ (strcat "\n\nProcessed nonil in " (rtos (/ (- (car (_vl-times)) start) 1000.) 2 4) " secs."))
  11. (princ "\n\n\n")
  12. (setq start (car (_vl-times)))
  13. (repeat 10000
  14.    (mapcar 'set '(a b c d e f g h i j k l m) '(1 2 3 4 5 6 7 8 9 0 nil nil nil))
  15.    (nil->dquote '(a b c d e f g h i j k l m)))
  16. (princ (strcat "\n\nProcessed nil->dquote in " (rtos (/ (- (car (_vl-times)) start) 1000.) 2 4) " secs."))
  17. (princ)
  18. )
  19. (tst)

是的,它(你)更快
好吧,回到工作,似乎突然(在这里工作)每个人都想在这周分享我,不管怎样,我的注意力
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 16:01:13 | 显示全部楼层
 
很好的快速基准测试-第2天学到了一些新东西!
 
顺便说一句,如果它们的定义如下,则比较更准确:
  1. (defun nonil (%vl) (foreach x %vl (if (null (vl-symbol-value x))(set (read (vl-symbol-name x)) ""))))

 
  1. 8

 
我在子对象中使用了foreach函数而不是mapcar(因为mapcar映射的是一个函数,并且比foreach慢)。
在mine中删除了(mapcar’eval L)部分,因为在这种情况下,不需要返回。
但结果是一样的——再次比较。
 
 
 
 
它是书面的
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:06:04 | 显示全部楼层
how about just
  1. (defun Grrrill (%vl) (foreach v %vl (set v (cond ((vl-symbol-value v)) ("")))))
, for short
 
 
nah, first some (power distribution) lists were in autocad , then oh no! , not good! , must be excel , and now (years later) , oh no! not good! , must be autocad. Fine with me , but no money (order number) no deal...
 
 
almost weekend
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:08:45 | 显示全部楼层
 
 
Didn't see your post before but it looks like we're the ones asking you for advise from now on
 
 
I assume C# has the same dcl abilities as VBA (a graphic DCL editor) and more. Only things that really matter are verify your data before starting dialog , make sure you have a working exit button and no command calls during active dialog... rest should be peanuts for you!
 
 
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 16:12:17 | 显示全部楼层
 
I'd say coding with LISP is alot easier and flexible, than other languages.
DCL is alot different (and limited), than designing User/Windows Forms, because you do it thru pure coding -
Cycle of:
1.Write/Modify the DCL code
2.Display the dialog in ACAD to check its design
 
On the other hand, you can quickly get used to working with C#'s WindowsForm projects on Visual studio but the main problem would be looking for techniques to do "this" and "that" in ACAD.
Another alternative for easier design of dialogs and being not-so limited at accessing objects'n'classes would be through VBA.
BTW the Form's controls have more events than DCL's tiles - for DCL you can check if something's being clicked/double-clicked,
while when using forms you can check if the cursor is hovered inside/outside of the control and if some KBD key has been pressed.
 
If I was you I would list exactly(be alot more specific) what I want - i.e. "upon what *events* that are possible in this language, to perform what exact algorithm/steps that are logical for the code".
Say:
 
During execution of what? Pressing an 'execute' button? Running the dialog itself?, the command-call, Autocad?
About the force writing you could try something with the logfilename system variable.
 
 
IMO unless you don't have a certain idea to develop, that could not be done with the language you are using - the switch to a higher-level language is useless.
 
BTW Heres a C# demo, that uses WindowsForm to gather few inputs and write them to a .txt file -
But you could do the same with LISP&DCL
 
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:13:27 | 显示全部楼层
before I flush my work computer and begin my weekend : (gc) or garbage collection , forces all buffers to clear so usually I combine (close fp)  with (gc)
 
 
well , enough for this week , here @ work that is , have a good weekend
 
 
nice demo Grrr!
 
 
gr. Rlx
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:20:19 | 显示全部楼层
@rlx - there is much I don't know, but I am still learning.  This forum has helped me greatly as many of my questions had answers / solutions posted.  
 
@grrr - i agree, once you get the hang of LISP, it is quite easy and flexible.  I have done some development in C#, and creating a UI with events, validation, etc. is sure is a lot easier compared to DCL where there is complexity.
 
Regarding the log file - I am using the AutoCAD system variable logfilename, and it does write the results of VL-BT to the file (even when I cause ACAD to crash).  While executing my lisp code, and writing to a separate log file, when it crashes, not all information is written to the log file.  What I would like to understand is how to force writing while my program is executing, so if it does crash for some reason, I have all the logging information to correct the issue.  VL-BT has helped me out a lot but I cannot figure out a way to write that output to my log file (not the logfilename system variable file - if this makes sense.
 
Is it possible to capture the output from VL-BT and redirect it to the a log file?
 
As suggested by rlx, I will try (gc) to see if this will help force writing to a file.  I will try putting a (gc) in my write file function.  Thinking about it now, I could just close/reopen the file (which would add overhead and slow down the code)...
 
I will also zip up my project and share it with the group... maybe I am making this more complicated than it needs to be!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 13:04 , Processed in 0.428189 second(s), 67 queries .

© 2020-2025 乐筑天下

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