Below is a macro I created. I have added statements to explain what is happening throughout and It works fine if I load a CGM into isodraw and then run the macro.
The problem comes when I call the macro from the batch process tool. That's where it crashes and burns. I have also tried running this from the command line but the same thing happens.
It is pretty clear to me that closing the document is causing the batch tool to go down. So if anyone knows some extra code I could use to just loop within my macro the number of times, equivalent to the number of CGM in my source directory I think it would do the trick.
Any ideas would be appreciated.
One other question: is there a line of code I can use to lock and unlock certain layers?
#Save original document number as string. DEFINE doc AS string doc = 'ICN-' + activeDoc.name
#SELECT THE WHOLE DRAWING select all
MESSAGE "the file's full name is: " + doc
Group Selection COPY
##########works up until here using batch programme###################
#Closes source document CLOSE CONFIRM_NO
#hard coded to open official Project Pageframe Open "C:\Batchin\951pageframe.iso" activeDoc.name = doc ACTIVATE LAYER "Standard layer"
#Delete existing blank ERM and ICN numbers Select if Text contains 'ERM' Delete selection Select if Text contains 'AAAAAA' Delete selection
PASTE Selection SAME_POSITION Ungroup Selection
DEFINE path AS string path = 'C:\Batchout\'
#MESSAGE "File will be saved as: " path + name + extension
Save path + doc #CLOSE CONFIRM_NO
#Format for running from command line and saving as base iso format #IsoDraw71.exe -batch -s"C:\Batchin" -d"C:\Batchout" -f0 -m"test"
In regards to a method to have the macro cycle through...seemed like I had a better way of doing this before, but here is a screwed up approach since I can't remember
Add a new text element on an empty page (doesn't matter where).
Populate it with a unique piece of text (something easy to find later).
Export text (you could use xcf if you prefer, but you'll need to add object info to the text so that it exports).
Once the file is exported you can use your unique text (ref #2) to find the line you want to edit. Then use cmd or whatever to get a directory listing.
Once your file has the updated directory listing for that text element you can open the text file.
The variable will now contain your listing. There is a character limitation, but you should be able to get fair sized loads like this anyways.
Parse the element with the string tools to loop through all the names running your submacro.
Sounds like overkill but at the moment that's what comes to mind.
In regards to layer locking, no one line code that I'm aware to lock all but one. You'll need to loop over the layers.
Define i as Integer
Define CurrentLayer as Layer
Define LayerName as String
i = ActiveDoc.LayerCount
CurrentLayer = ActiveDoc.Layers[i]
While (Exists(CurrentLayer) = True)
LayerName = CurrentLayer.Name
ActiveDoc.Layers[LayerName].Exportable = False
ActiveDoc.Layers[LayerName].Printable = False
CurrentLayer = CurrentLayer.PreviousSibling
This macro has not been tested but the intent is turn exportability and printing off for each layer. Mod for you purposes. In order to turn one layer on (or off), just add a check of the LayerName to skip what you design. If you'll use this a lot, set it up as a submacro, add a global variable for the layer you want to turn on/off. You can then set the variable and call the submacro whenever needed.