简体   繁体   English

Revit API读取错误的类型参数值

[英]Revit API is Reading the Wrong Type Parameters Values

I've developed a family browser, where I can search and find families and can read their additional information. 我已经开发了家庭浏览器,可以在其中搜索和查找家庭,并可以阅读他们的其他信息。 However, the value I'm reading for type parameter is different from one shows in the Revit 2017. Below is the screenshot of property window of my application and Revit 2017. Here the value displays for Dimension's Depth is different from one I can see in the Revit . 但是,我为type参数读取的值与Revit 2017中显示的值不同。以下是我的应用程序和Revit 2017的属性窗口的屏幕截图。在这里,Dimension's Depth值显示与我可以在其中看到值不同。 Revit

类型参数值不匹配

Here is the code behind : 这是背后代码

 static string FamilyParamValueString(FamilyType t, FamilyParameter fp, Document doc)
        {


            string value = t.AsValueString(fp);


            switch (fp.StorageType)
            {
                case StorageType.Double:
                    value = Util.RealString(
                      (double)t.AsDouble(fp))
                      + " (double)";

                    break;

                case StorageType.ElementId:
                    ElementId id = t.AsElementId(fp);
                    Element e = doc.GetElement(id);
                    value = id.IntegerValue.ToString() + " ("
                      + Util.ElementDescription(e) + ")";
                    break;

                case StorageType.Integer:
                    value = t.AsInteger(fp).ToString()
                      + " (int)";
                    break;

                case StorageType.String:
                    value = "'" + t.AsString(fp)
                      + "' (string)";
                    break;
            }

            return value;
        }

here's how I'm calling the FamilyParamValueString method. 这就是我调用FamilyParamValueString方法的方式。

 foreach (FamilyType familytype in mgr.Types)
            {

                string name = familytype.Name;
                MultiValueDictionary<string, Tuple<string, string>> Parameters = new MultiValueDictionary<string, Tuple<string, string>>();

                foreach (string key in keys)
                {
                    FamilyParameter fp = fps[key];
                    var definition = fp.Definition;
                    string ParameterGroupid = LabelUtils.GetLabelFor(definition.ParameterGroup);

                    if (familytype.HasValue(fp))
                    {
                        // Reading type's parameter value
                        string value = FamilyParamValueString(familytype, fp, doc);

                        //store parameter information along with its group
                        Parameters.Add(ParameterGroupid, new Tuple<string, string>(key, value));

                    }
                }



            }

Please guide me, how I can able to read exactly the same values as it displays in the Revit type's properties. 请指导我,我如何能够读取与Revit类型的属性中显示的值完全相同的值。 Thank you for support! 谢谢你的支持!

It's related to units. 与单位有关。 The value returned by the parameter is in Revit's internal units of feet (ft), while the values you see on the screen are in mm, cm, m or whatever else you have set for that model. 该参数返回的值以Revit内部英尺(ft)为单位,而您在屏幕上看到的值以mm,cm,m或为该模型设置的任何其他值。 Just convert from internal to display and you will be fine. 只需从内部转换为显示,就可以了。

Here's a utility method for doing the conversion: http://www.revitapidocs.com/2018/9cc2c0ea-f59f-9d76-ce19-ae7eede03bbd.htm 这是进行转换的实用方法: http : //www.revitapidocs.com/2018/9cc2c0ea-f59f-9d76-ce19-ae7eede03bbd.htm

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM