乐筑天下

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

[编程交流] entmake Lisp中的多行

[复制链接]

55

主题

293

帖子

239

银币

后起之秀

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

铜币
275
发表于 2022-7-6 10:48:42 | 显示全部楼层 |阅读模式
大家好。
 
这是我在这个精彩的论坛上的第一篇帖子,我希望我能在这个宝贵的论坛上受到欢迎。
 
我知道如何处理Autolisp,但不是那么多,所以我需要使用带有圆角和封闭边的Entmake的多行lisp,这可能吗??
 
非常感谢
 
迈克尔。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:55:13 | 显示全部楼层
嵌入MLine非常麻烦,并且会导致异常-您可以嵌入MLineStyle,但最好使用ActiveX方法创建MLine对象本身。
 
以下是几个示例函数:
 
  1. ;;-------------------=={ Add MLine Style }==------------------;;
  2. ;;                                                            ;;
  3. ;;  Adds an MLine Style to the ACAD_MLINESTYLE dictionary     ;;
  4. ;;------------------------------------------------------------;;
  5. ;;  Author: Lee McDonnell, 2010                               ;;
  6. ;;                                                            ;;
  7. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  8. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  9. ;;------------------------------------------------------------;;
  10. ;;  Arguments:                                                ;;
  11. ;;  data - a DXF list of MLineStyle data                      ;;
  12. ;;------------------------------------------------------------;;
  13. ;;  Returns:  MLineStyle Dictionary Entity, else nil          ;;
  14. ;;------------------------------------------------------------;;
  15. (defun LM:AddMLineStyle ( data / dic obj )
  16. ;; © Lee Mac 2010
  17. (if (and (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
  18.           (not (dictsearch (setq dic (cdr (assoc -1 dic))) (cdr (assoc 2 data))))
  19.           (setq obj (entmakex data)))
  20.    (dictadd dic (cdr (assoc 2 data)) obj)
  21. )
  22. )
  23. ;;-----------------=={ Delete MLine Style }==-----------------;;
  24. ;;                                                            ;;
  25. ;;  Removes an MLine Style from the ACAD_MLINESTYLE           ;;
  26. ;;  dictionary                                                ;;
  27. ;;------------------------------------------------------------;;
  28. ;;  Author: Lee McDonnell, 2010                               ;;
  29. ;;                                                            ;;
  30. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  31. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  32. ;;------------------------------------------------------------;;
  33. ;;  Arguments:                                                ;;
  34. ;;  name - the name of an MLine Style to remove               ;;
  35. ;;------------------------------------------------------------;;
  36. ;;  Returns:  Entity name of removed style, else nil          ;;
  37. ;;------------------------------------------------------------;;
  38. (defun LM:DeleteMLineStyle ( name / dic )
  39. ;; © Lee Mac 2010
  40. (if (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))   
  41.    (dictremove (cdr (assoc -1 dic)) name)
  42. )
  43. )
  44. ;;------------------------------------------------------------;;
  45. ;; Test Function
  46. (defun Example ( / lst )
  47. (setq lst
  48.    (list
  49.      (cons 0 "MLINESTYLE")
  50.      (cons 100 "AcDbMlineStyle")
  51.      (cons 2 "Example") ; Name
  52.      (cons 70 (+ 272))  ; caps/fill/joints
  53.      (cons 3 "")        ; Desc
  54.      (cons 51 (/ pi 2.)); Start ang
  55.      (cons 52 (/ pi 2.)); End ang
  56.      (cons 71 2)        ; Number of lines
  57.      (cons 49 -0.5)     ; Element Offset
  58.      (cons 62 256)      ; Element Colour
  59.      (cons 6 "BYLAYER") ; Element Linetype
  60.      (cons 49 0.5)
  61.      (cons 62 256)
  62.      (cons 6 "BYLAYER")
  63.    )
  64. )
  65. (LM:AddMLineStyle lst)
  66. )
  67. ;;----------------------=={ Add MLine }==---------------------;;
  68. ;;                                                            ;;
  69. ;;  Adds a VLA MLine Object to the supplied Block container   ;;
  70. ;;  object, going through the supplied vertex list.           ;;
  71. ;;------------------------------------------------------------;;
  72. ;;  Author: Lee McDonnell, 2010                               ;;
  73. ;;                                                            ;;
  74. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  75. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  76. ;;------------------------------------------------------------;;
  77. ;;  Arguments:                                                ;;
  78. ;;  space - VLA Block Object                                  ;;
  79. ;;  ptLst - List of 3D Points for MLine Vertices              ;;
  80. ;;------------------------------------------------------------;;
  81. ;;  Returns:  VLA MLine Object, else nil                      ;;
  82. ;;------------------------------------------------------------;;
  83. (defun LM:AddMLine ( space ptLst )
  84. ;; © Lee Mac 2010
  85. (vla-AddMline space (LM:PointVariant ptLst))
  86. )
  87. ;;------------------=={ Safearray Variant }==-----------------;;
  88. ;;                                                            ;;
  89. ;;  Creates a populated Safearray Variant of a specified      ;;
  90. ;;  data type                                                 ;;
  91. ;;------------------------------------------------------------;;
  92. ;;  Author: Lee McDonnell, 2010                               ;;
  93. ;;                                                            ;;
  94. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  95. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  96. ;;------------------------------------------------------------;;
  97. ;;  Arguments:                                                ;;
  98. ;;  datatype - variant type enum (eg vlax-vbDouble)           ;;
  99. ;;  data     - list of static type data                       ;;
  100. ;;------------------------------------------------------------;;
  101. ;;  Returns:  VLA Variant Object of type specified            ;;
  102. ;;------------------------------------------------------------;;
  103. (defun LM:SafearrayVariant ( datatype data )
  104. ;; © Lee Mac 2010
  105. (vlax-make-variant
  106.    (vlax-safearray-fill
  107.      (vlax-make-safearray datatype
  108.        (cons 0 (1- (length data)))
  109.      )
  110.      data
  111.    )   
  112. )
  113. )
  114. ;;--------------------=={ Point Variant }==-------------------;;
  115. ;;                                                            ;;
  116. ;;  Creates a populated Safearray Variant of Double type.     ;;
  117. ;;------------------------------------------------------------;;
  118. ;;  Author: Lee McDonnell, 2010                               ;;
  119. ;;                                                            ;;
  120. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  121. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  122. ;;------------------------------------------------------------;;
  123. ;;  Arguments:                                                ;;
  124. ;;  lst - list of 2D/3D Points to populate the Variant.       ;;
  125. ;;------------------------------------------------------------;;
  126. ;;  Returns:  VLA Safearray Variant                           ;;
  127. ;;------------------------------------------------------------;;
  128. (defun LM:PointVariant ( lst )
  129. ;; © Lee Mac 2010
  130. (LM:SafearrayVariant vlax-VBDouble (apply 'append lst))
  131. )
  132. ;;---------------------=={ Get Points }==---------------------;;
  133. ;;                                                            ;;
  134. ;;  Returns a list of selected points.                        ;;
  135. ;;------------------------------------------------------------;;
  136. ;;  Author: Lee McDonnell, 2010                               ;;
  137. ;;                                                            ;;
  138. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  139. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  140. ;;------------------------------------------------------------;;
  141. ;;  Arguments: - None -                                       ;;
  142. ;;------------------------------------------------------------;;
  143. ;;  Returns:  List of 3D Points                               ;;
  144. ;;------------------------------------------------------------;;
  145. (defun LM:GetPoints ( / lst pt )
  146. ;; © Lee Mac 2010
  147. (if (car (setq lst (list (getpoint "\nPick First Point: "))))
  148.    
  149.    (while (setq pt (getpoint "\nPick Next Point: " (car lst)))
  150.      (mapcar
  151.        (function
  152.          (lambda ( from to ) (grdraw from to 3 1))
  153.        )
  154.        (cdr (reverse (setq lst (cons pt lst))))
  155.        (reverse (cdr lst))
  156.      )
  157.    )
  158. )
  159. (redraw) (reverse lst)
  160. )
  161. ;;------------------------------------------------------------;;
  162. ;; Test Function
  163. (defun c:test ( / lst )
  164. (if (setq lst (LM:GetPoints))
  165.    (LM:AddMLine
  166.      (vla-get-ModelSpace
  167.        (vla-get-ActiveDocument
  168.          (vlax-get-acad-object)
  169.        )
  170.      )
  171.      lst
  172.    )
  173. )
  174. )

 
IMO,为了视觉效果和易用性,在本例中只需使用(命令“_.mline”)。
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

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

铜币
275
发表于 2022-7-6 10:56:55 | 显示全部楼层
非常感谢。
 
它一直运行到最后一点,在结束错误时,没有绘制任何内容。
 
命令行中的错误消息。
 
  1. ; error: no function definition: VLAX-GET-ACAD-OBJECT

 
仅作为透明绿线运行的程序。
 
任何解决方案。
 
迈克尔
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 11:03:02 | 显示全部楼层
 
我发现它可以将多线绘制到每个点,但在最后留下了这个消息。
 
#
 
尝试添加VL-LOAD-COM,我通常将其保存在我的acaddoc中。lsp
 
  1. (defun c:test ( / lst )
  2.   [color=red](vl-load-com)[/color]
  1. Loads Visual LISP extensions to AutoLISP
  2. (vl-load-com)
  3. This function loads the extended AutoLISP functions provided
  4. with Visual LISP. The Visual LISP extensions implement ActiveX
  5. and AutoCAD reactor support through AutoLISP, and also provide
  6. ActiveX utility and data conversion functions, dictionary handling
  7. functions, and curve measurement functions.
  8. If the extensions are already loaded, [i]vl-load-com[/i] does nothing.
  9. Return Values
  10. Unspecified.

 
 
它仍然会留下我提到的信息,但会画出一条线。
李对此有一个答案。
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

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

铜币
275
发表于 2022-7-6 11:06:52 | 显示全部楼层
谢谢秃鹰
 
但什么都没有改变。
 
还有别的解决办法吗???
 
当做
迈克尔
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 11:10:17 | 显示全部楼层
 
确保已将更改保存在lisp中。同时启动新的绘图任务,然后再次加载lisp。
开始Lisp程序,然后出发。
 
再试一次。
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

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

铜币
275
发表于 2022-7-6 11:13:25 | 显示全部楼层
雅哈,没错。
 
我过去常常直接从Visual Lisp编辑器加载代码,但将其保存为Lisp文件并再次加载则不同,效果更好。
 
因此绘制了Mline,但正如您前面提到的,代码出现在末尾。
 
  1. #<VLA-OBJECT IAcadMLine 0cc48984>

 
这是什么意思????
 
谢谢
 
迈克尔
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 11:15:38 | 显示全部楼层
 
我不确定。正如我所说的,李会回答这个问题。但我相信代码会给你一些想法,如何做自己的,你可以想出如何修改它,以你喜欢的。我相信这是我为mline看到的第一个代码,我觉得它非常有趣。
回复

使用道具 举报

0

主题

1

帖子

1

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 11:20:50 | 显示全部楼层
大家好
我在land desktop2002做一个小项目,
clint提供了jpeg和jgw文件以转换为plines。
请告诉我去connvert的简单方法
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 11:25:53 | 显示全部楼层
 
 
欢迎来到论坛,我建议你开始一个新的线程。你会得到更多答案。你的主题与这条线索无关。
 
祝你好运
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 17:07 , Processed in 1.122517 second(s), 72 queries .

© 2020-2025 乐筑天下

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