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

Level 7

Repeat code for trail files/mapkey

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

2 REPLIES 2

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.