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

Repeat code for trail files/mapkey

Highlighted
Garnet

Repeat code for trail files/mapkey

Does anyone know the code to repeat block for doing specific action in trail file/mapkey?

3 REPLIES 3
Highlighted

Re: Repeat code for trail files/mapkey

I don't think there is any sort of looping functionality in trail files or map keys, based upon the fact that there is none for relations. No "for", "do...while", or "repeat...until" constructs. The execution of commands is analogous to a tape running through a reader. It proceeds straight through the code and your only logical branching is done with "if" statements.

Highlighted

Re: Repeat code for trail files/mapkey

In a-synchronous mode you can easily write your own control structure und use while, for or what ever control structure. This example will open files, give by it full path and generate a STEP or IGES output. With Tcl it is very easy to deal with strings, this makes it easy to manipulate mapkey's.

 

#
# Main Action, Hardcoded here
# Input where ever you get the full path from
#
proc MK_Action {} {

        set files [list]
        lappend files c:/CreoTickle/work/models/blower.asm
        lappend files c:/CreoTickle/work/models/frame.prt
        lappend files c:/CreoTickle/work/models/nut.prt
        lappend files c:/CreoTickle/work/models/piston_pin.prt

        foreach file $files        {

                MK_Quit_Window
                # Run the Mapkey
                MK_Change_Dir        [file dirname $file]
                # Or write on the fly a config file
                # MK_Change_Dir_By_Config_File [file dirname $file]
                MK_File_Open        [file tail $file]
                MK_File_Save_As        STEP
        }


        MK_Quit_Window

}

The complete code can be found in Mapkeys - Use Mapkey in Asynchronous mode

Using this is helpful for beginners, but at the end you don't have really a function feedback (Return code), and the map key's may change from version to version. But if you have a mapkey library it's for sure very easy to program. Generate all the mapkey can be time consuming as well.

Highlighted

Re: Repeat code for trail files/mapkey

You can actually do this easily in OpenSource CREOSON (depending on the language you want to use)...

 

Trail Files are a bit more sensitive ... but Mapkeys seem to work well.

 

  1. Just record the mapkey
  2. Save to config.pro
  3. Open the config.pro
  4. Copy the mapkey body out and create a variable/reference in your automation script. (e.g. myMapKey)
  5. Replace the current selection reference (e.g. filename) with something generic like "FILENAME"
  6. Loop through your files... replacing "FILENAME" in your "myMapKey" variable with your current file and execute the modified mapkey on with each iteration...
  7. Smile 🙂

This depends on the language you want to use... but with CREOSON you have many options due to the generic JSON interface.    Javascript and Python are good examples of how this is being used currently...

 

Hope that helps!

 

Dave

 

 

Announcements