乐筑天下

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

[编程交流] Return to Original Drawing (LI

[复制链接]

2

主题

7

帖子

5

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:54:37 | 显示全部楼层 |阅读模式
I have a LISP routine that opens a drawing related to the drawing already open, and another one that performs some layer manipulation in the 2nd drawing, does a COPYALL, and closes the 2nd drawing. What I haven't been able to figure out, through vast amount of internet searching along with trial and error, is how to be able to return to the original drawing and paste the contents. I can, of course, do it manually, but I'd like to automate it as much as possible.
 
I've tried various lisp and script routines, also nested variations of those. The result is either a process halts due to the file opening, or a script or lisp doesn't wait for the previous one to complete before it runs. Does what I'm trying to do even sound possible??? If so, any light that can be shed on this would be greatly appreciated. Thanks.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:12:53 | 显示全部楼层
Welcome to the forum .
 
I guess you need the function *vla-activate* which would activate the needed drawing .
 
Regards,
 
Tharwat
回复

使用道具 举报

2

主题

7

帖子

5

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:20:52 | 显示全部楼层
Tharwat,
Thanks for your help. I have added four lines of code related to vla-activate, as suggested, but the results are still the same.
 
  1. (defun c:GS (/ dwgPath dwgList dwgName numDwgs count scrFile)(setq dxfPath "C:\\Documents and Settings\\el_MI\\my documents\\auto_lisp\\tests\" ; sets the pathdwgList (vl-directory-files dxfPath "*.dwg") ; get the list of all the dxf's)(if dwgList ; if dwg files exists there(progn(setq numDwgs (length dwgList) ; number of drawingscount 0 ; initiate counterscrFile (open (strcat dxfPath "Runme.scr") "w") ; open a script file in the same folder)(repeat numDwgs ; for all the drawings(setq dwgName (strcat """ dxfpath (nth count dwgList) """))(write-line ".Open" scrFile) ; write to script file(write-line dwgName scrFile)(write-line ".delay 500" scrFile);;;If you need to load a lisp routine in each dwg; (write-line "(load "OutlineLayer.LSP")" scrFile) ; load any required lisp routine;;; Enter your commands here.(write-line "(c:ol)" scrFile)(write-line ".delay 500" scrFile);;;(setq count (1+ count)); next dwg)(close scrFile) ; close when done(command ".script" (strcat dxfpath "Runme.scr")) ; run the script); progn); if;(setq documents (vla-get-documents (vlax-get-acad-object)));(setq DwgFile "373_0001.dwg");(setq doc1 (vla-item documents DwgFile));(vla-activate doc1)(command ".pasteorig")(princ)) ; defun
 
Any commands following the script write/run are executed immediately, without waiting for the script to complete. In this case, anything in the clipboard is pasted before the script runs. If it would wait for the script to be complete, the correct entities would be pasted.
 
I know this because if I leave the pasteorig out of the code, and wait for the sript to run, and THEN type PASTEORIG, everything is good. Thanks again for your help.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:34:35 | 显示全部楼层
First please read this and use the codes Posting Guidelines .
 
http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines&p=51051&viewfull=1#post51051
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:43:51 | 显示全部楼层
At the moment , here is what I use for vla-activate function and implemented with your drawing file path ..
 
  1. (setq acdoc (vla-get-documents (vlax-get-acad-object)))(vla-activate (vla-open   acdoc   "C:\\Documents and Settings\\el_MI\\my documents\\auto_lisp\\tests\\[color=red][b]YourDrawingName.dwg[/b][/color]"   :vlax-false ))
Tharwat
回复

使用道具 举报

2

主题

7

帖子

5

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 10:05:08 | 显示全部楼层
Thank you for that quick response. So what happens now is the drawing specified immediately opens. When I Ctrl/tab back to the original drawing from which the lisp is called, the lisp then runs. Once this is done, I can manually paste to either drawing, as this is till not automated. I tried this both SDI=0 and SDI=1.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 06:11 , Processed in 0.915196 second(s), 64 queries .

© 2020-2025 乐筑天下

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