Jump to content

Read information from drawing and use it in a command string


Taurenis

Recommended Posts

Dear CAD specialists,

 

is there a way to read information from drawing (e.g. content of a specific text object, content/value of specific attribute or any other object that I can place in a layout) and then put that information in a command string?

 

LISP is not in the range of solutions as:

1) I haven't had time to dig into it

2) I have quite a few LT users who also need to be able to use my solution

 

Simple example of the problem

I have an object with a value "5". I would like to draw a polyline with a width equal to that object's value ("5") using a Tool with a command string:

^C^C_PLINE;\width;[read object's value];[read object's value];

 

The real problem

I have created PageSetups for different paper sizes for our plotter as well as for creating PDF and plt files. PageSetups include custom paper sizes.

To simplify plotting I have created tools for each paper size with a command string e.g.:

for plotter: ^C^Cpreview;-plot;N;;_A3_HP500;HP500_A3_A3.2_A3.1_A3.0.pc3;N;N;

for pdf file: ^C^Cpreview;-plot;N;;_A3_DWG to PDF;CP_DWG To PDF.pc3;~;N;y;

 

Explanation

^C^C: cancels all the previous commands

preview: leads to print preview so the person can check if drawing is OK

-plot: invokes plotting

N: is the answer to question whether detailed plot configuration is necessary

[empty]: uses default (actice) layout name for layout to be plotted

_A3_HP500: is the name of PageSetup

HP500_A3_A3.2_A3.1_A3.0.pc3: is the name of output device

N: is the answer to question whether to write the plot to a file

N; is the answer to question whether to save changes to PageSetup

The last question which is answered manually is whether to proceed with plot

 

What I would like to do is create a tool which reads the PageSetup name and output device name from something that I can define along with (or within) a layout. Each layout would contain 6 source objects/fields (plotter/pdf/plt x PageSetup/name of output device). This way I could use one tool for plotting, one for creating pdf file and one for creating plt file disregarding the current paper size

 

The command string would look smt like:

^C^Cpreview;-plot;N;;[value from drawing A1];[value from drawing B1];N;N;

Link to comment
Share on other sites

Interesting idea, if you create a plot style, surely you can set the plotter/pdf/plt in the style, so the output device would just accept the default during the -plot command. You could then run a macro that would ask for which option you want "output to plotter", "output to PDF" or "output to plt". Though it might be easier to just have 3 macro's to choose from.

Link to comment
Share on other sites

Thanks for the answer.

I believe that by writing "plot style" you mean PageSetup.

However, the thing is that for the specific layout (say paper size A3.2) I have three PageSetups - one for plotting, one for PDF and one for plt. If I go with all the default values of -plot command it will use the PageSetup which is set as current. So it doesn't solve the problem.

Link to comment
Share on other sites

Sorry yes I meant PaseSetup, if you have a PageSetup for each of the 3 options and but that in you your macro then the next prompt for the plottername actually uses this as the default value and not the one stored with the layout, so if your layout is set up with PageSetup "plotter" but your macro uses PageSetup "PDF" then "PDF" is the default value used there is no need to give the device again, it just cuts out one hurdle from your question.

Link to comment
Share on other sites

The next question is, are you then only wanting the user to make the choice of device because if it is set per layout then all you need do is call the -plot command. Sorry if I'm missing the point I'm just trying to clarify the question in my own mind :) I can be a bit slow sometimes

Link to comment
Share on other sites

I would like to create a solution where the user doesn't have to make any choices but which button to press - "Plot" / "Create PDF" / "Create PLT".

If I get you correctly then I already have the solution you are suggesting - I have three buttons for each paper size. However, each paper size needs to have a PageSetups for "Plot" / "Create PDF" / "Create PLT". It means that I have 3x the number of paper sizes (in my case 3x28=84) buttons.

What I want is to have 3 buttons which "understand" which paper size is now active and chooses appropriate PageSetup.

Link to comment
Share on other sites

Sorry again, but why do you need to change paper size. If a layout is setup on A4 with all its titles and viewports, and you plot it ontoi A3 you get an A4 drawing in the middle of the sheet; From the other side if it is A3 and you print to A4 using PlotSetup then you only get half a drawing, on the other hand if you are wanting to plot a drawing layout of A3 onto a smaller A4 sheet, then you need to answer yes to the first prompt and go into the detailed plot configuration settings (I think that was confusing me), if so then the problem needs rethinking.

So if the size of paper is being input into an attribute by someone that is a fixed value for that layout, why not just change the default PageSetup for that layout. Otherwise the paper size needs to be decided as you are running the macro and doesn't need storing in the drawing, which is a different approach to how the macro would work.

 

If the layout is drawn and you would like the user to have the option to plot at A4, A3 A1 etc onto paper, pdf or file then the user needs to change something like an attribute first, before the macro is run, correct?

Link to comment
Share on other sites

Hmm.. we are not on the same page on this one.

No need to change the paper size in the way you described. I beleve that the problem might be hiding in the way we are used to work with drawing files.

 

I will give an example. Hope this will straight the things out.

 

Lets say I have two drawings in a file. Each is put on a separate layout (imported from a template) - one is A3.1 (paper size A3.1) the other is A2.0 (paper size A2.0). A3.1 has three PageSetups corresponding to it ("A3.1 plotter"/"A3.1 PDF"/"A3.1 PLT"). Analogically for A2.0.

1st I want to create PDF file. 2nd I want to plot from dwg.

 

1.1) I activate layout A3.1. If I have 3 buttons (plot/create pdf/create plt) I hit "create pdf"; the command string now has to understand that it has to use PageSetup "A3.1 PDF".

1.2) I activate layout A2.0. If I have 3 buttons (plot/create pdf/create plt) I hit "create pdf"; the command string now has to understand that it has to use PageSetup "A2.0 PDF".

2.1) I activate layout A3.1. If I have 3 buttons (plot/create pdf/create plt) I hit "plot"; the command string now has to understand that it has to use PageSetup "A3.1 plotter".

2.2) I activate layout A2.0. If I have 3 buttons (plot/create pdf/create plt) I hit "plot"; the command string now has to understand that it has to use PageSetup "A2.0 plotter".

Link to comment
Share on other sites

So what is different in the PageSetup for Plotter or PDF, if the paper is constant A3 for a particular layout the only thing that changes is the output device. You still need to have dozens of PageSetup's to apply to various layouts for paper size but each layout can only ever have a choice of 3 output devices (the PageSetup for that layout is fixed), however that layout is set at A3 so you only need choose the output device.

I'm not being deliberately argumentative, the problem I have is that at work we use network printers and getting the -plot command to recognise the name is difficult, if it is setup in a PageSetup then the problem goes away because that is the default value, but if you need to use the plotter name in the macro it causes issues, really all I need to know is how you would like the user to decide on the output device. It can be stored in a variable that is read by a macro, but if it is already saved in a PageSetup life is so much easier.

If each layout is setup for the plotter the macro only has to choose "yes" default or change to pdf or plt.

Link to comment
Share on other sites

Ok. I totally got where we were not connecting.

The thing is that our plotter is a bit old and has a "character".

1) In order to be able to print with correct margins, I had to create a custom paper size with a custom margins and define custom offsets in PageSetup (PS). So plotter is actually using a different paper from the one built-in ACAD PDF creator uses even though the outcome is the same.

2) For our plotter I can only save 5 custom paper sizes per pc3 file. So I created a pc3 file for A3+*A3.2+A3.1+A3.0, A2+A2.1+A2.0 and A1+A1.0 (so it's three pc3 files/plotting devices for ISO paper sizes).

 

So the question is still open - how can I fill in the missing info in command string:

^C^Cpreview;-plot;N;;[value from drawing A1];[value from drawing B1];N;N;

 

*A3.1, A2.0 etc. are the prolonged standart ISO paper sizes (see the image http://imgur.com/7V8d4yV).

Link to comment
Share on other sites

I have just seen your latest reply, before I really look at it, here is the start of an idea, it works here for the first two options. the layout is setup to your plotter so that is the default value, the macro asks you to input a number 0,1 or 2, 0=plotter(default value), 1=DWG To PDF, 2=? this still needs looking at do you have a named device for the PLT option.

^C^C_setenv;plot_to_0=ploter_1=PDF_2=file;\-plot;n;;;$M=$(if,$(eq,$(getenv,plot_to_0=ploter_1=PDF_2=file),0),;,$(if,$(eq,$(getenv,plot_to_0=ploter_1=PDF_2=file),1),"DWG To PDF.pc3";,$(if,$(eq,$(getenv,plot_to_0=ploter_1=PDF_2=file),2),PLT;,^C)));n;

Link to comment
Share on other sites

Ok. I totally got where we were not connecting.

The thing is that our plotter is a bit old and has a "character".

1) In order to be able to print with correct margins, I had to create a custom paper size with a custom margins and define custom offsets in PageSetup (PS). So plotter is actually using a different paper from the one built-in ACAD PDF creator uses even though the outcome is the same.

2) For our plotter I can only save 5 custom paper sizes per pc3 file. So I created a pc3 file for A3+*A3.2+A3.1+A3.0, A2+A2.1+A2.0 and A1+A1.0 (so it's three pc3 files/plotting devices for ISO paper sizes).

So the paper size does actually change per layout depending on the output device, does this mean that you do have a named PageSetup for all the variations.

Edited by SLW210
Fixed quote tag
Link to comment
Share on other sites

OK first thankyou for this question, it got the old grey matter working.

Try this code it will no doubt fail :) but it's a starting point, this does have a few requirements from you first, for each PageSetup name, make a new layer and name it exactly the same (if you have spaces it might not work), on each layout put 3 mtext items with the text "plot" "pdf" "plt". Change the layer of each text to match the PageSetup for that particular layout. I'd just do one layout and 3 layers as a test. If this works you can create a template file with everything setup later.

Next try set macrotrace=1 then run this macro, if it works yippee, it won't so after running it copy the command history and post it here.

When the macro runs it should pause - at this point you need to click one of the text items depending on which device you want - it uses the layer name to use as the PageSetup.

It works here but I don't know your system or the names used

^C^Csetenv;temp;$m=$(getvar,clayer);laymcur;\setenv;temp1;"$m=$(getvar,clayer)";clayer;"$m=$(getenv,temp");-plot;n;;"""$m=$(getenv,temp1)""";;;n;

This shows what I am trying to explain - the word PDF is on the layer A4PDF and A4PDF is the name of the PageSetup for an A4 PDF Layer.jpg

Link to comment
Share on other sites

Haven't used "setenv" "temp" etc. before. It's a whole new world to explore :)

 

1) the code works

2) unfortunately only on LT (I'm using full ACAD myself and some of my collegues are as well)

3) spaces do cause a problem (ACAD interprets it as "enter")

4) for pdf and plt I would suggest adding "~;" at the end of the code, just before last "n" (that brings up the "Save" dialog box)

^C^Csetenv;temp;$m=$(getvar,clayer);laymcur;\setenv;temp1;"$m=$(getvar,clayer)";clayer;"$m=$(getenv,temp");-plot;n;;"""$m=$(getenv,temp1)""";;;~;n;

 

If this was only the first step, I'm ready to hear out the next one. If this was the final solution, I must admit that it's not what I was looking for. I don't want the user to make any other choices but the file name and final question about plotting after the user has pressed one of the buttons (plot/create pdf/create plt)

Link to comment
Share on other sites

Yay +1 for LT, apparently that is an LT only option, usually it's the other way round. I'm sorry if this option is a bit disapointing for you, the basic concept is all I can think of, getting it to work is just tidying up. I have scratched my head over this but can't think of anything that is based in the layout that could be used to read information into a macro even using the setenv command the variable is not locked to a layout, even creating a load of macro's for each PageSetup there isn't a way that I know of, to make a macro layout based. And diesel just doesn't have the descision making capabilities of LISP. The question still remains open though, how did you see the user choosing between the different output devices, you mentioned an attribute or text, but they would still somehow have to set that up first before printing, would that be done manually or by editing.

Link to comment
Share on other sites

The attribute or text would be loaded (imported) with the layout from template. So no problem with that.

If only it was possible at some point in the command string to say "please read and use the value of attribute called "pdf"" the problem would be solved.

Hopefully there is an answer out there. I will post it here if I find it.

Thanks for the work you have done looking for a solution!

Link to comment
Share on other sites

I have 7 different plot settings in a menu you say your using Autocad so each of these just has a different plotter set up for the same size title block. In one place I worked at we had two title blocks ours and a government authority title block slightly different sheet settings so just had two macros not rocket science.

 

For code http://www.cadtutor.net/forum/showthread.php?69132-Printing-LISP-Help...&highlight=Printing-LISP

 

Plotters.jpg

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