明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3681|回复: 2

[原创]原位置COPY物件到其它圖檔

[复制链接]
发表于 2005-4-6 17:37 | 显示全部楼层 |阅读模式
  1. ;|
  2. My intention is to:
  3. 1. 'copyclip' some features from this drawing.
  4. 2. Open another drawing
  5. 3. Paste the copied features into the newly opened drawing.
  6. 4. Save and close this new drawing.
  7. 5. Get back to the old drawing and continue to repeat the cycle.Tried as follows till step 3:
  8. (defun c:cp()
  9. (setq sset (ssget)) ;from current drawing
  10. (command "copyclip" sset "")
  11. (command "._VBAStmt" (strcat "AcadApplication.Documents.Open "" "c:/junk.dwg" """)
  12. (command "pasteorig") ;does not work in new drawing.
  13. )As soon as the new drawing is opened, it becomes the current. But,
  14. the line (command "pasteorig") does not get executed here since the program belongs to old drawing.
  15. Any tips on what to do so that I can continue to perform the steps 3, 4, 5?
  16. |;
  17. ;;BY LUCAS(龙龙仔)
  18. ;;原位置COPY物件到其它图档
  19. (defun C:COPY_2_OTHER_DWG (/ DOC LST N NEWDWG SS NAME)
  20.    (vl-load-com)
  21.    (if (and (setq SS (ssget (list (cons 410 (getvar "ctab"))
  22.          (cons 0 (strcat "~" "VIEWPORT"))
  23.            )
  24.            )
  25.        )
  26.        (setq NAME (getfiled "开启图档" (getvar "ACADPREFIX") "dwg" 8))
  27.        (setq NAME (findfile NAME))
  28.            )
  29.        (progn
  30.            (setq N       -1
  31.          DOC       (vla-get-activedocument (vlax-get-acad-object))
  32.          NEWDWG (vla-open (vla-get-documents (vlax-get-acad-object))
  33.                NAME
  34.          )
  35.            )
  36.            (repeat (sslength SS)
  37.   (setq LST
  38.                (cons (vlax-ename->vla-object (ssname SS (setq N (1+ N))))
  39.              LST
  40.                )
  41.   )
  42.            )
  43.            (vla-copyobjects
  44.   DOC
  45.   (vlax-safearray-fill
  46.      (vlax-make-safearray
  47.          vlax-vbobject
  48.          (cons 0 (1- (length LST)))
  49.      )
  50.      LST
  51.   )
  52.   (if (equal (getvar "ctab") "Model")
  53.      (vla-get-modelspace NEWDWG)
  54.      (vla-get-paperspace NEWDWG)
  55.   )
  56.            )
  57.            (vla-saveas NEWDWG NAME acnative)
  58.            (vla-close NEWDWG)
  59.            (vlax-release-object DOC)
  60.            (vlax-release-object NEWDWG)
  61.        )
  62.    )
  63.    (princ)
  64. )
发表于 2005-4-9 18:22 | 显示全部楼层
cad自带这个功能,编辑菜单里的粘贴到原坐标,有区别吗???
 楼主| 发表于 2005-4-11 12:52 | 显示全部楼层
当你要copy到所有图中时,程序只要执行一下(当然程序要修改)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-21 05:15 , Processed in 0.158938 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表