Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Pro/Program: swapping components in an assembly 1

Status
Not open for further replies.

oxana

Mechanical
Jan 16, 2002
23
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
 
Replies continue below

Recommended for you

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.
 
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
 
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. &quot;instance1.prt&quot;). Also you can specify the name of the part as: &quot;instance<generic>.prt&quot;. 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 &quot;param_a&quot; == &quot;test1&quot; <- put your text
comp = &quot;instance1<generic>.prt&quot;
endif

if &quot;param_a&quot; == &quot;test2&quot;
comp = &quot;instance2<generic>.prt&quot;
endif

if &quot;param_a&quot; == &quot;test3&quot;
comp = &quot;instance3<generic>.prt&quot;
endif

and so on.

Keep me in touch with this.

-Hora.
 
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

 
Hora,

Additional question to our discussion. I need to expand swapping components to suppressing them when 2 of my input parameters are &quot;blank&quot;. In other words, I have a &quot;param_a&quot; and &quot;param_b&quot; 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 &quot;blank&quot;, but the other one is not, I will be adding a certain instance of that subassembly. But when both &quot;param_a&quot; and &quot;param_b&quot; ==&quot;blank&quot;, 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 &quot;blank&quot; instance&quot;, 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
 
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==&quot;YES&quot;
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
 
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 != &quot;&quot;) | (PARAM_B != &quot;&quot;)
ADD COMPONENT (COMP)
...
...
ENDIF

The &quot;|&quot; (vertical line take it from SHIFT + &quot;\&quot;) means &quot;or&quot;. Pro/Program will evaluate the expression &quot;IF ..... &quot; 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! (&quot;&quot;).

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

PARAM_A = &quot;CASE_1&quot;
PARAM_B = &quot;&quot;

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

IF PARAM_A == &quot;CASE_1&quot;
COMP = &quot;instance1.prt&quot;
ENDIF

IF PARAM_A == &quot;CASE_2&quot;
COMP = &quot;instance2.prt&quot;
ENDIF

.... and so on

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

IF (PARAM_A != &quot;&quot;) | (PARAM_B != &quot;&quot;)
PARAM_C = &quot;TRUE&quot;
ELSE
PARAM_C = &quot;FALSE&quot;
ENDIF

Then in Pro/PROGRAM add this:

IF PARAM_C == &quot;TRUE&quot;
ADD COMPONENT (COMP)
...
...
ENDIF

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

If your relations are very complex, the I suggest you to control them in a &quot;LAYOUT&quot;, 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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor