PDA

View Full Version : Layout-tab name in a macro.



GVR
11th May 2011, 07:48 am
Hello,

I have made a macro which print a specifically area of different layout-tabs. It works fine.
But now i have to use it in other drawings with other layout-tab names and than the macro doesn't work anymore.
Now i have to change the macro each time with all the new layout-tab names.
Is there a way to use a name/number that always work for layout1, layout2, layout3,...etc.
I thought it was "layout1" etc. with or without the ", but that doesn't work.

I hope someone has a answer.
Already thanks.

Ahankhah
11th May 2011, 08:58 am
You can issue (layoutlist) to get a list containing all layout tabs, so then you can use foreach function to set each tab current to do print.


(foreach layout (layoutlist)
(command "._LAYOUT" "_Set" layout)
put here your code to print
)

GVR
11th May 2011, 09:07 am
I don't know this kind of code. Is this code part of LISP? In that case i can't use it. I'm using AutoCAD LT.

Edit:
I tried it but i got this error back: (foreach LISP command is not available.

So my question about LISP is now answered i think.

Ahankhah
11th May 2011, 09:19 am
I don't know this kind of code. Is this code part of LISP? In that case i can't use it. I'm using AutoCAD LT.Could you insert your macro which works on your PC?

GVR
11th May 2011, 09:47 am
This is the script that i use:



filedia 0
layout

001
_-plot
y

PublishToWeb JPG.pc3
onderlegger
l
n
w
0,0
2400,1670
1:1

y
Print.ctb





y
y
layout

A
_-plot
y

PublishToWeb JPG.pc3
onderlegger
l
n
w
0,0
2400,1670
1:1

y
Print.ctb





y
y
layout

B
_-plot
y

PublishToWeb JPG.pc3
onderlegger
l
n
w
0,0
2400,1670
1:1

y
Print.ctb





y
y
layout

C
_-plot
y

PublishToWeb JPG.pc3
onderlegger
l
n
w
0,0
2400,1670
1:1

y
Print.ctb





y
y
layout

001
filedia 1


In the drawing for this script the layouts are named: 001, A, B, C.
The paper-size is named: "onderlegger"

Ahankhah
11th May 2011, 10:39 am
By using Ctab system variable, you cad obtain the name of current tab (layout).
As I searched in AutoCAD's documntation and help, unfortunately there is no any command or system variable in AutoCAD to say the name of other tabs (layouts).

Ahankhah
11th May 2011, 10:47 am
I think you have another problem in addition to not knowing tabs (layouts) name. You alse don't know the count of tabs. Without AutoLISP, You can't find out how many tabs are there in the drawing.

GVR
11th May 2011, 11:02 am
Ahankhah, Thank you for your help.
I'm gonna modify the script so it is printing only the active layout-tab. Then i can print each layout when i work on it, instead of printing them all at once at the end.

But i still hope that someone els have a solution.

dbroada
11th May 2011, 11:08 am
How are you using this? Do you use it as part of a batch process or just the current drawing?

If the former I have no suggestions but if the latter can you just remove the first few lines (start your script with the -plot line) to run on the currently selected layout?

edit......

I would have posted this before your identical solution but somebody brought me some work to do. :x

GVR
11th May 2011, 11:16 am
@dbroada
But still thanks for your idea. It was a little to late but it's the gesture that counts.:)

The new version of the script is already working.

Ahankhah
11th May 2011, 11:21 am
Ahankhah, Thank you for your help.
You are welcom.


i still hope that someone els have a solution.
I will let you know any new solution, if I find, without fail.

BIGAL
13th May 2011, 04:04 am
Why not use excell to create a script for you, if you have always the same type of layout name then its only a matter of putting a number in 1 sq and run a macro, a script can be written as 1 line with multi commands rather than 1 after another a bit easier in exell

as an example please check not tested

8 becomes
filedia 0
layout 001 _-plot y PublishToWeb JPG.pc3 onderlegger l n w 0,0 2400,1670 1:1 y Print.ctb
layout 002 _-plot y PublishToWeb JPG.pc3 onderlegger l n w 0,0 2400,1670 1:1 y Print.ctb
.
.
.
layout 008 _-plot y PublishToWeb JPG.pc3 onderlegger l n w 0,0 2400,1670 1:1 y Print.ctb

maybe simpler just save scripts 1-10 and run the correct one.

GVR
17th May 2011, 01:16 pm
That's just the problem. There is no logical sequences.
The layout-name is the name of that part of a building. (wing-a, wing-b, part c-f, basement.........etc)

So i keep the script to print just 1 page at this moment.

BIGAL
18th May 2011, 10:00 am
This is way out there ! Got a copy of MSword or excell it has vba in it as its macro language so maybe dump a dxf and read it via excel macro write out layout tab names and create script. Big job but achieveable.

Disavantage is that you will end up with a script for every dwg.

Its sounding easier just type layout name in excel as created then create script. Much easier only need 1 line in excel repeated rest is easy.

Found it excel cell A3 has layout cell B3 has "plot y PublishToWeb JPG.pc3 " D3 cell C3 = "l n w 0,0 2400,1670 1:1 y Print.ctb"

so cell E1 = =CONCATENATE(B3," ",A3, C3 )
_-plot y PublishToWeb JPG.pc3 onderlegger l n w 0,0 2400,1670 1:1 y Print.ctb

copy and paste E column into notebook save as script

ps dont forgot E1="filedia 0" E2 etc at top of script as per first post.

Just a comment I think theirs a massive opportunity for excell to write scripts for Acad LT with its inbuilt VBA for repetitive tasks. Just think outside the oblong, every one else has a sq.