Skip to main content
12-Amethyst
April 8, 2013
Solved

Windchill Customization(Giving constraint to an attribute)

  • April 8, 2013
  • 2 replies
  • 13223 views

Hi everybody !

I am very new to this forum & very beginner to windchill 10.1.

Is this possible to add constraint to an attribute through program.

(ex. SingleValuedConstraint, LegalValueList)

Best answer by KD_01

Using this code has one demerit

The OOTB processor can’t persist the value so you have to write a custom processor also.

2 replies

1-Visitor
April 8, 2013

For WC 9.1:

In my experience, manipulating the AttributeContainer of the IBAHolder and the related View objects is overly complex. That statement's probably debatable, but directly manipulating the Persistable constraints seems much easier.

Here's an example of creating a DiscreteSet constraint:

Object values[] = new Object[]{"Blue","Red","Green"};

DiscreteSet ds = new DiscreteSet(values);

WTTypeDefinition td = ....

AttributeDefinition ad = ....;

TypeSingleAttrConstraint constraint = new TypeSingleAttrConstraint();

constraint.setTypeDefinition(td);

constraint.setAttributeDefinition(AttributeDefinitionReference.newAttributeDefinitionReference((AbstractAttributeDefinition)ad));

constraint.setBindingRuleClassName(SingleAttributeConstraintBindingRule.class.getName());

constraint.setEnforcementRuleClassName(DiscreteSetConstraint.class.getName());

constraint.setEnforcementRuleData(ds);

constraint = save/insert(constraint);

You may want to clear/reset any applicable cache afterwards.

KD_0112-AmethystAuthor
12-Amethyst
April 9, 2013

Thanks Matthew.

I am in 10.1 and what I want to do is suppose there is one soft attribute of Document named "New". Now I need a dropdown box in the UI with some value like the attached picture and again that attribute will be a multi valued attribute.

So, how to do that?

I want to give the value programmatically cause those values will come from a txt file.Untitled.png

1-Visitor
December 19, 2014

Hi Kaushik,

Is there a way to fetch all the attributes for a given subtype?

Is there a way to pull the metadata of the fetched attribute?

For example, i have a subtype of "CustomerExperience" object and many attributes configured on this subtype.

I am trying to fetch all the MBA(Model Based Attributes) and IBA(Instances Based Attributes), and after that fetch all the constraints,default values, datatype etc.. i.e metadata of the attribute

Thanks

RK

17-Peridot
January 5, 2015

Hi, in 10.2 you have this OOTB, called "External Enumerated Value List". There you can pull the values from a text file or even from a DB like ERP.

wcbru_10_2_M020.png
Happy New Year!
Björn
1-Visitor
May 19, 2015

Hi Kaushik,

I have one doubt. I have one custom column. I want to publish the value of distribution target there. How can I get the value of Distribution target name or number in that column?

I mean, how can I fetch the data of Distribution target IBA there?

Thanks,

Sakil