PDA

View Full Version : How associate "Filename -> partname" ?


ukawa
04-07-2004, 07:41 AM
Hi

I am looking for a macro for my me10 version 10.5 (Windows 2000):
I would like to take the name of the open file and set that as name of the
active part.

Example: I open the file "pippo.mi" , I activate the macro and the name of
active part becomes "pippo"

I have tried the function "INQ_ENV 0 DISPLAY (INQ 304) " but it doesn't work well.

Can someone give me some suggestion ?
Thanks
Regards

John Scheffel
04-07-2004, 09:48 AM
The main challenge is to extract the base name of the file from the full path returned by the INQ 304. Since I already had some code to do this, I created a macro to do what you want. Try the Name_part_to_file macro in the attached file. I only tested this in Drafting 12. I don't have version 10.50 any longer so could not test it.

There is one limitation with this macro. It assumes the file name contains either zero periods or one period, and it removes the first period it finds and everything after that. So if you have a filename with a period that is part of the name (such as "my.file.mi" or "my.filename"), it will not produce the intended result (will name the part "my" in each case). It would be possible to make it remove only the last period and what follows, or only remove a ".mi" extension, but from your description it was unclear if this was an issue. If you want it to work with filenames containing periods, you will have to come up with some guidelines for if/when they should be kept.

ukawa
04-08-2004, 12:47 AM
Hi

First I would say "thank you" to John Scheffel for his availability immediately to furnish me a good macro.

Unfortunately this doesn't perfectly work.

I work with files like this: "ABC-110-001.mi" , when I activate the macro the name of the part becomes "110001" ..... I lose the first three letters "ABC" and two "-"

Some suggestion? Can be the function INQ_ENV 0 DISPLAY (INQ 304) doesn't work in the same way between different version of me10 ?

Thanks

John Scheffel
04-08-2004, 10:39 AM
I tried the file name "ABC-110-001.mi" in version 12 and it worked fine. I did find a PC with ME10 10.50 installed and tried it there, but it didn't work at all. I checked the 10.50 help and it doesn't list a value for INQ 304 under INQ_ENV 0. I tried it on the PC and INQ 304 returns the name of the top part, not the file name. So you must be looking at the Help from another version.

The version 11.6 help does show INQ 304 as returning the full path of the file name. I think version 11 was the first one to support this INQ value, so that may be why it doesn't work for you.

ukawa
04-09-2004, 12:27 AM
Hi

I premise that I don't know very well the macros's language.
I have tried to look the guide (v.10.5) and I have found this:

INQ_ENV 0 DISPLAY (INQ 304) = I have not found the correspondence
INQ_ENV 0 DISPLAY (INQ 303) = path directory (only path directory)

I have found a command that perhaps it was good:

INQ_DB 2 DISPLAY (INQ 301) but it works only on Unix.

For now nothing cannot be done on my me10 version.
However thanks anyway , you have been very available.
Regards (...and excuse me for my bad English)

pcushion
04-06-2005, 03:31 AM
Hi John,

I found this macro VERY useful.
I have one request; I like to place an underscore ( _ ) before my part names.
Where in the macro could I add this character.

Thanks.
Paul.

John Scheffel
04-06-2005, 03:19 PM
To add an underscore before the part name, you can change the end of the macro to look like this (added one line with <-- comment).

...
ELSE
LET Partname Basename
END_IF
LET Partname ('_'+Partname) {<-- Add an underscore before part name}
{EDIT_PART TOP} {uncomment this if you want to always rename the top part}
RENAME_PART Partname
END_DEFINE

pcushion
04-07-2005, 01:46 AM
Hi John,

That worked great - Thanks.

Paul.