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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Use JLink to modify a Pro/Program file?

lylebeidler
1-Newbie

Use JLink to modify a Pro/Program file?

We have a bunch of models that all need to have their Pro/PROGRAMS modified.
This will all be pretty similar stuff, and it may be worth my while writing
a JLink program to automate modifying the Pro/PROGRAM (yes, I know it sounds
silly. It's a long story). Have any of you JLink masters done anything
like that? Do you have any tips or code you'd be willing to share? Bad
idea? Good idea? Impossible to do? Any feedback is welcome. Thanks!



--



Lyle Beidler
MGS Inc
178 Muddy Creek Church Rd
Denver PA 17517
717-336-7528
Fax 717-336-0514
<">mailto:-> -
<">http://www.mgsincorporated.com>
5 REPLIES 5

We have a program that we had written by JD Felkins that un-programs our
pro e models. Basically it runs through the files and removes all the
relations, parameters, pro-program, etc so they don't have our design
automation.



Once you export the pro-program file you can manipulate it using
standard java methods and then import it back in and save the pro e
file.


bfrandsen
6-Contributor
(To:lylebeidler)

Lyle,
you can export/import Pro/Program files through J-link. See
ProgramExportInstructions_Create and ProgramImportInstructions_Create in
the API Wizard. Once exported you can modify the files with java to your
liking and import them again.

Regards,
Bjarne



Lyle Beidler <->
15-09-2010 17:44
Please respond to
Lyle Beidler <->


To
-
cc

Subject
[proecus] - Use JLink to modify a Pro/Program file?






We have a bunch of models that all need to have their Pro/PROGRAMS
modified. This will all be pretty similar stuff, and it may be worth my
while writing a JLink program to automate modifying the Pro/PROGRAM (yes,
I know it sounds silly. It’s a long story). Have any of you JLink
masters done anything like that? Do you have any tips or code you’d be
willing to share? Bad idea? Good idea? Impossible to do? Any feedback
is welcome. Thanks!

--

Lyle Beidler
MGS Inc
178 Muddy Creek Church Rd
Denver PA 17517
717-336-7528
Fax 717-336-0514
-
FV
17-Peridot
17-Peridot
(To:lylebeidler)

Hi all,

Lyle,

The task could beacomplished byusing a trail file and some type of batch or script file. The trick is to exit out of pro/program text editor in order to return control back to pro/e which isrunning trail file sequence.

-change config.pro settings for Pro/Program editor to be a plain text editor ("notepad.exe" for example).

-output a pro/program file by usingTools->Program->Edit Design command sequences. This will spawn a text editor process.The pro/program file will have themodel name and '.pls' extension. It is aplain text file. Replace this file with the good one.

-kill running text editor process ( taskkill.exe on windows) thus returning control back to proe.

-Pro/E will continue the trail file sequence with 'Current values' option.

-use Regenerate->Current Values as the final check.

-exit pro/e and start pro/e for the next model.

HIH.

FV.
In Reply to Lyle Beidler:

We have a bunch of models that all need to have their Pro/PROGRAMS modified.
This will all be pretty similar stuff, and it may be worth my while writing
a JLink program to automate modifying the Pro/PROGRAM (yes, I know it sounds
silly. It's a long story). Have any of you JLink masters done anything
like that? Do you have any tips or code you'd be willing to share? Bad
idea? Good idea? Impossible to do? Any feedback is welcome. Thanks!



--



Lyle Beidler
MGS Inc
178 Muddy Creek Church Rd
Denver PA 17517
717-336-7528
Fax 717-336-0514
<mailto:-> -
<http://www.mgsincorporated.com> http://www.mgsincorporated.com




> The task could be acomplished by using a trail file and some type of
> batch or script file. The trick is to exit out of pro/program text
> editor in order to return control back to pro/e which is running trail
> file sequence.

Although Lyle asked about J-Link specifically, it's always good to
know about alternatives. For the most part, the two approaches are
the same: export/edit/import. The J-link approach could be faster if
the model was opened is session but not visible in any window. If it
had to be open in a window for some reason, the trail file approach
would probably be a little faster.

You can make the trail file approach somewhat more reliable by
resetting the text editor command to be a program/script that edits
the file. Pro/Engineer will look for the temp file when the program
is done processing and read it back into the model. No need to
worry about terminating processes.

I have had to do this in the past with other file types and it works
well. If a user is driving the session, the text editor command will
have to be reset back to the normal command after the program is
done, of course.

The Pro/Program file data needs to be handled carefully because the
content will most likely be unique for every file. One would need to
edit the existing data, making minor changes pretty much every time.



Marc
--
Marc Mettes
-
Visit My CAD/PDM AutomationBlog
Or, Subscribe to My CAD/PDM Automation Blog by Email





Hello

The best way to edit and change the Pro/Program file is to perform an JLink ProgramExportInstructions then change the exported file by reading the lines using the java.util package. After successfully changing the Pro/Program file, then you will perform a JLink ProgramImportInstructions. If you are wanting to change only the relations then you can use the model.GetRelations and model.SetReleations. If you want to set the post relations then you would need to export the program because there is not a post relations method. This is the best way to modify a Pro/Program file.

Announcements


Top Tags