cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

pass the filename to the macro

DouglasWade
1-Newbie

pass the filename to the macro

I am creating a perl script to open a file runs a macro and I want it to change the Illustration control number to a new value. Does Isodraw store the filename as a variable? Can I get the filename variable and do search and replace all inside a macro. d
13 REPLIES 13

In the regular Isodraw forum this was answered last week. Below is the information from that post. Note that you can rename the file, however your script would need to delete the original file (you would basically be doing a 'Save as'). Joined: 05 Sep 2007 Posts: 1 Location: Hennef, Germany Posted: Thu Oct 30, 2008 3:27 am Post subject: Filenames in IML -------------------------------------------------------------------------------- The filename of the topmost illustration window can be retrieved in with IML by Code: Define sName as String sName = activeDoc.name To get the entire filepath (including the filename) use Code: Define sPath as String sPath = activeDoc.path There are also some useful string functions for paths and filenames: Code: sFileExtension = getExt(sName) sNameOnly = stripExt(sName) sName = getFilename(sPath), sPathOnly = stripFilename(sPath)

Thanks for listing. I did not see my post from last week, nor when I did a search it return anything (subject or my name). In fact, I was a bit embarrassed that I was unable to find it and you did, so I search again today, it was busy for over 3 minutes without returning any results. But on to my next question: I did not see anything in the Macro guide to do a find/replace? Is there anything in there. I want change a text item. d

A text search and replace can be done by exporting a textfile, doing the s&r in the textfile and open the textfile again. (You would call IsoDraw from your Perl script two times for that)

The following line command will allow you to open a specified file and then apply a macro. We use the Windows shell feature to loop causing multiple files open and have a macro applied. IsoDraw7.exe C:\Batch\FileName.iso -macro"Save_Macro" The above command, as written above, would have to be run from the PTC program folder to properly execute. Also note, if you are running a previous version of IsoDraw, you may need to change the IsoDraw7.exe to reflect the startup file name. Using the above command you could call a macro that did a simple text export. Export c:\temp\FileName.txt "Text_Excerpt" Run your find and replace externally and then run another macro on the file which would open the text file. Open c:\temp\FileName.txt "Text_Excerpt"

Thanks for the help. All is good with one exception. When I open with the text exceprpt, it wants a yes/no button to be pushed to import it. I want that to be silent. I tried on the Open, to have confirm_yes, but that did not help. d

Update: The opening of the text excerpt file, does not import the file. It does not create or change an existing file. Does the text file and original file need to be named the same and or be in the same directory? Again confused... d

Confirm_yes is not what you think. It is NOT an answer to, "Do you want to save?" It is, instead, saying, "Do you want to ask?". To avoid the prompt, use Confirm_no. For the text excerpt, here are a couple lessons learned: 1) No, the text file does NOT need to match the main file name. 2) You can only export once without opening the text file back. If you attempt to export twice in a row, you will end up with a text file that will not update the original file.

"Trevor Hendricks" wrote:

2) You can only export once without opening the text file back. If you attempt to export twice in a row, you will end up with a text file that will not update the original file.

If I follow correctly you are doing the following: 1) Open the iso file and export the text. 2) You do your find and replace in the text file. 3) You then are opening the text file and saving it with an an .iso extension? If the third is how you are doing this, that is your error. What should happen is... 3) Open original iso file, run batch that then opens the text file (while the iso is open). This updates the original iso file. Add a save command to the end of the macro if needed.

"Trevor Hendricks" wrote:

. 3) Open original iso file, run batch that then opens the text file (while the iso is open). This updates the original iso file. Add a save command to the end of the macro if needed.

Can you attach your macro code so I can take a look? I'm not sure why you are getting a confirmation box at this point. Can you confirm the exact text of the prompt to ensure it is asking if it should import the text?

Make sure that once you open your original iso file you are using the "open" command to apply the alterred text file. Example: Open "C:\temp\alterred.txt" "Text_Excerpt"

"Trevor Hendricks" wrote:

Make sure that once you open your original iso file you are using the "open" command to apply the alterred text file. Example: Open "C:\temp\alterred.txt" "Text_Excerpt"

Announcements