Hide at scales coarser than

Hide at scales coarser than

dkam47
Advocate Advocate
2,829 Views
4 Replies
Message 1 of 5

Hide at scales coarser than

dkam47
Advocate
Advocate

Sorry if this is an easy question but can you use LookupParameter to get the value of "Hide at scales coarser than").

 

The following returns null.

 

Parameter myViewScale = vs.LookupParameter("Hide at scales coarser than");

TaskDialog.Show("Revit", myViewScale.AsValueString());

 

 

Thank you.

0 Likes
Accepted solutions (2)
2,830 Views
4 Replies
Replies (4)
Message 2 of 5

RPTHOMAS108
Mentor
Mentor
Accepted solution

Easy questions are my forte (usually).

 

Never got a BIP that way so I'm not sure. This BIP has two versions depending on units so perhaps that is an issue i.e. Lookup function trys to return the wrong one for the units of the template? Should use the Revit Lookup tool to get an insight into what the parameter is doing in the database.

 

For this built in parameter associated with the view element you should really use the Element.Parameter(BuiltInParameter) overload to get it. This parameter will only be attached to certain types of view such as ViewSection. So, you’ll have to check the view type first as part of the procedure. Depending on if the project is imperial or metric you’ll use one of the below built in parameters.

 

SECTION_COARSER_SCALE_PULLDOWN_METRIC (-1006613)

SECTION_COARSER_SCALE_PULLDOWN_IMPERIAL (-1006614)

 

The storage type is Integer and will return the whole number denominator of the scale but AsValueString will return as you would expect. As you are likely aware, this BIP is not related to the viewscale of the view it is on.

 

Getting parameters via BIP also has the advantage that it is product language independent.

Message 3 of 5

dkam47
Advocate
Advocate
Thanks RPTHOMAS108! I'm still learning the basics so thanks for your detailed explanation. I'll give it a try and let you know.
0 Likes
Message 4 of 5

JimJia
Alumni
Alumni
Accepted solution

Dear dkam47,

 

RPTHOMAS108 is right. You need to use BuiltInParameter. 

The Revit Platform API has a large number of built-in parameters.

It is preferred to built-in parameters than LookupParameter.

If you do not know the exact BuiltInParameter ID, get the parameter by iterating the ParameterSet collection.

foreach (Parameter p in element.Parameters)
                {
                    //get parameter name
                    string name = p.Definition.Name;

                    if (p.Definition is InternalDefinition)
                    {
                        //get the builtin parameter
                        BuiltInParameter builtInParam = (p.Definition as InternalDefinition).BuiltInParameter;
                    }

                    //get the unit type
                    UnitType unitType = p.Definition.UnitType;
                    //get the display type
                    DisplayUnitType displayType = p.DisplayUnitType;
                }

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: [email protected]
0 Likes
Message 5 of 5

dkam47
Advocate
Advocate

Thanks for the help. I was able to get the BuiltInParameter value. Here is what I ended up on.

 

            

FilteredElementCollector viewCol = new FilteredElementCollector(doc);
            IList<Element> viewList = viewCol.OfClass(typeof(ViewSection)).ToElements();

            TaskDialog.Show("Revit", viewList.Count.ToString());
            
            foreach (Element e in viewList) 
            {
            
                var myValue = e.get_Parameter(BuiltInParameter.SECTION_COARSER_SCALE_PULLDOWN_IMPERIAL);
                if(myValue == null)
                {
                continue;
                }
                
                var u = myValue.AsValueString();
                TaskDialog.Show("Revit", u);

0 Likes