Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hello,
I have a strange problem that I didnt think I would encounter. I am using the Batch Process with a Macro to convert files. One of the things in this macro is to change the active document name to the contents of a variable:
activeDoc.name = strICN
Unfortunately when running the macro using the batch process it doesnt change the name - it keeps the original file name and seems to ignore this command. If I run the Macro within Isodraw it then changes it, and I can then save this manually - however I would prefer to avoid doing this 250 times.
The only thing I can think of is that when using the batch process the file is not an ''active' document so the command will not work (just guessing here), if this is the case how do I change the file name when using the batch process? or is their a command that changes the filename whether it is active or not?
Many thanks for your assistance.
Alan
Solved! Go to Solution.
Just a thought.
What about adding a save command in your macro? You could save it with your new filename in the macro. The batch process would still save the file again with the original filename, so you'd have some files to remove, but you should then have your updated files.
Does your macro actually load the drawings into Isodraw as it works? If so, I would have thought that activeDoc was valid once a drawing is loaded. If not, I think you are right that activeDoc isn't being created for the files you're working on, so maybe the document object would do it, rather than activedoc?
I assume that the Batch Process does open the document to apply the macro, but maybe it isnt classed as an active document as it doesnt open it in the sense that we would manually open a file and theirfore it isnt an active document. But I dont fully understand what the Batch Process actually does behind the scenes - i cannot find this information in the reference material.
When I manually open the file inside isodraw and execute the macro it works perfectly, changing the name of the document, and because it doesnt work using the batch process this makes me think that when the macro is being applied via the batch process, the file is not considered an active document.
I will give your suggestion a try - thanks.
I've never tried this with the IML but in my previous life as a CAD macro programmer, current document commands in a batch process would only work if the documents (drawings) were physically loaded at the time the current document commands were run.
Does your batch process actually load files into Isodraw? i.e. do you see them being loaded, then removed and the next one loaded etc?
Ok, i managed to screen grab the two dialog boxes that come up fast. The first one 'Opens' the file (but you dont actually see the file like you would if you manually opened it) and the second one 'exports' the file.
Thanks Tim
Sorry Alan I forgot you were using the batch process for Isodraw so wouldn't be aware what it's doing outside your macro.
It does sound like it's loading the drawings doesn't it? And the box where you put the macro clearly states it will run the macro on each drawing, so it should have activeDoc.
BUT...Perhaps the batch process doesn't recognise you've changed the filename. The batch process will load the specified file, then save the same specified file - the fact that your macro has changed the file name might be irrelevant to the batch process, and it probably just assumes the name is the same as the one it loaded.
I would be tempted to do the whole thing in a macro, but that would mean extracting the file names for the specified directory and I wouldn't know where to start with this.
Trevor Hendricks is probably better at advising on this
Just a thought.
What about adding a save command in your macro? You could save it with your new filename in the macro. The batch process would still save the file again with the original filename, so you'd have some files to remove, but you should then have your updated files.
I have thought of executing the batch from the CMD line, Trevor has a wiki page he created explainng this process (need to refind). My only problem is their are many options for a WebCGM 2.1 that from what I have read using the save/export function it doesnt seem to have access to these options whilst using a macro and their are a lot of options.
Thanks
Thanks guys - it worked a charm
As a test I created the following macro:
MACRO ActiveDoc
DEFINE strICN AS string
strICN = "Testing_Doc"
activeDoc.name = strICN
END MACRO
When I executed the macro whilst I had the document open in isodraw it changed the name of the document. When called this macro from the batch process it didnt resave the file to 'Testing_Doc'.
I am going to try another test, such as 'IF active doc then do this...' if it doesnt do the 'this' then I would say Batch Process doesnt make the files active documents.
Will report back shortly.
Thanks
Ok I executed the following macro using the batch process:
MACRO ActiveDoc
DEFINE strICN AS string
strICN = "Testing_Doc"
IF (exists(activeDoc))
Create Text 750 25 strICN
END IF
END MACRO
It worked, it inserted the text 'Testing_Doc' this is getting annoying. Maybe the batch process just doesnt let you change the name, maybe its read only?...I dont quite see the harm in changing the name of the document.
If anyone has any suggestions or answers please share.
Thanks
Remember what the purpose of the batch tool is. The tool is meant to take a file, open it, run a macro (optional) to modify it, and then save it as something else. My strong assumption is that the tool looks in the source folder | grabs a file, | assigns the root name to an internal variable | run macro (if present) | and then saves the file in the new format with the new extension.
The approach to take was mentioned earlier in the thread.
Using the batch tool, you'll need to code your macro to save out the destination file (the batch tool will still output it's normal file, but just delete these when it is done). To do this, you can use the activedoc command to grab the root file name.
Also, you can specify settings for all file types by macro. It's a little tedious, but can be done. I've attached the excerpt from the IsoDraw documentation advising how to make the changes.
Thanks for all the direction and suggestions, I will implement this first thing in the morning - my head is battered and I am going home.
Much appreciation to you both.
Alan