SetValueString multiple time to same family parameter

SetValueString multiple time to same family parameter

Anonymous
Not applicable
783 Views
5 Replies
Message 1 of 6

SetValueString multiple time to same family parameter

Anonymous
Not applicable

I want to use SetValueString for a familyParameter in a loop.

 

once the value is assigned, the FamilyParameter is not taking valueString second time.

how can I clear first value from the FamilyParameter and reAssign?

 

How can I convert a PointOnEdge to referencePoint ?

0 Likes
784 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Are you really, totally, sure that you want to be using SetValueString?

 

Quite probably, using the overload of the Set method taking a string argument will better suit your needs:

 

https://apidocs.co/apps/revit/2019/956a1e23-cfe5-a60b-1ff9-0e8e33812774.htm

 

Please read my recent explanation why AsString and AsValueString results differ to understand:

 

https://thebuildingcoder.typepad.com/blog/2019/04/batch-processing-and-aspects-of-asstringvalue.html...

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 6

Anonymous
Not applicable

Thanks for the reply Jeremy. I have  multiple triangles. 

I need to assign length of each member( line curve) to a family Parameter. 

Each triangle is going through the loop. So I need to re-assign the value for the family parameter. The code works perfect when using one triangle and using setValueString for each family parameter. But when it is time to reassign value for the next triangle, it crashes. each triangle are different in size.

_a is a family parameter (string name is “a”,  should contain the length of one particular member of each triangle. List_crvs is the curve list containing one particular member of each triangle. image.jpgit crushes.

0 Likes
Message 4 of 6

Anonymous
Not applicable

image.jpg

0 Likes
Message 5 of 6

Anonymous
Not applicable

 

I also need to convert these PointOnEdge to reference point, so I can move the top one, according to familyParameter formula. The code is not done yet.  Otherwise I would share whole code. It is in the middle and I am stuck badly with simple value assigning. 

image.jpg

0 Likes
Message 6 of 6

MarryTookMyCoffe
Collaborator
Collaborator

I really don't see a good reason to use SetValuesString.
wouldn't be better to use something like :

        static public bool setParameter(Document familyDocument, FamilyParameter familyParameter, string value)
        {
            if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))
                return false;
            switch (familyParameter.StorageType)
            {
                case StorageType.None:
                    break;
                case StorageType.Integer:
                    familyDocument.FamilyManager.Set(familyParameter, Convert.ToInt32(value));
                    return true;
                case StorageType.Double:
                    familyDocument.FamilyManager.Set(familyParameter, Convert.ToDouble(value));
                    return true;
                case StorageType.String:
                    familyDocument.FamilyManager.Set(familyParameter, value.ToString());
                    return true;
                case StorageType.ElementId:
                    break;
                default:
                    break;
            }
            return false;
        }
-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes