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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Isodraw 7.1 Macro query

ptc-1663523
1-Newbie

Isodraw 7.1 Macro query

Hi all,

 

I am new to this so please be patient.

 

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?

 

Cheers

 


Macro test

 

#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

End Macro

 


#Format for running from command line and saving as base iso format
#IsoDraw71.exe -batch -s"C:\Batchin" -d"C:\Batchout" -f0 -m"test"

1 REPLY 1

Only partial answers here unfortunately.

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

Sudo code:

  1. Add a new text element on an empty page (doesn't matter where).
  2. Populate it with a unique piece of text (something easy to find later).
  3. Export text (you could use xcf if you prefer, but you'll need to add object info to the text so that it exports).
  4. 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.
  5. Once your file has the updated directory listing for that text element you can open the text file.
  6. 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.
  7. 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.

macro layerLoop

     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

    End While

end macro

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.

Top Tags