String.length of instance/type parameter.

String.length of instance/type parameter.

mohd.fadel
Enthusiast Enthusiast
2,883 Views
20 Replies
Message 1 of 21

String.length of instance/type parameter.

mohd.fadel
Enthusiast
Enthusiast

Hello everyone,

 

I'm using Revit and Revit sdk 2013.

 

There is something weird happening, and i couldn't find anything related to my problem. I'm trying to find the length of a an instance parameter. Everything works perfectly when i retrieve the parameter.

 

Here is my code:

 

Document doc = e.GetDocument();

            ICollection<ElementId> addedElem = e.GetAddedElementIds();
            foreach (ElementId id in addedElem)
            {
                Element elem = doc.GetElement(id);
                ParameterSet parameters = elem.Parameters;
                foreach (Parameter param in parameters)
                {
                    if (param.Definition.Name == "Test Parameter")
                    {

                         if (param.AsString() != "")
                         {
                             paramString = param.AsString();
                             int paramLength = paramString.Length;
                             System.Windows.Forms.MessageBox.Show(paramLength.ToString());

                         }

                    }

             }

 

 

Here's my problem, when i enter a value in my parameter that has a length greater than 10 (ex. "Hello by the way" 16 characters). The length is  displayed in a message box (16). However, if i enter a value less than 10 (ex. "Hello" 5 characters) Not even an empty box is displayed. Nothing is happening. It's like if the length of the string is less than 10 characters, it is not being recognized at all.

 

Anyone faced such a problem?

 

Regards.

 

M. Fadel

 

0 Likes
Accepted solutions (1)
2,884 Views
20 Replies
Replies (20)
Message 21 of 21

mohd.fadel
Enthusiast
Enthusiast

Hahaha!

 

I'm really sorry about all this.. Sometimes you just don't see it!

 

Still can't beleive how silly it was..

 

 

Thanks a ton!:)

 

M.Fadel

 

0 Likes