Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
I am attempting to render the animation of a flexible component in Creo parametric. Specifically I am trying to show a timing belt in motion but I think this would be useful for springs and other components where the material deforms.
I have tried several different approaches and read several discussions on the topic without success. I am able to make the geometry of the part change with the assembly by referencing the assembly in the components feature definition or making the component flexible however the assembly must be regenerated for the geometry to update. My understanding is that Mechanism and Animate applications in Creo can not regenerate after each step in the motion.
To make the model animate and regenerate I have added a line to the relations that will increment the motion of my model. Basically I added something like "dimension = dimension + step" so that each time the model is regenerated it will move the position of the component one step.
This works well but I need a way to capture a picture of the model after each step and automatically generate the next step. I was thinking I could use a mapkey, something like "regenerate the model --> render --> save as a picture (with incremental name)" and then repeat a given number of times. Searching the forums the only solution I have found to making incremental names and repeating the command is to make one giant mapkey that includes all of the steps repeated with different file names in each step. A bit of a workaround but if I write a small program to generate this mapkey it wouldn't be much work to repeat this process in the future.
If you don't want to read this whole post start reading here.
The challenge I am having is that I can not get a mapkey to perform all the functions I need together (regenerate the model --> render --> save as a picture).
I can create a mapkey that "regenerates and then renders the model" and I can create one that "saves the model as a picture". However when I try to create a single mapkey to perform the whole function it fails to save. I have tried recording this as a single mapkey as well as combining the two components manually but neither solution worked. My only thought is that when I try to do this in a single mapkey Creo is not waiting for the render to complete before attempting to save. Any ideas on how to solve this problem?
This is the mapkey I recorded to perform the "regenerate the model --> render --> save as a picture" sequence, but it is not saving a picture when I run it.
*ignore the smiles
mapkey $F12 ~ Command `ProCmdRegenAuto` ;~ Command `ProCmdViewRenderWindow`
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdModelSaveAs`
mapkey(continued) ~ Activate `file_saveas` `pb_favorites__FAV_8_`;\
mapkey(continued) ~ Select `file_saveas` `ph_list.Filelist` 1 `My_Project`;\
mapkey(continued) ~ Activate `file_saveas` `ph_list.Filelist` 1 `My_Project`;\
mapkey(continued) ~ Select `file_saveas` `ph_list.Filelist` 1 `rendered frames`;\
mapkey(continued) ~ Activate `file_saveas` `ph_list.Filelist` 1 `rendered frames`;\
mapkey(continued) ~ Update `file_saveas` `Inputname` `frame0001`;\
mapkey(continued) ~ Open `file_saveas` `type_option`;~ Close `file_saveas` `type_option`;\
mapkey(continued) ~ Select `file_saveas` `type_option` 1 `db_583`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;
When the mapkey runs, does it just skip the render? I would think it is not prepared to over-write the existing picture.
****
I've done this sort of thing before, though creating .txa files (training trail files) rather than mapkeys using VBA.
Presently I'd go for an AutoIT program to drive the software, which would allow for some control in the event of regen failure by tweaking the accuracy (which caused no end of trouble on the item I was animating before.)
One could also have a self-loading mapkey; part of the process would run a command shell that generated a mapkey file with an incremented filename and then the mapkey would load and run the new version of itself, if not directly (don't recall if mapkeys can be self-referential) then by a mapkey intermediate.
When I run the mapkey it regenerates and renders but does not save. I have tried deleting the previous picture that was saved to the folder but it still does not save anything when I run the mapkey.
Thanks for the suggestions. I have done very little with trail files is there any benifit to trying somthing there instead of using mapkeys? I might look into AutoIT if I cant get something inside Creo to work.
I think I have confirmed that creo is not waiting until the rendering is complete to exicute the next step in the mapkey. I added a pause to the mapkey after the rendering and before the save. However when I run the mapkey it prompts for user input before the rendering is complete. Any ideas on how to prevent creo from executing the next step in the mapkey before the rendering is complete?
Also would the be any difference if I tried doing this with a trail file instead of a mapkey? (my experience with both is minimal)
If mapkey execution is not waiting for the render to complete, I'm not sure it would be any different for a trail* file. If so, time to drag AutoIT onto the playing field.
Trail files are very similar to mapkey files, so if you are understanding mapkeys, trail files will also be understandable.
The main difference is that mapkeys are limited in length** (I forget how many characters) but can call other mapkeys. I think trail files cannot include mapkey calls - when a mapkey is used, only the mapkey expansion is recorded in the trail file. I have used mapkeys in the creation of baseline trail files to avoid typos and mis-picks and the like, but never noticed any way to embed them.
*Changing the trail file suffix to txa causes the software to assume it is a training file and it won't exit if there is an error in running it.
**Perhaps this is to prevent cross pollination. The educational versions didn't allow recording or playback of trail files, presumably to prevent re-creating educational models from the commercial version's trail files. If mapkeys were unlimited in length the method could be used to circumvent commercial/educational license restrictions.
David, thank you for your help. I have started playing arround with AutoIT so I can learn how to use it.
I ran across CreoToolkit I dont know much about it but from what I understand it allows you to control creo from common programming languages such as c++. Would it be possible to use creotoolkit to make a program/function that would command creo to "regenerate the model --> render --> delay --> save as a picture (incrimenting file name each time in a loop)"?
Toolkit is at the far end for software development from Mapkeys and AutoIT. It is designed for people to create extensions to models and model creation/analysis, such as more sophisticated data extraction. I found AutoIT to be more than sufficient and recommend going along that path before delving into the PTC API.
There is a section on the Pro User group dedicated to automation that has some Toolkit developers, but either they are pretty self-sufficient or there aren't many of them, as they don't post very much. That includes the J-Link and Web-link guys.
The reason for leaning on AutoIT is that it allows pretty easy control of the entire computer, so it you could have a program creating the animation send and e-mail when it's done; not as easy from Toolkit. And AutoIT has a heck of an interesting user base; people doing all sorts of things, so examples and help are abundant.