Jump to content
GVR

Layout-tab name in a macro.

Recommended Posts

GVR

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.

Share this post


Link to post
Share on other sites
Ahankhah

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)
[color=red]   put here your code to print[/color]
[color=black])[/color]

Share this post


Link to post
Share on other sites
GVR

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.

Share this post


Link to post
Share on other sites
Ahankhah
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?

Share this post


Link to post
Share on other sites
GVR

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"

Share this post


Link to post
Share on other sites
Ahankhah

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).

Share this post


Link to post
Share on other sites
Ahankhah

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.

Share this post


Link to post
Share on other sites
GVR

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.

Share this post


Link to post
Share on other sites
dbroada

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

Share this post


Link to post
Share on other sites
GVR

@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.

Share this post


Link to post
Share on other sites
Ahankhah
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.

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites
GVR

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.

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites
Bhavik

Hello all,

 

I have Auto CAD LT2016 and right now I have to go to each layouts and than give command "zoom, extents". This is very irritating:( when I have too many layouts and file runs very slow.

So, can anyone please tell me if you know any macro which automatically goes to every layout and runs "zoom, extents" command:roll:.

Share this post


Link to post
Share on other sites
steven-g

Not in LT unless you know the name of each layout, otherwise there is no way to tell LT to go to a layout.

Share this post


Link to post
Share on other sites
BIGAL

steven-g any way to do the Ctrl+Pgdn this will step through layouts

 

We name our layouts pretty simple like D01 D02 etc so could do a excel copy paste given number of layouts using ctab = D01 and so on would it matter if D30 it will just error.

 

ctab D01
Zoom E
ctab D02
Zoom E
ctab D03
Zoom E

Share this post


Link to post
Share on other sites
steven-g

I have never found a way, Ctrl + PgDn is a shorcut not a command and it's not listed in the CUI which would give a clue as to how it operates, "ctab" or "layout - set" both work but only if you know the layout names, "layout - ?" does return the layout names and could conceivably be sent to a variable and split by diesel which I might try (might). Macro's do have some special control codes which can be useful.

 

 

EDIT*

Nope no way to get the output of the layout tab list into a diesel accesible list (from a macro), it is a nice way to get the list into excel, but if your doing that then there is no need to struggle with a macro, as using an excel script is much easier.

Edited by steven-g

Share this post


Link to post
Share on other sites
Bhavik

Hi Steven,

 

I have fixed layout name for ex :- DC-101, DC-102, DC-103, DC-201 etc.

So is it possible with fixed layout name..?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×