1

I am working on a project where I have to assign angle parameters to Dimension built-in group in Revit API c#
Here the angles are available in degrees as shown below

enter image description here

When I set the value in degree (say 11.5 degree) directly I get an error which says "Constraints not satisfied"
So I added the code to convert degree to radian, but even this fails.
My current code below

FamilyManager famManager = famDoc.FamilyManager;
double angle = 11.25; //value in degree
double dn = angle * Math.PI / 180; //Converting degree to radian
FamilyParameter fp = familyManager.get_Parameter("BEND ANGLE");
if (fp != null)
{
    familyManager.Set(fp, values);
}


Another method that I tried

double dn = UnitUtils.ConvertToInternalUnits(angle, DisplayUnitType.DUT_DECIMAL_DEGREES);

I am getting the same error.
Let me know if I am doing something wrong.

Rahul Bhobe
  • 4,165
  • 4
  • 17
  • 32
JPais
  • 115
  • 2
  • 14

1 Answers1

1

Your code is correct. Assuming "values" is equal to "dn".The problem is that you cannot assign the value of 11.25° to this parameter, try to do it manually and you will get the same errar message. There is a problem with the constraints of your model.

ManuelSL
  • 126
  • 5
  • Thank you for your reply. I tried doing it manually and it works. There is a csv file that is uploaded and two parameters I have to update in the model out of which one is a angle value. But programmatically it does not work. – JPais Jul 21 '21 at 14:04
  • in your code. What value did you assign to "values" ? – ManuelSL Jul 21 '21 at 14:24
  • The value of radian value of dn goes there.. which is "0.19634954084936188" (11.25 degree) – JPais Jul 21 '21 at 15:17
  • And what abut the CurrentType in FamilyManager. It is the one that you want to modify ? – ManuelSL Jul 21 '21 at 15:20
  • yes, I am changing it. actually the entire operation happens in a loop. incase of iteration count is 0, I am renaming it and greater than 0, I am creating new type. if (cnt== 0) { famManager.RenameCurrentType("FamilyType " + cnt); } else { famManager.NewType("Family Type " + cnt); } – JPais Jul 21 '21 at 15:32
  • ok, you are setting the parameter value in radians correctly. There is a problem in the family, somehow the combination of parameter values for the current type cannot be solved by revit. I only can advise you to simplify your code and try exactly the same as you do in the UI, maybe the program is doing something else that actually produces the error. Sorry. – ManuelSL Jul 21 '21 at 16:28