乐筑天下

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

[编程交流] 仅在X轴和Y轴上复制

[复制链接]

56

主题

256

帖子

230

银币

后起之秀

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

铜币
253
发表于 2022-7-5 15:22:29 | 显示全部楼层 |阅读模式
大家好,你好。
 
下面有一个脚本,它使用两个单独的命令沿x轴和y轴复制。CX和CY。
 
2个问题。
 
 
[列表=1]
  • 我每次复制时都需要它重新生成(当我复制引线时出现错误)(命令“.regen”)无效。
  • 复制多个,在第一次复制后,约束不再生效。
    [/列表]
     
    谢谢你的帮助。
     
    1. ;;----------------------------------------------------------------------;;
    2. (defun c:CX ()
    3.    (setq ss (ssget))
    4.    (command "._copy" ss "" "M" pause ".yz" "@" pause)
    5.    (command ".regen")
    6.    (setq ss nil);; add this line to clean the selection
    7.    (princ)
    8. )
    9. (defun c:CY ()
    10.    (setq ss (ssget))
    11.    (command "._copy" ss "" "M" pause ".xz" "@" pause)
    12.    (command ".regen")
    13.    (setq ss nil);; add this line to clean the selection
    14.    (princ)
    15. )
    16. ;;----------------------------------------------------------------------;;
    17. (vl-load-com)
    18. (princ
    19.    (strcat
    20.        "\n:: Lock_Copy_X&Y.lsp loaded ::"
    21.        "\n:: Invoke by typing 'CX' (Copy on X-axis) or 'CY' (Copy on Y-axis) ::"
    22.    )
    23. )
    24. (princ)
    25. ;;----------------------------------------------------------------------;;
    26. ;;                             End of File                              ;;
    27. ;;----------------------------------------------------------------------;;

     
    Roy_043在这里(第4号帖子)回答:
    http://www.cadtutor.net/forum/showthread.php?94798-仅在X轴和Y轴上复制&p=699099&viewfull=1#post699099
  • 回复

    使用道具 举报

    56

    主题

    256

    帖子

    230

    银币

    后起之秀

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

    铜币
    253
    发表于 2022-7-5 15:30:00 | 显示全部楼层
    只是给这个一个小肿块谢谢。
    回复

    使用道具 举报

    106

    主题

    1万

    帖子

    101

    银币

    顶梁支柱

    Rank: 50Rank: 50

    铜币
    1299
    发表于 2022-7-5 15:40:01 | 显示全部楼层
    当面打你的消息
     
    1. (Alert  ":: Lock_Copy_X&Y.lsp loaded ::\n\n\n:: Invoke by typing 'CX' (Copy on X-axis) or 'CY' (Copy on Y-axis) ::" )

     
    第二条建议
    1. (defun c:CX ( / ss) this localises ss so no need for set nil

     
    如果这是你经常做的事情,你可以使用一个智能反应器,我只需要输入x100,然后它会要求对象并相应地移动,在X x234 x45-6之后键入任何数字,这是45-6的原因,因为周期会导致例程中出现错误。
     
    1. ; Enter the filet radius as part of a command line entry f100 offset O234 circle c123-45
    2. ; note - is used for decimal point
    3. ; original code and methology by Alan H
    4. ; assistance and code that worked by Lee-Mac
    5. ; OCT 2015
    6. ( (lambda nil
    7. (vl-load-com)
    8. (foreach obj (cdar (vlr-reactors :vlr-command-reactor))
    9. (if (= "fillet-reactor" (vlr-data obj))
    10. (vlr-remove obj)
    11. )
    12. )
    13. (vlr-command-reactor "fillet-reactor" '((:vlr-unknowncommand . fillet-reactor-callback)))
    14. )
    15. )
    16. (defun filletrad ( / rad)
    17. (setq rad (distof (substr com 2) 2))
    18. (if (<= 0.0 rad)
    19. (progn
    20. (setvar 'filletrad rad)
    21. (vla-sendcommand fillet-reactor-acdoc "_.fillet ")
    22. )
    23. )
    24. )
    25. (defun makecirc ( / rad radd)
    26. (setq rad (distof (substr com 2) 2))
    27. (if (<= 0.0 rad)
    28. (progn
    29. (setvar 'circlerad rad)
    30. (setq pt (getpoint "Pick centre pt"))
    31. (vla-sendcommand fillet-reactor-acdoc "_.Circle !pt ")
    32. )
    33. )
    34. )
    35. (defun offdist ( / dist)
    36. (setq dist (distof (substr com 2) 2))
    37. (if (<= 0.0 dist)
    38. (progn
    39. (setvar 'offsetdist dist)
    40. (vla-sendcommand fillet-reactor-acdoc "_.Offset ")
    41. )
    42. )
    43. )
    44. (defun pipeoff ( / dist)
    45. (setq dist (distof (substr com 2) 2))
    46. (if (<= 0.0 dist)
    47. (progn
    48. (setq poff (strcat "P" (rtos dist 2 0)))
    49. (if (not poff)(load "Pipe offsets"))
    50. (vla-sendcommand fillet-reactor-acdoc poff)
    51. )
    52. )
    53. )
    54. (defun projopen ( / Proj year)
    55. (setq year (atoi (substr com 2 4)))
    56. (if (< year 2014)
    57. (setq projno (strcat "EXPLORER \\\\cogg.local\\fs\\LCFC3\\DESIGN\\DATA\" (substr com 2 4) " Projects\" (substr com 2) "[url="file://\\Design\"]\\Design\\[/url]"))
    58. (setq projno (strcat "EXPLORER P:\" (rtos year 2 0) " Projects\" (substr com 2) "[url="file://\\Design\"]\\Design\\[/url]"))
    59. )
    60. (vla-sendcommand fillet-reactor-acdoc (STARTAPP projno))
    61. )
    62. (defun fillet-reactor-callback ( obj com )
    63. (setq com (vl-string-translate "-" "." (strcase (car com))))
    64. (cond
    65. ( (and
    66. (wcmatch com "~*[~F.0-9]*")
    67. (wcmatch com "F*")
    68. (wcmatch com "~F*F*")
    69. (wcmatch com "~*.*.*")
    70. ) ; and
    71. (filletrad)
    72. )
    73. ( (and
    74. (wcmatch com "~*[~C.0-9]*")
    75. (wcmatch com "C*")
    76. (wcmatch com "~C*C*")
    77. (wcmatch com "~*.*.*")
    78. ) ;and
    79. (makecirc)
    80. )
    81. ( (and
    82. (wcmatch com "~*[~O.0-9]*")
    83. (wcmatch com "O*")
    84. (wcmatch com "~O*O*")
    85. (wcmatch com "~*.*.*")
    86. ) ; and
    87. (offdist)
    88. )
    89. ( (and
    90. (wcmatch com "~*[~D.0-9]*")
    91. (wcmatch com "D*")
    92. (wcmatch com "~D*D*")
    93. (wcmatch com "~*.*.*")
    94. ) ; and
    95. (projopen)
    96. )
    97. ( (and
    98. (wcmatch com "~*[~P.0-9]*")
    99. (wcmatch com "P*")
    100. (wcmatch com "~P*P*")
    101. (wcmatch com "~*.*.*")
    102. ) ; and
    103. (pipeoff)
    104. )
    105. ) ; master cond
    106. ) ; defun
    107. (or fillet-reactor-acdoc
    108. (setq fillet-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object)))
    109. )
    回复

    使用道具 举报

    18

    主题

    1529

    帖子

    973

    银币

    中流砥柱

    Rank: 25

    铜币
    649
    发表于 2022-7-5 15:51:06 | 显示全部楼层
    为什么不在打开正交模式的情况下正常使用copy命令?
    回复

    使用道具 举报

    0

    主题

    24

    帖子

    24

    银币

    初来乍到

    Rank: 1

    铜币
    0
    发表于 2022-7-5 15:57:14 | 显示全部楼层
    因为看这个。我有很多用途。尝试垂直于x或y轴上的点捕捉。
     
    如果他们不想让我们使用,为什么广告会为x、y和z添加点过滤器?
     
     
     
    这绝对完美。非常感谢。巧妙的技巧。我会记住这一点。
     
    谢谢在罗伊043号发射时,我并没有查看反应堆。谢谢
     
    这是我的CX和CY命令。再次感谢Roy_043。
    1. (defun c:test ( / ss)
    2. (setq ss (ssget))
    3. (command "._copy" ss "" "_multiple" pause)
    4. (while (/= 0 (getvar 'cmdactive))
    5.    (command ".yz" "@" pause)
    6. )
    7. (princ)
    8. )
    回复

    使用道具 举报

    56

    主题

    256

    帖子

    230

    银币

    后起之秀

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

    铜币
    253
    发表于 2022-7-5 16:01:36 | 显示全部楼层
    Lisp程序!
     
    我刚开始学习autolisp编程,我会尝试修改包括“CZ”函数和“CXY”、“CXZ”、“CYZ”。
    你认为用“移动”取代“复制”对移动也有效吗?
     
    谢谢!
    回复

    使用道具 举报

    0

    主题

    1

    帖子

    1

    银币

    初来乍到

    Rank: 1

    铜币
    0
    发表于 2022-7-5 16:08:39 | 显示全部楼层
    这是我的移动Lisp程序。
     
    1. ;;----------------------------------------------------------------------;;
    2. ; Answer on how to fix multiple copy by Roy_043 14.03.2018: http://www.cadtutor.net/forum/showthread.php?94798-Copy-on-X-axis-only-and-Y-axis-only&p=699099&viewfull=1#post699099
    3. ; Credit to Roy_043
    4. (defun c:CX ( / ss)
    5. (setq ss (ssget))
    6. (command "._copy" ss "" "_multiple" pause)
    7. (while (/= 0 (getvar 'cmdactive))
    8.    (command ".yz" "@" pause)
    9. )
    10. (princ)
    11. )
    12. (defun c:CY ( / ss)
    13. (setq ss (ssget))
    14. (command "._copy" ss "" "_multiple" pause)
    15. (while (/= 0 (getvar 'cmdactive))
    16.    (command ".xz" "@" pause)
    17. )
    18. (princ)
    19. )
    20. ;;----------------------------------------------------------------------;;
    21. (vl-load-com)
    22. (princ
    23.    (strcat
    24.        "\n:: Lock_Copy_X&Y.lsp loaded ::"
    25.        "\n:: Invoke by typing 'CX' (Copy on X-axis) or 'CY' (Copy on Y-axis) ::"
    26.    )
    27. )
    28. (princ)
    29. ;;----------------------------------------------------------------------;;
    30. ;;                             End of File                              ;;
    31. ;;----------------------------------------------------------------------;;
    回复

    使用道具 举报

    56

    主题

    256

    帖子

    230

    银币

    后起之秀

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

    铜币
    253
    发表于 2022-7-5 16:20:55 | 显示全部楼层
    这是我的伸展版,里面还有其他好吃的。
    1. ;;----------------------------------------------------------------------;;
    2. (defun c:MX ( / ss)
    3. (setq *error* SS:error)
    4. (SS:startundo)
    5. (setq cmde (getvar "cmdecho"))
    6. (setq os (getvar "osmode"))
    7. (setq orthom (getvar "orthomode"))
    8. (setvar 'cmdecho 0)
    9. (setvar 'osmode 83)
    10. (setvar 'orthomode 1)
    11. (setq ss (ssget))
    12. (command "._move" ss "" pause ".yz" "@" pause)
    13. (setq ss nil)
    14. (*error* nil)
    15. (princ)
    16. )
    17. (defun c:MY ( / ss)
    18. (setq *error* SS:error)
    19. (SS:startundo)
    20. (setq cmde (getvar "cmdecho"))
    21. (setq os (getvar "osmode"))
    22. (setq orthom (getvar "orthomode"))
    23. (setvar 'cmdecho 0)
    24. (setvar 'osmode 83)
    25. (setvar 'orthomode 1)
    26. (setq ss (ssget))
    27. (command "._move" ss "" pause ".xz" "@" pause)
    28. (setq ss nil)
    29. (*error* nil)
    30. (princ)
    31. )
    32. (defun SS:error (errmsg)
    33. (and acDoc (vla-EndUndoMark acDoc))
    34. (and errmsg
    35.         (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
    36.         (princ (strcat "\n<< Error: " errmsg " >>"))
    37.         )
    38. (setvar 'cmdecho cmde)
    39. (setvar 'osmode os)
    40. (setvar 'orthomode orthom)
    41. )
    42. (defun SS:startundo ()
    43. (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
    44. (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))
    45. )
    46. (vl-load-com)
    47. (princ
    48. (strcat
    49.         "\nLock_Move_X&Y.lsp loaded"
    50.         "\nInvoke by typing 'MX' (Move on X-axis) or 'MY' (Move on Y-axis)"
    51.         )
    52. )
    53. (princ)
    54. ;;----------------------------------------------------------------------;;
    55. ;;                             End of File                              ;;
    56. ;;----------------------------------------------------------------------;;
    回复

    使用道具 举报

    56

    主题

    256

    帖子

    230

    银币

    后起之秀

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

    铜币
    253
    发表于 2022-7-5 16:23:28 | 显示全部楼层
    回复

    使用道具 举报

    发表回复

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

    本版积分规则

    • 微信公众平台

    • 扫描访问手机版

    • 点击图片下载手机App

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

    GMT+8, 2025-3-14 03:30 , Processed in 0.470086 second(s), 70 queries .

    © 2020-2025 乐筑天下

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