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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Exporting animated sequences of images out of Creo Parametric

dcokin
14-Alexandrite

Exporting animated sequences of images out of Creo Parametric

Sometimes I like to animate flexible things that can't be done with kinematics (e.g. springs), or setup complicated simulations depending on a time parameter.  Setup a relation such as "value = value + 1", and the model will update with every regeneration.  Then save an image file after each update, and create a GIF (or other video file) with the results.  This is pretty easy to do if you only have a small number of frames, but for a large number, the lack of automation will become a problem.

 

I had initially thought I could automate this with a mapkey, but I hit a brick wall trying to save an image with a unique filename each time.  (I got as far as using relations to compose a properly formatted filename, getting a mapkey to copy the value, and paste into the filename field when saving the image... but turns out mapkeys are actually not capable of copy/paste operations on playback.)  I wound up creating a mapkey that calls a windows batch file, which writes a new customized mapkey for the desired animation, spelling out all the regenerations and saves.  (The *.bat file uses a loop; the custom mapkey does not, it's like a long player piano scroll, with a new filename specified for each loop.)

 

This was far a more complicated effort than the initial simulation I was working on!  Since it was done on my own time and not at the direction of my employer, and isn't even related to our industry, I've decided to release the utility with a General Public License.  I've tested it with Creo Parametric 2.0 & 4.0, and it works equivalently on both platforms.  So, I doubt there will be issues with Creo 3.0.  Haven't been able to test with Creo 5.0, as our license server does not support it.  Like any mapkey, these are very likely to break with new versions of Creo, if the GUI they manipulate has changed.  But hopefully, will be easy to fix in the future when this happens.  The mapkeys are broken up into subroutines that perform just one function each, to make isolating and fixing problems easier.  The code is full of comments with helpful hints and instructions on how to make updates in the future.

 

The 3 files needed to make it work are pasted below, but you may wish to check my github for any updates:

https://github.com/wackyneighbor/Image_Sequence_Animation_Exporter_for_Creo_Parametric

 

Files needed:

  • animation_relations_sample.txt - Paste the contents of this file into the model you wish to animate, and follow included notes for creating needed model parameters
  • animation_start_mapkey.pro - This file includes the code for the "mapkey" used to start the process. Paste the contents of this into your "config.pro" settings file if you'd like this to be always available.  Otherwise, save the file somewhere convenient, such as your Creo "working directory", and import whenever needed.  (File / Options / Configuration Editor / Import configuration file)
  • animation_sequence_mapkey_generator.bat - This generates a customized mapkey for the desired animation. It MUST be saved in your Creo "working directory".

To use:

  • Set up model to be animated, using relations from sample file, and ensure the initial mapkeys have been imported into your current session.
  • Type "configanim".
  • Follow the instructions in the console window that appears. You will be prompted for the number of regenerations to use between frames, the name of the saved view orientation to reset after regeneration (optional; only needed for perspective views), the number of frames to save, the height & width in pixels for the exported images, the filename prefix to use for the images, whether to use default of *.png image format, or switch to *.tif (Creo 2.0 doesn't support *.png).
  • Image files will be saved to your Creo "working directory".

Alternatively:

  • To skip the configuration dialog and begin exporting a sequence using the same settings last configured, type "cycleanim".
  • Import the "animation_sequence_mapkey.pro" file that was left in your working directory to use a "cycleanim" created in a previous session.

To avoid "letterboxed" output, and ensure on-screen annotations appear as WYSIWYG:

Although you specify the precise dimensions of your output images, Creo will letterbox the results to match the aspect ratio of your current model viewport window.  Additionally, any on-screen annotations that are shown will have proportions relative to your current model viewport, rather than the size of your output images.  The window size may shift along with changes to your computer's monitor resolution (such as if you shut the lid of a laptop).

 

To prevent these issues and ensure you get consistent output, it is advisable to lock the interactive viewport window to be the same dimensions you will use for image export.  You may do this with the hidden config.pro setting "force_base_size 1280 720" (where 1280 and 720 are the desired width and height in pixels, respectively).  Note that you must add this line to your config.pro before launching Creo.  Adding this config setting to an active session will have no effect, although you may change the current height and width settings at any time during a session where the setting was activated.  This is not a convenient setting to have in effect at any time when you are not exporting animations, so be sure to remove the line from your config.pro afterwards.  (Or comment out by preceding with "!")

 

Desired enhancements:

  • A convenient mechanism to cancel a recording in progress.
  • Include system for moving light sources between frames, such as the sun going across the sky. This could be accomplished by analyzing the location of two datum points, and writing the coordinates to a file outside of Creo.  Use *.bat file to parse this file for the coordinates, and create a customized *.dlg file specifying these locations as the source & aim point for a distant light.  Import the light to the current scene before saving image.
  • Use photo-realistic rendering for each frame, rather than just saving an image.

animation_relations_sample.txt:

/* Creo Parametric relations for animating via regeneration loops
/* by Darren Cokin  v1.0 November 2018   General Public License
/*
/* Replace <animated_parameter> with the parameter or dimension you would like
/* to vary.  Replace <starting_value> with a parameter, or just enter a number.
/* Replace <animation_increment> with a parameter, or just enter a non-zero
/* number.
/*
/* Please create the following standard animation control parameters in the
/* model, with indicated types:
/*        animate_with_every_regen = yes no
/*         animation_current_frame = integer
/*            regenerations_needed = integer
/*            regeneration_counter = integer
/*                    dynamic_text = string
/*
/* If you would like your model to include a control panel, with flat to screen
/* text overlaid on the model where parameters can be displayed and varied,
/* you may also wish it to disappear when it's time to save an image.  Create
/* as an annotation feature, and edit model's program (Tools / Model Intent /
/* Program) to include this statement before the feature's "ADD FEATURE"
/* statement:
/*   if animate_with_every_regen == no | (animate_with_every_regen == yes & \
/*     regeneration_counter != regenerations_needed)
/* And also include an "endif" statement after the the feature's "END ADD"
/* statement.
/*
/* Begin animation control algorithm:
/* If animation is not active, reset animated parameter to starting value,
/* reset frame count, reset regeneration count, and reset dynamic text.
if animate_with_every_regen == no
    <animated_parameter> = <starting_value>
    animation_current_frame = 1
    regeneration_counter = 1
    dynamic_text = "SIMULATION IS NOT RUNNING"
else
    /* Check if this is the second to last regeneration cycle.  This is when the
    /* model is fully regenerated, and we save the image for the animation
    /* frame.
    /* Increment regeneration count, and update dynamic text.
    if regeneration_counter == regenerations_needed - 1
        regeneration_counter = regeneration_counter + 1
        dynamic_text = "SIMULATION FRAME " + itos(animation_current_frame) + \
          + " READY.  REGENERATE " + itos(regenerations_needed) + \
          "X TO CONTINUE AFTER SCREEN CAPTURED."
    else
        /* Check if this is the last regeneration cycle.  If so, increment
        /* animated parameter, increment frame counter, reset regeneration
        /* counter, and update dynamic text.
        if regeneration_counter == regenerations_needed
            regeneration_counter = 1
            animation_current_frame = animation_current_frame + 1
            <animated_parameter> = <animated_parameter> + <animation_increment>
            
            /* if user had only requested one regeneration cycle, it will go
            /* to this part of loop every cycle.  Use alternate dynamic text
            /* in that case.
            if regenerations_needed == 1
                dynamic_text = "SIMULATION FRAME " + \
                  itos(animation_current_frame) + \
                  " READY.  REGENERATE TO CONTINUE AFTER SCREEN CAPTURED."
            else
            /* update dynamic text for usual case with multiple regens
                dynamic_text = "SIMULATION FRAME " + itos(\
                  animation_current_frame) + " IN WORK.  REGENERATE " + \
                  itos(regenerations_needed - 1) + "X MORE."
            endif
        else
            /* When in any regen cycle that isn't the last or second to last,
            /* just increment the regeneration counter and dynamic text.
            regeneration_counter = regeneration_counter + 1
            dynamic_text = "SIMULATION FRAME " + itos(\
              animation_current_frame) + " IN WORK.  REGENERATE " + \
              itos(regenerations_needed - regeneration_counter) + "X MORE."
        endif
    endif
endif

animation_start_mapkey.pro:

! Welcome to the Image Sequence Animation Mapkey Generator for Creo Parametric
! by Darren Cokin  v1.0 November 2018   General Public License
!
!  Mapkeys:
!    configanim = configure a new animation sequence, and start it running
!    cycleanim = restart animation using last configuration
!    importmapkey = reload last configuration created in previous session
!                   into current session, so 'cycleanim' is available 

! This subroutine imports the newly created animation_sequence_mapkey.pro file
! into the current Creo Parmametric session.
mapkey importmapkey @MAPKEY_LABELimports *.pro file with mapkey to save entire animation;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `PREVIEW_POPUP_TIMER` \
mapkey(continued) `main_dlg_w1:PHTLeft.AssyTree:<NULL>`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Activate `file_open` `Current Dir`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 \
mapkey(continued) `animation_sequence_mapkey.pro`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `PREVIEW_POPUP_TIMER` \
mapkey(continued) `file_open:Ph_list.Filelist:<NULL>`;\
mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\
mapkey(continued) ~ FocusIn `UITools Msg Dialog Future` `no`;\
mapkey(continued) ~ Activate `UITools Msg Dialog Future` `no`;

! This mapkey launches the "animation_sequence_mapkey_generator.bat" utility,
! which will prompt the user for various inputs, and then write a custom
! animation_sequence_mapkey.pro file.  This mapkey then continues to call a
! subroutine to import that file into the current session, and then starts
! running the animation sequence via the mapkey in that file.
mapkey configanim @MAPKEY_LABELconfigures new animation and starts it;\
mapkey(continued) @SYSTEManimation_sequence_mapkey_generator.bat;\
mapkey(continued) %importmapkey;%cycleanim;

animation_sequence_mapkey_generator.bat:

see comments; hit length limit in this post

 

ACCEPTED SOLUTION

Accepted Solutions

This is awesome and exactly what I need!  However, I'm having trouble getting it to work.  Using Creo 7.0.2.0.  The batch runs ok and produces the images but it seems like regeneration isn't actually changing the model geometry.  All the images are identical.  I've tried up to 9 regens and the results are all the same.  When I manually change the desired parameter, the geometry changes (after 2 regens).  Any thoughts?

View solution in original post

5 REPLIES 5
dcokin
14-Alexandrite
(To:dcokin)

animation_sequence_mapkey_generator.bat:  (PART 1 of 2)

: Image Sequence Animation Mapkey Generator for Creo Parametric
: by Darren Cokin  v1.0 November 2018   General Public License
:
: Note that ":" is the comment prefix for *.bat files, "/*" is the comment
: prefix for relations, and "!" is the comment prefix for *.pro files used to
: define mapkeys. (do not include comment lines within a mapkey.)
:
: TROUBLESHOOTING BROKEN MAPKEYS FOR NEW VERSIONS OF CREO PARAMETRIC
: Since mapkeys rely on the user interface, they are prone to breaking
: when the user interface changes.  Certain subroutines below are more likely
: to break than others, they are identified in comments.  Once a broken
: subroutine is identified, record a new mapkey with latest version of Creo
: Parametric that performs the same function, and paste the code into this
: file, with some particular changes.  In image saving mapkey for instance,
: the specified filename, height & width should be replaced with a variables.
:
: Note that within a mapkey, every line after the first one starts with a
: "mapkey(continued) " statement and every line except for the last one ends
: with a "\" continuation character.
:
: There is an 80 character length limit for lines in a mapkey, which means
: 61 characters maximum between "mapkey(continued)" and "\".
:
: When putting mapkey code in this file, preceed every line with "echo ", and
: end every line with ">>animation_sequence_mapkey.pro".  Note that these do
: not contribute to the 80 character limit.
:
: Various characters in the mapkey code and comments must be "escaped" when
: written in a *.bat file such as this.
:      replace < with ^<
:      replace > with ^>
:      replace & with ^&
:      replace % with %%
:
: additional escape characters are needed inside FOR loops & IF statements
:      replace ( with ^(
:      replace ) with ^)
:      replace ; with ^;
:
:   Thus, for a mapkey that is repeated in a loop, like the last one in
:   this file, each line should start with:
:      "mapkey^(continued^) "
:
: Note that escape characters do not contribute to the 80 character limit.

@echo off
Title Image Sequence Animation Mapkey Generator for Creo Parametric
Mode Con Cols=80 lines=20 & color 81

echo Welcome to the Image Sequence Animation Mapkey Generator for Creo Parametric
echo by Darren Cokin  v1.0

echo.
echo.
echo Tested ^& working with Creo Parametric 2.0 ^& 4.0.  Note that mapkey code
echo such as generated by this utility is very likely to stop working with future
echo versions of Creo, as the GUI features they are attempting to control may have
echo changed.  Troubleshooting and fixing should be relatively easy, as the mapkeys
echo are broken up into subroutines that perform one action each.  Once the problem
echo is identified, a mapkey that performs the same function in the new version of
echo Creo Parametric could be recorded, and the code pasted in place.  (With escape
echo characters and variables added as needed, see comments in source code of this
echo utility for advice.)
echo.
echo    This utility should have been distributed with a text file called
echo    "animation_relations_sample.txt" which provides code that can be
echo    pasted into a 3D model for easy compatibility with this utility.
echo.
echo.
pause
cls

echo Welcome to the Image Sequence Animation Mapkey Generator for Creo Parametric
echo by Darren Cokin
echo.
echo.
echo How many times would you like to regenerate the model between frame captures?
echo Enter a number between 1 - 9 (or leave blank to accept default value of 1)
set /p RegenRepeats="> "

: if user did not enter a value, set to default value of 1
if "%RegenRepeats%"=="" (
    set /a RegenRepeats = 1
)

echo.
echo Reset a view (camera orientation) between frames?
echo Note that regeneration will disrupt display of perspective views.  If you
echo would like to restore a saved view orienation before saving each frame,
echo enter its name here, otherwise hit enter to continue.
echo    Note that spaces are allowed in view names.  You must enter view name
echo    in ALL CAPS here.  (Even though it is displayed in Title Case within
echo    Creo Parametric.)
set /p ViewToRestore="VIEW NAME (ALL CAPS) > "

echo.
echo How many frames would you like to capture for the entire animation?
echo Enter a number between 1 - 9999 (or leave blank to accept default value of 24)
set /p NumberOfFrames="> "
: if user did not enter a value, set to default value of 24
if "%NumberOfFrames%"=="" (
    set /a NumberOfFrames = 24
)

cls
echo Welcome to the Image Sequence Animation Mapkey Generator for Creo Parametric
echo by Darren Cokin
echo.
echo.
echo What is the height in pixels of the images you would like created?
echo Enter a number (or leave blank to accept default value of 720 pixels)
set /p Height="> "
: if user did not enter a value, set to default value of 720
if "%Height%"=="" (
    set /a Height = 720
)
: convert Height from pixels to inches (at 100 pixels per inch)
set /a HeightInInchesInteger=%Height:~0,-2%
set /a HeightInInchesFractional=%Height:~-2%
set HeightInInches=%HeightInInchesInteger%.%HeightInInchesFractional%

echo.
echo What is the width in pixels of the images you would like created?
echo Enter a number (or leave blank to accept default value of 1280 pixels)
set /p Width="> "
: if user did not enter a value, set to default value of 1280
if "%Width%"=="" (
    set /a Width = 1280
)
: convert Height from pixels to inches (at 100 pixels per inch)
set /a WidthInInchesInteger=%Width:~0,-2%
set /a WidthInInchesFractional=%Width:~-2%
set WidthInInches=%WidthInInchesInteger%.%WidthInInchesFractional%

echo.
echo What prefix would you like to use for the image filenames?
echo Enter a text string (or leave blank to accept default value of "CreoAnim_")
set /p FilenamePrefix="> "
: if user did not enter a value, set to default value of CreoAnim_
if "%FilenamePrefix%"=="" (
    set FilenamePrefix=CreoAnim_
)

echo.
echo Creo 2.0 is not able to save *.png format image files.  Enter "tif" here
echo to save *.tif format image files instead, or leave blank for *.png.
set /p FilenameExtension="> "
: if user did not enter a value, set to default value of png
if "%FilenameExtension%"=="" (
    set FilenameExtension=png
)

: set variable for type_option to be used in image saving mapkey.
:  should be "db_563" for *.tif, or "db_564" for *.png
if "%FilenameExtension%"=="tif" (
    set Filetype=db_563
) else (
    set Filetype=db_564
)

cls
echo Welcome to the Image Sequence Animation Mapkey Generator for Creo Parametric
echo by Darren Cokin
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Generating code.
echo Mapkey that triggered this batch script will continue upon completion.

: Create variable with regeneration mapkey to use first
set /a RegenRepeatsMinusOne=%RegenRepeats%-1
set RegenMapkeyToUseFirst=%%g%RegenRepeatsMinusOne%

: Create variable with regeneration mapkey to use every time after first
set RegenMapkeyToUse=%%g%RegenRepeats%

: Create variable that is either blank or has the "%restoreview;" mapkey, depending on if
: user specified a view to restore
if "%ViewToRestore%"=="" (
    set ViewRestoreOption=
) else (
    set ViewRestoreOption=%%restoreview;
)

 CODE CONTINUES IN NEXT COMMENT

dcokin
14-Alexandrite
(To:dcokin)

animation_sequence_mapkey_generator.bat continued:  (PART 2 of 2)

: Begin writing *.pro file, filling in standardized mapkeys that do not need to be customized
echo ! This file was autocoded by "animation_sequence_mapkey_generator.bat", a>animation_sequence_mapkey.pro
echo ! utility developed by Darren Cokin.  It includes a number of subroutines>>animation_sequence_mapkey.pro
echo ! for saving an animated image squence from Creo Parametric, customized>>animation_sequence_mapkey.pro
echo ! for a given number of image frames, the resolution of those images,>>animation_sequence_mapkey.pro
echo ! filename prefix for those images, and whether or not to refresh a saved>>animation_sequence_mapkey.pro
echo ! view (camera orientation) in between saving the images (needed for>>animation_sequence_mapkey.pro
echo ! perspective views only).>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro
echo ! These subroutines regenerate the model a given number of times, and>>animation_sequence_mapkey.pro
echo ! then activates Temporarily Shade.  This will remove the text overlaid on>>animation_sequence_mapkey.pro
echo ! lower left of the screen indicating simp rep and xsec status, and on the>>animation_sequence_mapkey.pro
echo ! lower right with tolerance settings (if tol_display config setting is on).>>animation_sequence_mapkey.pro
echo ! If you are trying to make a wireframe mode animation, these shade commands>>animation_sequence_mapkey.pro
echo ! will interfere.>>animation_sequence_mapkey.pro
echo mapkey g0 @MAPKEY_LABELshade;~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g1 @MAPKEY_LABELregenerate and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g2 @MAPKEY_LABELregenerate twice and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto`;\~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g3 @MAPKEY_LABELregenerate 3 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g4 @MAPKEY_LABELregenerate 4 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto`;~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g5 @MAPKEY_LABELregenerate 5 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g6 @MAPKEY_LABELregenerate 6 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto`;~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g7 @MAPKEY_LABELregenerate 7 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g8 @MAPKEY_LABELregenerate 8 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto`;~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo mapkey g9 @MAPKEY_LABELregenerate 9 times and shade;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdRegenAuto` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdViewShade`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro


echo ! This subroute flips the values of ANIMATE_WITH_EVERY_REGEN to YES.>>animation_sequence_mapkey.pro
echo ! Model should include a relation that increments some value if this is>>animation_sequence_mapkey.pro
echo ! equal to yes.  Example:>>animation_sequence_mapkey.pro
echo !    if ANIMATE_WITH_EVERY_REGEN == yes>>animation_sequence_mapkey.pro
echo !        value = value + ^1>>animation_sequence_mapkey.pro
echo !    endif>>animation_sequence_mapkey.pro
echo mapkey activateregenmode @MAPKEY_LABELflips parameter to YES;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdMmParams` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Arm `relation_dlg` `ParamsPHLay.ParTable` 2 `rowANIMATE_WITH_EVERY_REGEN` \>>animation_sequence_mapkey.pro
echo mapkey(continued) `value`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Disarm `relation_dlg` `ParamsPHLay.ParTable` 2 \>>animation_sequence_mapkey.pro
echo mapkey(continued) `rowANIMATE_WITH_EVERY_REGEN` `value`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable` 2 \>>animation_sequence_mapkey.pro
echo mapkey(continued) `rowANIMATE_WITH_EVERY_REGEN` `value`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Open `relation_dlg` `ParamsPHLay.ParTable_INPUT`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Close `relation_dlg` `ParamsPHLay.ParTable_INPUT`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable_INPUT` 1 `YES`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Activate `relation_dlg` `PB_OK`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo ! This subroute flips the values of ANIMATE_WITH_EVERY_REGEN to NO.>>animation_sequence_mapkey.pro
echo mapkey deactivateregenmode @MAPKEY_LABELflips parameter to NO;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProCmdMmParams` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Arm `relation_dlg` `ParamsPHLay.ParTable` 2 `rowANIMATE_WITH_EVERY_REGEN` \>>animation_sequence_mapkey.pro
echo mapkey(continued) `value`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Disarm `relation_dlg` `ParamsPHLay.ParTable` 2 \>>animation_sequence_mapkey.pro
echo mapkey(continued) `rowANIMATE_WITH_EVERY_REGEN` `value`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable` 2 \>>animation_sequence_mapkey.pro
echo mapkey(continued) `rowANIMATE_WITH_EVERY_REGEN` `value`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Open `relation_dlg` `ParamsPHLay.ParTable_INPUT`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Close `relation_dlg` `ParamsPHLay.ParTable_INPUT`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable_INPUT` 1 `NO`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Activate `relation_dlg` `PB_OK`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

echo ! This subroutine imports the newly created animation_sequence_mapkey.pro file>>animation_sequence_mapkey.pro
echo ! into the current Creo Parmametric session.>>animation_sequence_mapkey.pro
echo mapkey importmapkey @MAPKEY_LABELimports *.pro file with mapkey to save entire animation;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `PREVIEW_POPUP_TIMER` \>>animation_sequence_mapkey.pro
echo mapkey(continued) `main_dlg_w1:PHTLeft.AssyTree:^<NULL^>`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Activate `file_open` `Current Dir`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 \>>animation_sequence_mapkey.pro
echo mapkey(continued) `animation_sequence_mapkey.pro`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `PREVIEW_POPUP_TIMER` \>>animation_sequence_mapkey.pro
echo mapkey(continued) `file_open:Ph_list.Filelist:^<NULL^>`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ FocusIn `UITools Msg Dialog Future` `no`;\>>animation_sequence_mapkey.pro
echo mapkey(continued) ~ Activate `UITools Msg Dialog Future` `no`;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro

: Continue writing *.pro file with customized mapkeys.
:
: only create the view restore mapkey if the user specified a view to restore
if not "%ViewToRestore%"=="" (
echo ! This subroutine restores the state of a particular view ^(camera orientation^)>>animation_sequence_mapkey.pro
echo ! It is needed because the display of perspective views is disrupted by>>animation_sequence_mapkey.pro
echo ! regeneration.  This mapkey was generated automatically by>>animation_sequence_mapkey.pro
echo ! animation_sequence_mapkey_generator.bat with a specified view name.>>animation_sequence_mapkey.pro
echo !   NOTE that spaces are allowed in view names.>>animation_sequence_mapkey.pro
echo !   NOTE that view names here must be entered ALL CAPS.>>animation_sequence_mapkey.pro
echo !        ^(even though they are displayed in Title Case within Creo Parametric^)>>animation_sequence_mapkey.pro
echo mapkey restoreview @MAPKEY_LABELRestores specified view^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Command `ProCmdNamedViewsGalSelect`  `%ViewToRestore%`^;>>animation_sequence_mapkey.pro
echo.>>animation_sequence_mapkey.pro
)

: Write the first part of the main animation sequence mapkey

echo ! This mapkey runs the animation.  It regenerates the model a particular>>animation_sequence_mapkey.pro
echo ! number of times, saves an image file with a particular name, and then repeats>>animation_sequence_mapkey.pro
echo ! the process.  It was generated automatically by>>animation_sequence_mapkey.pro
echo ! animation_sequence_mapkey_generator.bat.>>animation_sequence_mapkey.pro
echo mapkey cycleanim @MAPKEY_LABELRegenates and saves images;\>>animation_sequence_mapkey.pro
echo mapkey(continued) %%activateregenmode;%RegenMapkeyToUseFirst%;%ViewRestoreOption%\>>animation_sequence_mapkey.pro

: The next section of the mapkey will be repeated for the desired number of frames, with a unique
: filename for the saved image each time.

: start the loop
Setlocal enabledelayedexpansion
for /l %%a in (1,1,%NumberOfFrames%) do (

: determine the next filename, including adding leading zeros to frame count
set counter=%%a
set counter=000!counter!
set counter=!counter:~-4!
set NextFilename=%FilenamePrefix%!counter!.%FilenameExtension%

: continue writing the mapkey
: this section saves an image with particular settings.  Edit the below to change image resolution, etc.
:   the type_option in the 3rd line can be db_563 for tif, or db_564 for png
echo mapkey^(continued^) ~ Command `ProCmdModelSaveAs`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Activate `file_saveas` `Current Dir`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Select `file_saveas` `type_option` 1 `%Filetype%`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Update `file_saveas` `Inputname` `!NextFilename!`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Activate `file_saveas` `OK`;~ Open `shd_img_param` `o_size`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Close `shd_img_param` `o_size`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Select `shd_img_param` `o_size` 1 `Variable`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Update `shd_img_param` `i_height` `%HeightInInches%`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Update `shd_img_param` `i_width` `%WidthInInches%`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Update `shd_img_param` `i_tmargin` `0`;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Update `shd_img_param` `i_lmargin` `0`; ~ Open `shd_img_param` `o_depth`;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Close `shd_img_param` `o_depth`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Select `shd_img_param` `o_depth` 1 `depth24`^;\>>animation_sequence_mapkey.pro
echo mapkey^(continued^) ~ Activate `shd_img_param` `OK`^;\>>animation_sequence_mapkey.pro

: This section prepares for the next frame, ending the loop.  Skip for last cycle, as no
: next frame to prepare for
if not %%a==%NumberOfFrames% (
echo mapkey^(continued^) !RegenMapkeyToUse!^;!ViewRestoreOption!\>>animation_sequence_mapkey.pro
)
)
EndLocal

: Write the end of the main animation sequence mapkey.
echo mapkey(continued) %%deactivateregenmode;%RegenMapkeyToUseFirst%;>>animation_sequence_mapkey.pro
dcokin
14-Alexandrite
(To:dcokin)

2020 update:  works fine with Creo 7.0.0.0 without any changes

This is awesome and exactly what I need!  However, I'm having trouble getting it to work.  Using Creo 7.0.2.0.  The batch runs ok and produces the images but it seems like regeneration isn't actually changing the model geometry.  All the images are identical.  I've tried up to 9 regens and the results are all the same.  When I manually change the desired parameter, the geometry changes (after 2 regens).  Any thoughts?

dcokin
14-Alexandrite
(To:RT_8859244)

Glad to hear someone has found this useful!

 

> it seems like regeneration isn't actually changing the model geometry.
> Any thoughts?

 

Sounds like the relations aren't properly linked to automatically change the desired parameter. Make sure you followed all the instructions at the top of "animation_relations_sample.txt", regarding creating all the needed parameters, and replacing the boilerplate ones throughout the sample relations with ones of your own choosing. (Make sure you change these consistently everywhere they show up throughout the relations.)

 

Before running the export routine, you can test the relations are working by manually setting "animate_with_every_regen" to "yes", and mashing Ctrl-G to regen a bunch of times, to confirm things are moving as expected.

 

> When I manually change the desired parameter, the geometry changes (after 2 regens).

 

By the way, if the geometry typically updates fully after 2 regens, you should set the routine to use 3 regens, so the prompts get a chance to catch up to the geometry.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags