PDA

View Full Version : original file path (macro)


grande-mago
09-14-2005, 07:38 AM
How I can store the path of the file that is open in Designer drafting? I use the release 11.60.
Generally I do this step:
1. open the file (The file is on the Server: \\cadserver1\drawings\ (file://\\cadserver1\drawings\)...)
2. sometimes I save the file on my PC with the command Save as... (c:\...) so the software store the
new path (c:\...) and loose the orignal path (\\cadserver1\drawings\ (file://\\cadserver1\drawings\)...)
3. Then I want save the file on the server, in the original path, but I don't know what is the original
path because I manage the file with a PDM software.
I think that the better solution is to store the original path inside the file .mi but I don't know
where and how. When I want to store the file .mi on the server I read (with a macro) the original path.

John Scheffel
09-14-2005, 08:31 AM
I don't know if this helps, but you can inquire the full path of the current drawing using:

INQ_ENV 0
LET Full_file_path (INQ 304)

If the drawing has not been saved since loading, this will return the path it was loaded from. If it has been saved, this will return the path it was saved to. If you just want the path and not the file name you would need to parse it out.

The only way I know to store information with a MI file is to use an INFO. This is a text string that can be attached to drawing entities such as parts, lines, text, etc.

So I think you could write a macro which inquires the current full path, then attaches an INFO to the Top part to save this path. However, I have never tried this and don't have a macro to offer.

grande-mago
09-14-2005, 10:15 PM
Thank you very much, your reply confirm my idea, but I don't find a macro (or only the command) to store INFO on TOP part.
Can somebody help me?

John Scheffel
09-15-2005, 12:23 PM
You can add an info to the Top part with a statement similar to:

ADD_ELEM_INFO 'info_string' SELECT PARTS '/' CONFIRM END
where info_string is a text string that becomes the INFO attached to the top part. This can be any string you want, but in order to identify which info contains the file name you may want to use a key, something like:

SERVER_PATH:\\cadserver1\drawings\...

There is nothing unique about the colon, but it it commonly used in INFOs to separate fields. After you load the file, you can search for this info and extract the server path with code such as:

LOCAL Server_path
LOCAL Pos_colon
LET Server_path 'Not_found'
INQ_PART '/'
LOOP
LET Info_text (INQ 905)
IF (POS Info_text 'SERVER_PATH:')
LET Pos_colon (POS Info_text ':')
LET Server_path (SUBSTR Info_text (Pos_colon+1) ((LEN Info_text)-Pos_colon+1))
END_IF
EXIT_IF (Info_text='END-OF-LIST')
END_LOOP
IF (Server_path = 'Not_found')
DISPLAY 'Top part did not contain server path'
ELSE
STORE Server_path
END_IF

I haven't tested any of this so it may not work as is, but it should get you close.

grande-mago
09-16-2005, 05:46 AM
thank you very much !!! This this very useful.
The macro work very well !!