Author Topic: Macro to save file name & location  (Read 188 times)

Pearco

  • Hero Member
  • *****
  • Posts: 841
Macro to save file name & location
« on: September 07, 2017, 02:18:44 PM »
Hi Dcad macro gurus;

What I would like to do is with a toolbar and BasicCad code  when I get the drawing finished, is click on the toolbar and print the complete path to where the the file is stored. Then later I can look at the print and know where to find the file. Problem is this code is beyond my ability. Is this even possible in BasicCad or does one exist ?

Thank to any help.
Jim
User since ProDesign 1.5

bdeck

  • Hero Member
  • *****
  • Posts: 825
Re: Macro to save file name & location
« Reply #1 on: September 07, 2017, 11:56:31 PM »
Hi Pearco,

Prl, BobP, Lar, JJG, Dempsey, RobS, etal, appear to be busy, so I'll try to answer.
 
Here are two macros I use from the command line to label drawings. They use the current text size, but you could modify them to your taste.

I recommend making text file copies of the sys and sys$ variable listings from the Macros17.hlp file. (help files do not allow word searches within the listings, text files do )

One caveat: Sys$(2) and sys$(3) return the path and name of most recently saved file, even from a prior session, if the current file has never been saved.

I find it easier to type [spc] "gfn" [enter] than to click a button. Easier still if I shorten the names to "gf" and "gff".  So I'll leave the tool bar part to someone else. I don't use the macro often enough to justify a hotkey or a button.

It would be great if DC could do this automatically in the margin of every printout, along with the date and time. My PLC software has done that for 25 years. Too much to ask? Must be time for another macro.

Regards
bd

Code: [Select]
'gfp.d3m    get file path and put it in a text field
fname$=sys$(2)   'name and path
>Text2D
{
<Text [fname$]
<incomplete
}

Code: [Select]
'gfn.d3m    get file name and put it in a text field
fname$=sys$(3)  'name only
>Text2D
{
<Text [fname$]
<incomplete
}
« Last Edit: September 08, 2017, 09:55:50 AM by bdeck »

Pearco

  • Hero Member
  • *****
  • Posts: 841
Re: Macro to save file name & location
« Reply #2 on: September 08, 2017, 03:22:17 AM »
bd;
Thanks a lot. You guys make coding look so easy and so simple.

Again thank you.
Jim
User since ProDesign 1.5

Dr PR

  • Hero Member
  • *****
  • Posts: 5472
Re: Macro to save file name & location
« Reply #3 on: September 08, 2017, 09:06:56 PM »
bd,

Rob and others an I have requested variables that can be embedded in files to place things like the date, time, file name, path, etc. in drawings. If we had these we could put them in title boxes to they would always be printed automatically.

Phil
DesignCAD user since 1987

Rob S

  • Hero Member
  • *****
  • Posts: 4381
    • Construction Estimating Program for General Contractors
Re: Macro to save file name & location
« Reply #4 on: September 09, 2017, 07:09:01 AM »
Exactly.

Seems like such a relatively simple and yet so useful feature to add.

We already have basicad to produce the text strings we want, all we need is a way to display the result.
User since Pro-design

bdeck

  • Hero Member
  • *****
  • Posts: 825
Re: Macro to save file name & location
« Reply #5 on: September 09, 2017, 10:32:09 AM »
Rob and others an I have requested variables that can be embedded in files to place things like the date, time, file name, path, etc. in drawings. If we had these we could put them in title boxes so they would always be printed automatically.
Hi Phil,

Those variables are an excellent idea, and the idea of a self-populating title box is appealing, even though most of that can be done with a macro.

But that doesn't reliably address the present issue of forced version control.

What I am suggesting is a single line of data that gets printed by default (subject to a global option setting, I guess), where the print status of the data can be changed at print time (with a non persistent checkbox). The filepath, name, print date, and last save date  would be printed in along the margin, scaled to the page size (subject to a minimum and maximum text size). Again, this is 2017. I should not have to create a title box for in-house shop drawings or drafts, or for partial views using Print Section, Print Selection Only, or Fast Print. (I don't get paid by the hour.)

Doing this in a macro is really not practical. The macro would have to replace every print function in DC. And it would have to be installed so that the installation intercepts every possible route for the user to get to a print function.  Much easier for DC to do it at the final print stage. 

Also,  I don't see any way in a macro to find the save date of a file, or to override sys$(2-3) in an unsaved session.

Best
bd

« Last Edit: September 09, 2017, 11:13:27 AM by bdeck »

Rob S

  • Hero Member
  • *****
  • Posts: 4381
    • Construction Estimating Program for General Contractors
Re: Macro to save file name & location
« Reply #6 on: September 09, 2017, 10:51:33 AM »
Word and Excel do something like this in a defineable page header or footer, but you still have to define that header for each document.

Are there any programs you know of that already do this, where such a "page footer" can be defined and activated from the print dialog???

How would you want it to work in a panelled printout - once per sheet, or once only in the bottom right panel?

I wonder if a per-document footer, which could be copied and pasted from one document to the next might be useful, if doing it in the print dialog is too difficult. 

I would still prefer a way to print defineable variables in any line of text, as we all use different page layouts and titleblock designs.

For anyone doing a lot of drawings, this would be made part of their paperspace titleblock template, and thus no need to recreate for each drawing.

User since Pro-design

bdeck

  • Hero Member
  • *****
  • Posts: 825
Re: Macro to save file name & location
« Reply #7 on: September 09, 2017, 11:05:19 AM »
Are there any programs you know of that already do this, where such a "page footer" can be defined and activated from the print dialog???

How would you want it to work in a panelled printout - once per sheet, or once only in the bottom right panel?

Hi Rob S,

Automation Direct PLC software puts the file path and date in the printer margin of every page, automatically, buy default. Dunno if it can be changed. Never wanted to change it.

Whether I would want a customer, supplier,  or lawyer to have that info would be a separate question.

The whole point of version control is that the user does nothing. It is an automatic part of every printed page (unless explicitly defeated). I'm guessing that means every tile, as well.

bd
« Last Edit: September 10, 2017, 08:16:06 PM by bdeck »

Lar

  • Hero Member
  • *****
  • Posts: 2580
Re: Macro to save file name & location
« Reply #8 on: September 12, 2017, 05:46:39 PM »

Are there any programs you know of that already do this, where such a "page footer" can be defined and activated from the print dialog???
I can code things like this in Cinema 4D, because it has dynamic macros -  macros that are always on (once enabled). So I can control one entity's properties by another remote condition. Eg, Entity A's RGB values can be dependent on Entity B's angle, so whenever I rotate B, A's color changes. So, for a text entity I can make it display the current date and time, Then I attach this text entity to a camera and scale and position it close to the camera's lens so it always display where I want it in the picture, no matter how I turn the camera.


To do something similar in dcad you would have to place Blocks of the text wherever necessary (best in paper space sheet area - ie, not in model space), then before you print you would have to run a macro that redefines that Block to the current date/time.


Lar