cannot retrieve omniclass number

pmeigneux
Advocate
Advocate

cannot retrieve omniclass number

pmeigneux
Advocate
Advocate

Hi,

 

cannot retrieve omniclass number (Revit 2017).

 

My Code :

 

public RenderNodeAction OnElementBegin(ElementId elementId)
{
    Element El = _StackDoc.Peek().GetElement(elementId);

 

    BuiltInParameter _bipCode = BuiltInParameter.OMNICLASS_CODE;

    BuiltInParameter _bipDesc = BuiltInParameter.OMNICLASS_DESCRIPTION;


    String CatS = "Show Standard parameters in selected " + CTCT + ":\n";
    foreach (Parameter para in El.Parameters)
    {
        string defName = para.Definition.Name + " = ";

 

        // Use different method to get parameter data according to the storage type
        switch (para.StorageType)
        {
            case StorageType.Double:
                //covert the number into Metric
                defName += para.AsValueString();
                Double Test = para.AsDouble() * 25.4;
                String TESTS = Test.ToString();
                break;

 

            case StorageType.ElementId:
                //find out the name of the element
                ElementId id = para.AsElementId();
                if (id.IntegerValue >= 0)
                {
                     defName += _StackDoc.Peek().GetElement(id).Name;
                }
                else
                {
                     defName += id.IntegerValue.ToString();
                }
                break;

 

            case StorageType.Integer:
                if (ParameterType.YesNo == para.Definition.ParameterType)
                {
                     if (para.AsInteger() == 0)
                     {
                          defName += "False";
                     }
                     else
                     {
                          defName += "True";
                      }
                }
                else
                 {
                     defName += para.AsInteger().ToString();
                }
                break;

 

            case StorageType.String:
                defName += para.AsString();
                break;

 

            default:
                defName = "Unexposed parameter.";
                break;
        }
        CatS = CatS + defName + "\n";
    }

 

    String OmiClass = "";
    if (El.get_Parameter(_bipCode) != null)
         OmiClass = "<" + El.get_Parameter(_bipCode).AsString() + ">";
    else
         OmiClass = "<>";


    if (El.get_Parameter(_bipDesc) != null)
         OmiClass = OmiClass + "<" + El.get_Parameter(_bipDesc).AsString() + ">";
    else
         OmiClass = OmiClass + "<>";

 

    TaskDialog.Show("Debug", CatS + "\n\n OmiClass = " + OmiClass);


    return RenderNodeAction.Proceed;
}

 

My Rvt Model and Result on Windowns (in attachment).

 

Philippe.

0 Likes
Reply
Accepted solutions (1)
958 Views
6 Replies
Replies (6)

matthew_taylor
Advisor
Advisor

Hi @pmeigneux,

Have you used RevitLookup to check whether you are looking in the same place?

e.g. Not on an element, but on a familysymbol etc.

 

Everything will become clear.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes

pmeigneux
Advocate
Advocate

Hi Matt,

 

Please send me more detail.

 

Philippe.

0 Likes

matthew_taylor
Advisor
Advisor

@pmeigneux

RevitLookup can be found here: https://github.com/jeremytammik/RevitLookup

It allows you to browse selected elements, the document database etc.

 

Once you have it installed, you would select the door > Revit Lookup > Snoop Current Selection > Family Symbol (in right-hand pane) > Parameter Set (in right-hand pane), OmniClass Number (in left-hand pane), the values will then be shown in the right-hand pane.

 

A lo-fi method using the actual Revit UI can be seen in the attached image.

 

RevitLookup is an indispensable tool for browsing Revit. Install it as a top priority.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes

pmeigneux
Advocate
Advocate

Thank you Matt.

 

How from the element having access to his family and the parameters of this one?

 

Philippe.

0 Likes

matthew_taylor
Advisor
Advisor
Accepted solution

Hi @pmeigneux

Something like this:

dim famInstance as FamilyInstance =trycast (elem,familyinstance)

Dim famSymbol as familysymbol = famInstance.symbol

then get the parameter from the famSymbol object.

 

All of this will all become very apparent when you use RevitLookup. I cannot stress enough that you should install it and use it regularly to see the association between objects etc.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes

pmeigneux
Advocate
Advocate

Thank you Matt

0 Likes