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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Repeat code for trail files/mapkey

sammy1994
11-Garnet

Repeat code for trail files/mapkey

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

4 REPLIES 4

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.

RPN
17-Peridot
17-Peridot
(To:sammy1994)

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.

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

 

 

Hi Folks, I have created the web application: 

Repeatable Mapkey Generator | How to loop Creo Mapkey - try to check the video tutorials first:

Best Regards,
Vladimir Palffy
If you enjoy my content, please consider supporting what I do: Buy a Coffee for 4KSide - https://ko-fi.com/vpalffy or DONATE by https://www.paypal.me/4kside WHY SHOULD YOU DONATE TO 4K SIDE? More donation = more money More money allows me to buy more coffee More coffee makes me create more Creo ...
Announcements


Top Tags