Quantcast
Channel: PTC Community: Message List - Windchill
Viewing all articles
Browse latest Browse all 8876

Re: Windchill Customization(Giving constraint to an attribute)

$
0
0

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.


Viewing all articles
Browse latest Browse all 8876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>