Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Javascript style function in Pro/E

conrat

New member
I know this is out on a limb and I doubt this is possible, but I am tired of copying and pasting code so much.

We have an assembly where many of our sheet metal parts go over 96" long. We use a punch press to punch the holes in the sheet metal, but the maximum length of the part is 96", then we need to reposition the part.

This machine is rather old and we do manual repositions. This requires putting a note on our repeat region (which only shows the sheet metal parts to be punched) of what the reposition value is. We only do repositions in 10" increments, to keep it simple.

The size of the assembly constantly updates for different orders, so I can't just hard code the reposition value.

My problem is, I wrote code to look at the length of the part, then determine the best reposition for the part. The code is below. The problem with this is, I must copy and paste this into every part that might have a reposition, as the LENGTH parameter is constantly changing depending on the order.

Is there a way to write this code in an external file, then pass the current part length to this file and have it return the correct reposition length? This would be similar to how programming languages such as Javascript or VB handle these issues. You write the code once, then reference it anywhere (or in any part) that needs to be checked.

I assume this is possible with Java or VB, but I am not a programmer and only know a little Javascript.

Thanks in advance,
Jim

IF LENGTH>135<br style="color: rgb(0, 0, 255);"> REPOSITION=50<br style="color: rgb(0, 0, 255);">ELSE<br style="color: rgb(0, 0, 255);">IF LENGTH>125<br style="color: rgb(0, 0, 255);"> REPOSITION=40<br style="color: rgb(0, 0, 255);">ELSE<br style="color: rgb(0, 0, 255);">IF LENGTH>115<br style="color: rgb(0, 0, 255);"> REPOSITION=30<br style="color: rgb(0, 0, 255);">ELSE<br style="color: rgb(0, 0, 255);">IF LENGTH>105<br style="color: rgb(0, 0, 255);"> REPOSITION=20<br style="color: rgb(0, 0, 255);">ELSE<br style="color: rgb(0, 0, 255);">IF LENGTH>95<br style="color: rgb(0, 0, 255);"> REPOSITION=10<br style="color: rgb(0, 0, 255);">ELSE<br style="color: rgb(0, 0, 255);"> REPOSITION=0<br style="color: rgb(0, 0, 255);">ENDIF<br style="color: rgb(0, 0, 255);">ENDIF<br style="color: rgb(0, 0, 255);">ENDIF<br style="color: rgb(0, 0, 255);">ENDIF<br style="color: rgb(0, 0, 255);">ENDIF<br style="color: rgb(0, 0, 255);"><br style="color: rgb(0, 0, 255);">IF REPOSITION > 0<br style="color: rgb(0, 0, 255);">REMARKS2=ITOS(REPOSITION)+'" REPOSITION'<br style="color: rgb(0, 0, 255);">ELSE<br style="color: rgb(0, 0, 255);">REMARKS2=""<br style="color: rgb(0, 0, 255);">ENDIF

(note: The remarks2 parameter then gets added to a note that is displayed in the repeat region. If no value exists, the string is blank.)



Edited by: conrat
 
You can get pretty close to what you're looking for by using a Pro/Notebook
file (aka Layout) which has a .lay extension. This would allow you to
embed the logic in the layout, then create an association between the
model and the layout.


You would then be able to replace the all of the logic in the model with a
one line relation such as:
REPOSITION=REPOSITION_LAY



You would have to move an extensive amount of logic into the layout, but
it would spare you the copy-paste and updating nightmare.



Marc
 
Marc,

Thanks for the reply. This is something I may look into. I am driving the assembly with a text file so I am not sure I can input a text file into a layout.

The biggest problem I see is having to put all of the logic in one place, instead of feeding values to a function. I would need a separate parameter for each possible part, and in this assembly that can get large. Also, sometimes on part might grow to need repositioned, but another may not, depending on the input params.

I guess to truly get what I am looking for, I will need to learn some Java.

Thanks,
Jim
 
If the logic is too complex for relations, the next option would be
to use trail files, J-Link, or Pro/WebLink. These would require that
you move all of the logic outside of your models and into the J-Link
or Pro/WebLink code or the program that generates your trail file.


The consequence is that you would need this program in order to
change the model in the future, but that may not be a problem for
you.



Marc
 
Marc,

J/Link appears to be the best option. Since it just sets a simple parameter, I guess it wouldn't be too bad to make. I am no Java programmer, so hopefully this would be a good starting point.

Anyway, thanks for your time. I appreciate the feedback I did get. Like I said at the start, I was out on a limb.

Thanks again,
Jim
 
Hi,


I have seen this reqirement very lately. Jim same as your requirement. I was handeled a project. My project is for placing a machine on a support bed. the machine size will vary as per theapplication. Then bed size has to vary with there supporting parts and features. This is an and average 100 parts component. For completing this project we have utilized layout and pro/programming method only, instead of j-link. Because if we utilize j-link it will be again external file control.


It was done succesfully. Only preplanning is required for executing the programme.
 
Gondi,

Thanks for your reply. I may have 10 or 15 parts, all of which may or may not require repositioning OR each of those parts may require a reposition or varying lengths.

Can you give me an overview of how you accomplished your task?

Thanks if you can,
Jim
 

Sponsor

Back
Top