乐筑天下

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

[编程交流] 用于Copyalign的Lisp(2次单击)

[复制链接]

12

主题

29

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
57
发表于 2022-7-7 04:34:40 | 显示全部楼层 |阅读模式
大家好!我想知道是否有可能将复制升级功能添加到现有的align代码中,只需单击两次即可执行对齐!我想复制一个图纸的一部分,并迅速对齐他们在不同的线,而不修改我的原始图纸!我想在lisp中选择(复制),选择源行,选择目标行!这可能吗?我发布的代码是由Stefan BMR和marko_ribar共同完成的,非常棒。它来自主题“通过两次单击对齐对象”。非常感谢你!
  1. (defun c:al2p ( / *error* sel_ob get_ends ss e1 e2 l1 l2 p1)
  2. (vl-load-com)
  3. (or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
  4. (vla-startundomark acDoc)
  5. (defun *error* (msg)
  6. (and msg (not (wcmatch (strcase msg) "*CANCEL*,*EXIT*,*QUIT*")) (princ (strcat "\nError: ") msg))
  7. (vla-endundomark acDoc)
  8. (princ)
  9. )
  10. ;********************
  11. ;sel_obj- prevent selecting the same objects; prompt for missing
  12. ;return list (ename point)
  13. (defun sel_ob (p tip msg / e msg1)
  14. (setvar 'errno 0)
  15. (if (setq e (entsel msg))
  16. (if
  17. (and
  18. (setq msg1 (strcat "\nFirst element is not " tip))
  19. (wcmatch (cdr (assoc 0 (entget (car e)))) tip)
  20. (setq msg1 "\nSecond element must be different than first...")
  21. (not (eq (car e) p))
  22. )
  23. e
  24. (progn (princ msg1) (sel_ob p tip msg))
  25. )
  26. (if (= (getvar 'errno) 7)
  27. (progn (princ "\nMissed.. Try again.")
  28. (sel_ob p tip msg)
  29. )
  30. nil
  31. )
  32. )
  33. )
  34. ;********************
  35. (defun get_ends (e / o p p1 p2 b)
  36. (setq o (car e)
  37. b (eq (cdr (assoc 0 (entget o))) "LWPOLYLINE")
  38. p (vlax-curve-getparamatpoint
  39. o
  40. (vlax-curve-getclosestpointto o (trans (cadr e) 1 0))
  41. )
  42. p1 (if b
  43. (fix p)
  44. (vlax-curve-getstartparam o)
  45. )
  46. p2 (if b
  47. (1+ p1)
  48. (vlax-curve-getendparam o)
  49. )
  50. )
  51. (if (> (- p2 p) (- p p1))
  52. (list
  53. (trans (vlax-curve-getpointatparam o p1) 0 1)
  54. (trans (vlax-curve-getpointatparam o p2) 0 1)
  55. )
  56. (list
  57. (trans (vlax-curve-getpointatparam o p2) 0 1)
  58. (trans (vlax-curve-getpointatparam o p1) 0 1)
  59. )
  60. )
  61. )
  62. ;;; Start main routine
  63. (while
  64. (and
  65. (setq ss (ssget ":L"))
  66. (setq e1 (sel_ob nil "LINE,LWPOLYLINE" "\nSelect source object: "))
  67. (setq e2 (sel_ob (car e1) "LINE,LWPOLYLINE" "\nSelect destination object: "))
  68. )
  69. (progn
  70. (setq l1 (get_ends e1)
  71. l2 (get_ends e2)
  72. )
  73. (command "_align" ss ""
  74. "_non" (car l1)
  75. "_non" (car l2)
  76. "_non" (cadr l1)
  77. "_non" (cadr l2)
  78. "" "_n"
  79. )
  80. t
  81. )
  82. )
  83. (vla-endundomark acDoc)
  84. (princ)
  85. )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 05:43 , Processed in 0.724303 second(s), 54 queries .

© 2020-2025 乐筑天下

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