乐筑天下

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

[综合讨论] HELP:Advise on script to inser

[复制链接]

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-7 00:12:35 | 显示全部楼层
Two ways make lisp 1 line only unfortunately if it hits end of line before close bracket get error,
(foreach layout (layoutlist)(setvar "ctab" layout)(command "pspace")(command "-insert" "d:\new block.dwg" "2527.1006,827.3694" "1" "0"))
 
second save the foreach as a lisp then script just has two lines this is a universal way of doing it can be used elsehwere
(load "foreachtab")
(foreachtab "d:\new block.dwg" "2527.1006,827.3694")
 
  1. (foreachtab (blknanme pt / )(foreach layout (layoutlist) (setvar "ctab" layout) (command "pspace") (command "-insert" blkname pt "1" "0")))
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-7 00:16:07 | 显示全部楼层
OMG i realised something. All layout tabs are names differently across my lots of drawings.
 
If this is the case, what is the solution?
回复

使用道具 举报

6

主题

31

帖子

25

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-7 00:18:28 | 显示全部楼层
Try this
  1. ATTREQ 1ATTDIA 0(setq osnapsave (getvar "osnap"))(setvar "osnap" 0)(foreach layout (layoutlist) (setvar "ctab" layout) (if (/= 1 (getvar "cvport")) (command "pspace")) (command "-insert" "d:\\new block.dwg" "2527.1006,827.3694" "1" "0"))(setvar "osnap" osnapsave)savey
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-7 00:22:09 | 显示全部楼层
Hi JamCAD
 
Tested the script as indicated but got this error:-
 
So i took out this 3 lines(setq osnapsave (getvar "osnap")) (setvar "osnap" 0)
(setvar "osnap" osnapsave)
 
And also added "1" for the Y scale
 
This script now is this:-
 
  1. ATTREQ 1ATTDIA 0(foreach layout (layoutlist) (setvar "ctab" layout) (if (/= 1 (getvar "cvport")) (command "pspace")) (command "-insert" "d:\\new block.dwg" "2527.1006,827.3694" "1" "1" "0"))(setvar "osnap" osnapsave)savey
 
And manage to get it to work. All layouts regardless of name has the new block inserted.
 
Thanks bro.
 
But then kindly advise the purpose of the 3 lines of code & if it is necessary to prevent future errors & how to incoporate it to the script such that it can work correctly.
 
Thanks again.
 
 
 
 
 
 
 
 
回复

使用道具 举报

6

主题

31

帖子

25

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-7 00:23:28 | 显示全部楼层
Sorry, I'm trying to answer these questions on my phone and I'm not able to test it before I post. Those few lines of code are to disable the object snap so when you are inserting the block it doesn't accidentally snap to the incorrect point. I forgot that the system variable for the osnap settings is actually osmode. This should work now.
  1. ATTREQ 1ATTDIA 0(setq osnapsave (getvar "osmode"))(setvar "osmode" 0)(foreach layout (layoutlist) (setvar "ctab" layout) (if (/= 1 (getvar "cvport")) (command "pspace")) (command "-insert" "d:\\new block.dwg" "2527.1006,827.3694" "1" "1" "0"))(setvar "osmode" osnapsave)savey
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-7 00:26:31 | 显示全部楼层
Hi BIGAL,
 
do not quite understand the process.
 
I will just stick to the basic script instead
 
Thanks for the help as well
 
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-7 00:31:44 | 显示全部楼层
NP bro. Appreciate the help.
 
The revised script now works without issues.
 
Thanks
 
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-7 00:32:35 | 显示全部楼层
I also added this 3 lines to my initial script base on layout names:-
 
(setq osnapsave (getvar "osmode"))
(setvar "osmode" 0)
(setvar "osmode" osnapsave)
 
Script
  1. ATTREQ 1ATTDIA 0(setq osnapsave (getvar "osmode"))(setvar "osmode" 0)ctabA2-INSERT"*d:\new block.dwg"2527.1006043527,827.369441206792310ctabA3-INSERT"*d:\new block.dwg"2527.1006043527,827.369441206792310(setvar "osmode" osnapsave)savey
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-7 00:36:31 | 显示全部楼层
Thought this was discussed already OSMODE
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-7 00:39:39 | 显示全部楼层
 
OMG. You are right.
 
Now how did i copied the old code instead?   
 
WIll test it when back in office but i believe should be no issue now.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 03:52 , Processed in 0.345829 second(s), 70 queries .

© 2020-2025 乐筑天下

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