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

Batch Process with Macro to Change Name

SOLVED
Highlighted
Newbie

Batch Process with Macro to Change Name

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Batch Process with Macro to Change Name

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.

12 REPLIES 12

Re: Batch Process with Macro to Change Name

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?

Re: Batch Process with Macro to Change Name

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.

Re: Batch Process with Macro to Change Name

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?

Re: Batch Process with Macro to Change Name

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

Re: Batch Process with Macro to Change Name

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

Re: Batch Process with Macro to Change Name

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

Re: Batch Process with Macro to Change Name

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

Re: Batch Process with Macro to Change Name

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.

Re: Batch Process with Macro to Change Name

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