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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

gcontreras
1-Visitor

Script

Hello,

I want to make multiple analysis, from a robot in different positions. I want to be moving the robot and every 2 degrees I move it and make for every position a mode analysis, but since it is a long repetitive procedure i would like to run it has  it works with a servomotor. I would like to make a script that makes moves the position, then makes an analysis and then saves the results. i don´t have any idea if creo can makes scrips and how they work.

Someone has an idea?

Thank you very much,

Edna

ACCEPTED SOLUTION

Accepted Solutions
Chris3
21-Topaz I
(To:gcontreras)

I usually edit the mapkey directly, but you can also insert it from the Creo GUI.

Capture.PNG

Here is the syntax:

mapkey(continued) @SYSTEMZ:\\folder\\subfolder\\script.VBS;\

I usually write in VBS, but as Doug pointed out above you can include .bat files or other executibles. I have not reviewed Doug's code, but you could take that paste it into a text file, modify as needed, change to script.bat (or whatever you need) and then put it into the mapkey (like shown above) where needed (presumably the end).

You could then create another mapkey that just calls the first mapkey over and over as many times as you needed.

View solution in original post

10 REPLIES 10
Chris3
21-Topaz I
(To:gcontreras)

Creo has mapkeys which are a close equivalent of macros in Microsoft Office products. A mapkey key records your keyboard entries and function calls so you can repeat them over and over.

This may not be enough for what you need though because there is no way to have a mapkey save results uniquely. The best it could do is to save the results as one file name or report but then the next time you ran it, it would same the same file name or report name which would try and over-write the previous save. This would likely same you some time though even if you had to manually change the file name each time it ran.

Tricks with Mapkeys

Mapkeys

Tutorial: Creating Mapkeys  (requires login)

You could get around that limitation with some external scripting or one of Creo's APIs but those are complicated programming solutions that are likely outside of the scope of your task.

dgschaefer
21-Topaz II
(To:Chris3)

Perhaps the mapkey could call a batch file after the results are saved that looks at the directory contents and renames the file, appending a sequential number.

We use this snippet of code to set sequential file names for exported files:

:increment

rem ** Set incremental value of 'VER'

rem ** Since 'VER' is zero at start of file, first value will be 1.

:loop

set /a ver += 1

if exist u:\%destination_folder%\%FILENAME%%suffix%_%ver%.%type% goto loop

rem ** rename file with version

rename %FILENAME%.%type% %FILENAME%%suffix%_%ver%.%type%

rem ** Reset value of 'filename'

set filename=%filename%%suffix%_%ver%

:end

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn
Chris3
21-Topaz I
(To:dgschaefer)

Yeah, that's what I meant by external processing. I often do this sort of thing where I have a script written in some other language that is either called by a mapkey or that generates a mapkey so the mapkey can be pseudo dynamic.

I´ve done already the mapkeys and it worked, but as you said I can´t save the results.. could you show me a sample of the external processing and I investigate the Creo´s API. The thing is that every analysis I run takes about 10 minutes and until is finished I can save the results, and then again run the mapkey.  So I need to be sitting in the computer for hours to wait till the analysis end and again use mapkeys.

Thank you I appriciate it! That would be great, though, could you explain me a little where can I use this code and how could I join it with my mapkey procedure?

<Best regards,

Edna

Chris3
21-Topaz I
(To:gcontreras)

I usually edit the mapkey directly, but you can also insert it from the Creo GUI.

Capture.PNG

Here is the syntax:

mapkey(continued) @SYSTEMZ:\\folder\\subfolder\\script.VBS;\

I usually write in VBS, but as Doug pointed out above you can include .bat files or other executibles. I have not reviewed Doug's code, but you could take that paste it into a text file, modify as needed, change to script.bat (or whatever you need) and then put it into the mapkey (like shown above) where needed (presumably the end).

You could then create another mapkey that just calls the first mapkey over and over as many times as you needed.

Danke

Looks like you got the help you need.

I should mention, this snippet uses some variables that are defined earlier in the file.  I also cut out a couple of lines that just changed the directory the script was running in so as to not cause confusion.

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn

I must say I´m not familiar with the scripts from creo, or where to use them, but I will investigate and try to use your code. Thank you very much!

The code I posted isn't Creo specific, it's a batch file.  You can use the OS Script tab or directly edit the mapkey in the config file (both are described by Christopher above) to point to the script on disk.

Google batch files and you'll find lots of info on writing them.

Good luck!

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn
Announcements
Business Continuity with Creo: Learn more about it here.

Top Tags