Positional Representations: Find out which constraints are impacted

Positional Representations: Find out which constraints are impacted

Robert.MislerXEDWT
Participant Participant
338 Views
1 Reply
Message 1 of 2

Positional Representations: Find out which constraints are impacted

Robert.MislerXEDWT
Participant
Participant

Hi,

 

I am trying to identify constraints that are overridden by a positional representation, but for the life of me can't figure out how to do so in C#.

So far i get a constraint and then start iterating all positional representations. For every positional representation I try to use the function IsRelationshipValueOverridden, which i think should give me true or false, whether the constraint is altered by the positional representation or not.

Sounds good so far, except for the IsRelationshipValueOverridden function wanting me to provide the correct RelationshipValueType (here: type):

myResult = myPosRep.IsRelationshipValueOverridden(constraint, type, out myExpr);

 

How can I know, what type to give here? I have tried many combinations but there is always a constraint that will fail with: Exception thrown: 'System.ArgumentException' in System.Dynamic.dll.

I even iterate through all types and try/catch to process it, but that can't be the solution (and still fails).

 

Thank you so much for the help!

foreach (var type in Inventor.RelationshipValueTypeEnum.GetValues(typeof(Inventor.RelationshipValueTypeEnum)).Cast<Inventor.RelationshipValueTypeEnum>())
                        {
                            Inventor.RelationshipValueTypeEnum type = (Inventor.RelationshipValueTypeEnum)myType;
                            //Console.WriteLine("Trying type: " + type.ToString());
                            try
                            {
                                myResult = myPosRep.IsRelationshipValueOverridden(constraint, type, out myExpr);

 

0 Likes
339 Views
1 Reply
Reply (1)
Message 2 of 2

Robert.MislerXEDWT
Participant
Participant

After a lot of tinkering i think i may have to rephrase the question entirely.

The Problem was not that the arguments of IsRelationshipValueOverridden were wrong. The problem is that it only works for the main assembly.

I Iterate all (sub)assemblies in my main assembly and get the representations manager of the sub-assembly, then iterate all positional representations and want to find out if any of my constraints that are defined in the sub-assembly are overridden.

 

It works fine for the main assembly, but as soon as I try it with an subassembly, the function returns an error.

 

Is it even possible to access the positional representations of an subassembly within the main assembly through the API?

0 Likes