Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

cannot retrieve omniclass number

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
pmeigneux
919 Views, 6 Replies

cannot retrieve omniclass number

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.

6 REPLIES 6
Message 2 of 7
matthew_taylor
in reply to: pmeigneux

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?
Message 3 of 7
pmeigneux
in reply to: matthew_taylor

Hi Matt,

 

Please send me more detail.

 

Philippe.

Message 4 of 7
matthew_taylor
in reply to: pmeigneux

@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?
Message 5 of 7
pmeigneux
in reply to: matthew_taylor

Thank you Matt.

 

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

 

Philippe.

Message 6 of 7
matthew_taylor
in reply to: pmeigneux

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?
Message 7 of 7
pmeigneux
in reply to: matthew_taylor

Thank you Matt

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report