Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming Relations 5

Status
Not open for further replies.

treddie

Computer
Dec 17, 2005
417
Howdie,
Does anyone know if it is possible to have programming loops inside of a relation?
Also, is there a good, handy programming reference out there for relations outside of the ProE Online Help system?

Thanks.
treddie
 
Replies continue below

Recommended for you

Please see the following FAQ:

Mathematical Operators used in Pro/E Relations (faq554-970)
Using relation editor backdoor to parameters (faq554-1132)


Best regards,

Matthew Ian Loew


Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
There is no way to create loops in ProE, but you can "simulate" this using REGEN command. Of course, if you need to count 100 regens, then is better to forget.

Create a variable "i" or whatever, then in relations add something like this:

i = i+1

if i>= 10
i=0
endif

Then every time you make a regen i will increase with 1, until it reaches 10 and then is reseted.

Im this way I made a roller following a cam between two precise angles (between 20 and 90 degerees) with an increment of 5 degrees.

I start with an agular dimension which controls the a plane orientation and I create a "FLAG" parameter which can have two values: 0 and 1 and I added these relations:


IF D346:10 <= 20
D346:10 = 20
FLAG=0
ENDIF

IF D346:10 >= 90
D346:10 = 90
FLAG=1
ENDIF

IF FLAG == 1
D346:10 = D346:10 - 5
ELSE
D346:10 = D346:10 + 5
ENDIF

Create a mapkey for regen , like "R" key, and every time you touch R key, the system will update.

If this is what you want do with your loop, then give it a try.

-Hora

 
Many thanks to all of you for your responses. You have rescued me from a conundrum.
I went to great lengths to develop a particular relation (months, in fact), tested it in Visual Basic to ensure its functionality, and then ran into this last stumbling block when trying to implement it as a PRoE relation (which is the TRUE litmus test). There was no analytical solution to the problem so a loop is mandatory. Regen will give me that ability even though the amount of iterations will slow things down a bit. But that is much better than going the "manual" route.

Thanks again.
treddie
 
About an Interactive C Program
You can create your own interactive program to drive model geometry through relations. Consider the following information on creating user programs:

The User Prog command is available only in Part and Sketcher modes.

Only one user program may be edited or run at a time. However, you can write multiple programs for each part and then run them sequentially.

Each program is limited to a single entry subroutine, called "USRMAIN ()." The entry subroutine can call other subroutines in that program file.

Pro/ENGINEER provides a C file template usermain.c to help you write and use user programs.

You must capitalize Pro/ENGINEER dimensions in user programs.

Use D to refer to a dimension on the screen. This symbol corresponds to di in Part or Assembly mode or to sdi in Sketcher mode. The system does not accept a user-assigned symbol name, such as width, instead of the system-assigned dimension symbol.

Do not use exit statements in any of your routines. To build error handling into your program, use printf or fprintf statements.

You cannot drive assembly dimensions or pattern instance numbers using user programs.

To use an interactive program, you must complete the following steps:

Create a program. Alternatively, you can create a program by editing an existing program.

Compile and link the program.

Run the program to implement the changes.

When the program is finished running, regenerate the model to update geometry.

 
But since the program is a C program, cannot conventional loop and branching techniques, common to C, be used? I have an iterative loop that must be solved FIRST, to provide the arguments for equations that THEN drive the geometry.
 
Don't forget about the SOLVE function for solving some linear, and even non-linear, equations. While not a loop, this function can solve some problems that are traditionally solved with looping.

Best regards,

Matthew Ian Loew


Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
True. I hadn't thought of using it (I noticed it in the faq you listed, earlier). I'm so used to thinking of FOR NEXT, DO UNTIL, WHILE WEND, and company that it didn't click, and I passed over it. Certainly makes life easier by staying out of C, and staying within the relation.

treddie
 
One more thing, with Behavioral Modeling Extension (BMX) you can get the effect of looping thorugh the use of optimization features. The optimization feature allows for a non-linear excecution of the model tree.



Best regards,

Matthew Ian Loew


Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
Thank you all, for your much appreciated help. The ProE "onion" has had a couple more layers removed, revealing more of its depth. Maybe one day when I'm old and grey, I will have peeled back ALL the layers and reached ProE Nirvana!
treddie
 
dgallup -

Do you have the linked C programming functionality working on your machine? I tried it a while ago with no success. I'd be interested in finding out what compiler you use and and what steps you had to take to get it to compile the code. Being able to program in C would solve a few problems I've had in the past (mind you, anyone who has programmed C knows that I'm just inviting a host of OTHER problems)
 
I wish I could help you there, but I've never tried it. And, my experience with C is very slight. This may seem a bit off topic, but please bear with me. Around 1987 I started learning C. This was at the time that versions of BASIC began shipping with their OWN optimizing compilers. So I would go through the C book and say to myself, chapter after chapter, "Heck, I can do this in BASIC with out all the clumsy syntax, debug it quicker, compile it and get the same speed advantage (or close to it)...why learn C?" Now, BASIC has become a structured language with most of the conveniences of C. In my opinion (I could be totally off here), C is a dinosaur that doesn't know its dead yet. If I REALLY want speed, why not go from something like Visual BASIC, sidestep C, and go straight to Assembly? True, the difficulties in Assembly are monumental compared to C, but C as a speed advantage over BASIC just doesn't seem to hold weight anymore. Years ago, I worked for a company where one of the programmers there suggested building their product's software in Visual Basic, first, debug that with the quickness it affords, THEN port it over to C, to save the majority of debugging time spent that would have been spent in C. The port-over would entail its OWN degugging, but the idea was that if the end result MUST be in C, cut the development time down by working out a lot of the structural and logical problems in Visual Basic, so that I better understanding of the workings of the program are understood BEFORE going to C. They rejected his solution.
Was he right, or was he wrong? I don't know. The problem I find is that so much of the professional programming world is built around C, and at SOME point, I'll probably just have to dig in and do it. I use ProE a lot, and as I get into more and more of these elaborate problems, I may have no choice in the matter. But I still try to look for simple alternatives like ProE Program Tool, so that I can avoid C. But that tool is so limited (lack of branching and looping, for instance) that I can't use a lot of the standard practices I'm so familiar with. I hope that PTC will put a lot more functionality in the Program Tool and relations.
treddie
 
User Prog (C programming) is available only in sketch mode. So it is not useful here.

Only going to ProToolkit can solve the problem, but making a specific program to be linked with specific dimension is time consuming. Especially because ProToolkit is not at all "user friendly" with the majority of compilers.

-Hora
 
Thanks for that info, Hora.

You other option is to use an Excel Analysis. Link the dimensions to an Excel spreadsheet, and then write up the program in VB in the spreadsheet, or use Excel's tools for iterative solving.
 
Well actually, C WOULD work for me, because I'm driving the dimensions of a graph in Sketcher. But what a pain, especially from what I've been hearing.
The Excell/VB thing sounds like another cool alternative. Would be simple, too.
tr
 
Treddie,

Try the JKG solution (excel &VB) because is simple. If is not working, then you can try the C programming. For this one, you must have Visual C++ installed.

-Hora
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor