StorageTypes Switch

StorageTypes Switch

Anonymous
Not applicable
507 Views
3 Replies
Message 1 of 4

StorageTypes Switch

Anonymous
Not applicable

Hi again!

 

I'm trying to make a switch per StorageType parameters on elements, but in each case I have mistake " Cannot Implicitly convert ty int into Autodesk.Revit.DB.StorageType".

 

This is my code:

 

Capture.JPG

 

 

Anyone hnow what's going on?, Any idea?.

 

Regards!!!

0 Likes
508 Views
3 Replies
Replies (3)
Message 2 of 4

rosalesduquej
Alumni
Alumni

Hi Carlos,

 

First of all, when ever you post code in a question, try doing it with the text not a picture of it. 

 

Second I really don't understand what are you trying to do in your Switch case. Could you explain a bit more on it. 

 

Here is an example of a Switch case using StorageType 

 

private string ParameterValueForType(FamilyType type, FamilyParameter p)
{
    // return a string with the value of the parameter for this type
    string paramValue = "";
    switch (p.StorageType)
    {
        case StorageType.Double:
            paramValue = type.AsDouble(p).ToString();
            break;
        case StorageType.ElementId:
            paramValue = type.AsElementId(p).IntegerValue.ToString();
            break;
        case StorageType.Integer:
            paramValue = type.AsInteger(p).ToString();
            break;
        case StorageType.String:
            paramValue = type.AsString(p);
            break;
    }
    if (paramValue == null)
        paramValue = "";

    return paramValue;
} 

Maybe will give you and Idea on how to solve your problem.

Also I will recommend again to go over the training material. 

That will save both you and all the rest of us a lot of time and effort in the long run.

 

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

 

Sorry for the incovenient.

 

Thanks for your support.

 

 

0 Likes
Message 4 of 4

rosalesduquej
Alumni
Alumni
Hi Carlos,

Did what I suggested worked ? There is no inconvenient 🙂 just a suggestion to find things faster on your side. Keep me posted how does it go ok.

Cheers,


Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes