vernonlee 发表于 2022-7-6 23:38:19

HELP:Advise on script to inser

I needed to insert a block into many drawings at the same location.
 
After some study, I am able to run this script with scriptpro.
 

ATTREQ 1ATTDIA 0-INSERT"*d:\new block.dwg"2527.1006043527,827.369441206792310saveyBut the issue is i have 2 layout. The above script will only insert to the default layout only.
 
Can someone advise how insert in both layout?
 
Thanks

BIGAL 发表于 2022-7-6 23:42:14

Verysimple the ctab variable can be used to change layouts so in your script (Setvar "ctab" "layout 2") and add Mspace Z E just in case your inside a layout viewport other wise it will insert in the model. NOTE must use brackets this is a mini lisp command in a script .

vernonlee 发表于 2022-7-6 23:46:31

 
Ok. I will give it a shot.
 
BTW, since you mention it is now a mini lisp command in a script, i can still run it with scriptpro?
 
Thanks

steven-g 发表于 2022-7-6 23:50:16

You could use BIGAL's idea just adding the 2 lines to your script
CTABlayout 2
I honestly don't know if it will make a difference, being an LT user I don't know the effects of adding lisp code to scripts

JamCAD 发表于 2022-7-6 23:54:03

Try replacing your insert part of the script with this.

(foreach layout (layoutlist) (setvar "ctab" layout) (command "pspace") (command "-insert" "d:\new block.dwg" "2527.1006,827.3694" "1" "0"))

BIGAL 发表于 2022-7-6 23:55:08

Sorry it will not work with LT Steven is correct just do it as a command you can do on one line if you like
Ctab "layout 2" use " if you have spaces in layout name.

steven-g 发表于 2022-7-6 23:59:50

BIGAL I don't think the OP has LT I just added the comment for any possible LT users who may look-in :>)

vernonlee 发表于 2022-7-7 00:03:08

Hi guys. Thanks for the input. I am using autocad full version.
 
I will try to study all inputs & see how to work it out.
 
Thanks

vernonlee 发表于 2022-7-7 00:06:44

Hi JamCAD.
 
I add in as suggested in 2 different ways and i got errors for both.
 
1st way script

ATTREQ 1ATTDIA 0-INSERT(foreach layout (layoutlist) (setvar "ctab" layout) (command "pspace") (command "-insert" "d:\new block.dwg" "2527.1006,827.3694" "1" "0"))10savey
 
1st way error
 
 
2nd way script

ATTREQ 1ATTDIA 0(foreach layout (layoutlist) (setvar "ctab" layout) (command "pspace") (command "-insert" "d:\new block.dwg" "2527.1006,827.3694" "1" "0"))10savey
 
2nd way error
 
 
What did I do wrong?
 
 
 

vernonlee 发表于 2022-7-7 00:10:00

Got it working with this script.
 

ATTREQ 1ATTDIA 0ctabA2-INSERT"*d:\new block.dwg"2527.1006043527,827.369441206792310ctabA3-INSERT"*d:\new block.dwg"2527.1006043527,827.369441206792310savey
 
Thanks guys
 
 
 
 
页: [1] 2
查看完整版本: HELP:Advise on script to inser