Jump to content

Layout-tab name in a macro.


Recommended Posts

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.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 6 years later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...