×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Pro/Program: swapping components in an assembly

Pro/Program: swapping components in an assembly

Pro/Program: swapping components in an assembly

(OP)
Hi,

I was wondering what is the best way to replace components by Family Table members in an assembly via Pro/Program. What I've been doing is the following: I assemble all Family Members first. Then I add "IF" statements to each component in the program (if input is such-and-such, add this part); this way non-required components are suppressed at the execution. It works, but is there a better way to do it (not to bring all the components to the assembly)?

Thanks,

Oxana

RE: Pro/Program: swapping components in an assembly

Hi Oxana,

Yes, there is a better way to do that:

Let's say you have a family table with 2 instances: instance1, instance2.

In your assembly, install only the first one.

Create an integer pivot parameter, let's call it "param_a" and set the value 1 for it.

In relations create the decisions staements. Here is an example:

if param_a == 1
   comp = "instance1.prt"
else
   comp = "instance2.prt"
endif


Now, in Pro/Program identify the statements where you want to interchange your instances. You should find something similar with this:

ADD PART INSTANCE1
INTERNAL COMPONENT ID 24
PARENTS = 22(#6)
END ADD

and modify them in the following way:

ADD COMPONENT (COMP)
INTERNAL COMPONENT ID 24
PARENTS = 22(#6)
END ADD

Now, If you change the value of your "param_a" from 1 to 2, the program will automaticaly exchange the instances in your assembly.

You must be careful if you rename your instances, because the rename procedure will not rename the names of the instances in your relations! You must update manualy the names stored in relations. This is the only negative point for this method.

Good luck

-Hora.

RE: Pro/Program: swapping components in an assembly

(OP)
Hi Hora,

Thank you for the reply. I have more questions though. Can I drive the interchange by a string parameter, not an integer? I tried to find an answer to this question myself, but probably did something wrong, since I kept getting an error message: cannot find model by name COMP. (I used your method as well with an integer parameter, but got the same error message).

And if I have n instances, should I have n IF statements in the relations (no ELSE)?

Thank you,

Oxana

RE: Pro/Program: swapping components in an assembly

Hello,

Yes, sure you can drive your interchange assembly by a string parameter. The string must be writen between quotes. I just wrote an example there.

About the error: You must put the name of the instance between quotes and specify the extension prt. (i.e. "instance1.prt"). Also you can specify the name of the part as: "instance<generic>.prt". Do not use capitals. Go with lowercase characters only. Pro/E is case sensitive when you don't expect.

In Pro/PROGRAM, change the sentence ADD PART ..... with ADD COMPONENT (COMP). You must use brackets when you specify the component variable:

ADD COMPONENT (COMP)
.....

Unfortunately, if you have n instances, you must use a syntax like this (now param_a is a string variable):

if "param_a" == "test1"  <- put your text
   comp = "instance1<generic>.prt"
endif

if "param_a" == "test2"
   comp = "instance2<generic>.prt"
endif

if "param_a" == "test3"
   comp = "instance3<generic>.prt"
endif

and so on.

Keep me in touch with this.

-Hora.

RE: Pro/Program: swapping components in an assembly

(OP)
Thank you so-o much. It worked perfectly. The only thing I did wrong last time was - missing the .prt extension. Should know better by now that you have to be really careful when writing a program.

Thank you again,

Oxana

RE: Pro/Program: swapping components in an assembly



-Hora

RE: Pro/Program: swapping components in an assembly

(OP)
Hora,

Additional question to our discussion. I need to expand swapping components to suppressing them when 2 of my input parameters are "blank". In other words, I have a "param_a" and "param_b" that can take certain values. I add a component (subassembly) to my model depending on the value of one of the above mentioned parameters. Even if one of them is "blank", but the other one is not, I will be adding a certain instance of that subassembly. But when both "param_a" and "param_b" =="blank", I don't want that component to be added to my assembly at all (be suppressed). One way I could do it - to create a "blank" instance", but in that case I would have to give it a dummy part number according to our standards; I would prefer not to do it, if there is a better way. Is there a better way?

Thanks,

Oxana

RE: Pro/Program: swapping components in an assembly

If you need to suppress a component in an assembly, then do the following using your params; (below is a sample of an assembly Pro/PROGRAM with 3 parts)-

ADD PART 1100PE0014
 INTERNAL COMPONENT ID 31
 END ADD

 ADD PART 1100CP0123
 INTERNAL COMPONENT ID 32
 PARENTS = 31(#5)
 END ADD

IF PARAM_B=="YES"
 ADD PART MFI-0607-06
 INTERNAL COMPONENT ID 42
 PARENTS = 32(#6)
 END ADD
ENDIF

For the part # MFI-0607-06, whenever the parameter PARAM_B is set to YES, the part is added (or RESUME), for all other values, the part is suppressed. The IF and ENDIF (no spaces!!) must enclose the part or series of consecutive parts that will be RESUME or SUPPRESSED.

Hope this helps.


Steve

http://www.3dlogix.com

RE: Pro/Program: swapping components in an assembly

Hi Oxana,

This time, Steve was faster than me giving you the right answer. Yes, you must enclose the ADD COMPONENT (COMP) betwee, IF and ENDIF.

Now, in your case, because of the two parameters, you must add this sequence:

IF (PARAM_A != "") | (PARAM_B != "")
ADD COMPONENT (COMP)
...
...
ENDIF

The "|" (vertical line take it from SHIFT + "\") means "or". Pro/Program will evaluate the expression "IF ..... " and if one of the two parameters is NOT NULL then Pro/Program will add the instance. If BOTH parameters are NULL then no instance will be added (Pro/Program will supress the component).
Attention at double quotes! ("").

An alternative to that is to do this in relations by creating a new parameter "PARAM_C". Go in relations and add this sequence:

PARAM_A = "CASE_1"
PARAM_B = ""

/******** start of COMP declarations *******

IF PARAM_A == "CASE_1"
   COMP = "instance1.prt"
ENDIF

IF PARAM_A == "CASE_2"
   COMP = "instance2.prt"
ENDIF

.... and so on

/******* end of COMP declarations ******

IF (PARAM_A != "") | (PARAM_B != "")
   PARAM_C = "TRUE"
ELSE
   PARAM_C = "FALSE"
ENDIF

Then in Pro/PROGRAM add this:

IF PARAM_C == "TRUE"
ADD COMPONENT (COMP)
...
...
ENDIF

After regenerating, because the PARAM_A is not NULL, PARAM_C will hold the value "TRUE", and Pro/Program will add the component.

If your relations are very complex, the I suggest you to control them in a "LAYOUT", outside of your assembly. In this way you can see the variable values on screen and you can change them independent of your assembly.

Good luck!

-Hora

RE: Pro/Program: swapping components in an assembly

(OP)
Thank you very much. It's exactly what I needed. I did not realize that Pro/Program has similar syntaxes/capabilities to other programming languages.

Oxana

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources