getting Plan Filename for purposes of loading plan info from a text file


SHCanada2
 Share

Recommended Posts

Earlier this year I could not get the current plan's filename, joe had posted a suggestion a couple years ago, which I added my request to as well

 

 

today I was playing around with material lists and came across a method to get the current plan filename  and/or  path into a global variable.

 

I would like to know if anyone has tried it(or another method) and had success or not.

 

Essentially you do four things for this method:

1. in the OIP put in %file.dir% into one of the fields, I used "manufacturer"

2. in the components tab,  pick a field, lets say "manufacturer" as well, and put in =manufacturer

3. in another field on the components tab, lets say, "comments" put in a macro lets say named "=macros.setpathname" and have it use "apply formula to line item"

4. in the macro setpathname put in $file1=manufacturer

 

I think the reason it works is that the file.dir gets converted to a string once the materials list applies the macro in the formula

 

Couple caveats, in order to get it to update, you have to do one of two things that i have found so far:

1. go into the components tab and click on the field where the macro is specified. It will fire the macro once you leave the field

2. generate a materials list

 

so of course the problem is once it runs, the value is only in the global variable and does not actually get stored as text somewhere in the plan where it would be static until the next time it runs. This means everytime you open the file in CA, the textbox containing your plan info is blank (because the global variable has not been set).

 

it is static in the materials list,, but I'm not sure how to get it out of there

 

any ideas on either how to store data from a global variable in a plan file such that it does not get updated if the global variable is not set? or some other method to get the materials list to fire automagically ?

 

thanks

 

 

Link to comment
Share on other sites

I did stumble upon doing this while experimenting: in a polyline label:

 

%$file88="%file.dir%"%

 

it seems to set the global variable $file88 with the filename directory.

 

In another another macro I have (in another polyline label), it uses $file88 to read in some stuff in a file, such as customer address.. Testing by issuing a "save as" to another directory looks to update the contents of the file in another directory.

 

so I looks to be working. I assume it could work for other CA internal macros. I think you could then in theory use one polyline label with:

%$filedir="%file.dir%"%

%$filename="%file%"%

.....

 

and then use the global variables as you please

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share