Esempio n. 1
0
        /// <summary>
        /// Retrieve the family instance data to store in
        /// the external database for the given component
        /// and return it as a dictionary-like object.
        /// Obsolete, replaced by InstanceData class.
        /// </summary>
        object GetInstanceData(
            FamilyInstance a,
            Transform geoTransform)
        {
            Document     doc    = a.Document;
            FamilySymbol symbol = a.Symbol;
            Category     cat    = a.Category;

            Debug.Assert(null != cat,
                         "expected valid category");

            string levelName = ElementId.InvalidElementId == a.LevelId
        ? "-1"
        : doc.GetElement(a.LevelId).Name;

            XYZ location = Util.GetLocation(a);

            Debug.Assert(null != location,
                         "expected valid location");

            XYZ geolocation = geoTransform.OfPoint(
                location);

            string properties = Util.GetPropertiesJson(
                a.GetOrderedParameters());

            // /a/src/web/CompHoundWeb/model/instance.js
            // _id         : UniqueId // suppress automatic generation
            // project    : String
            // path       : String
            // family     : String
            // symbol     : String
            // category   : String
            // level      : String
            // x          : Number
            // y          : Number
            // z          : Number
            // easting    : Number // Geo2d?
            // northing   : Number
            // properties : String // json dictionary of instance properties and values

            object data = new
            {
                _id        = a.UniqueId,
                project    = doc.Title,
                path       = doc.PathName,
                family     = symbol.FamilyName,
                symbol     = symbol.Name,
                category   = cat.Name,
                level      = levelName,
                x          = location.X,
                y          = location.Y,
                z          = location.Z,
                easting    = geolocation.X,
                northing   = geolocation.Y,
                properties = properties
            };

            return(data);
        }
Esempio n. 2
0
        public InstanceData(
            FamilyInstance a,
            Transform geoTransform,
            string model_urn)
        {
            Document     doc = a.Document;
            FamilySymbol fs  = a.Symbol;
            Category     cat = a.Category;

            Debug.Assert(null != cat,
                         "expected valid category");

            string levelName = ElementId.InvalidElementId == a.LevelId
        ? "-1"
        : doc.GetElement(a.LevelId).Name;

            XYZ location = Util.GetLocation(a);

            Debug.Assert(null != location,
                         "expected valid location");

            XYZ geolocation = geoTransform.OfPoint(
                location);

            string jsonProps = Util.GetPropertiesJson(
                a.GetOrderedParameters());

            // /a/src/web/CompHoundWeb/model/instance.js
            // _id        : UniqueId // suppress automatic generation
            // project    : String
            // path       : String
            // urn        : String
            // family     : String
            // symbol     : String
            // category   : String
            // level      : String
            // x          : Number
            // y          : Number
            // z          : Number
            // easting    : Number // Geo2d?
            // northing   : Number
            // properties : String // json dictionary of instance properties and values

            _id        = a.UniqueId;
            project    = doc.Title;
            path       = doc.PathName;
            urn        = model_urn;
            family     = fs.FamilyName;
            symbol     = fs.Name;
            category   = cat.Name;
            level      = levelName;
            x          = Util.ConvertFeetToMillimetres(location.X);
            y          = Util.ConvertFeetToMillimetres(location.Y);
            z          = Util.ConvertFeetToMillimetres(location.Z);
            easting    = Util.RoundDegreesNorthOrEast(geolocation.X);
            northing   = Util.RoundDegreesNorthOrEast(geolocation.Y);
            properties = jsonProps;
        }
Esempio n. 3
0
        /// <summary>
        /// Retrieve the family instance data to store in
        /// the external database for the given component
        /// and return it as a dictionary in a JSON
        /// formatted string.
        /// Obsolete, replaced by GetInstanceData method.
        /// </summary>
        string GetComponentDataJson(
            FamilyInstance a,
            Transform geoTransform)
        {
            Document     doc    = a.Document;
            FamilySymbol symbol = a.Symbol;

            XYZ location = Util.GetLocation(a);

            XYZ geolocation = geoTransform.OfPoint(
                location);

            string properties = Util.GetPropertiesJson(
                a.GetOrderedParameters());

            // /a/src/web/CompHoundWeb/model/instance.js
            // _id         : UniqueId // suppress automatic generation
            // project    : String
            // path       : String
            // family     : String
            // symbol     : String
            // level      : String
            // x          : Number
            // y          : Number
            // z          : Number
            // easting    : Number // Geo2d?
            // northing   : Number
            // properties : String // json dictionary of instance properties and values

            string s = string.Format(
                "\"_id\": \"{0}\", "
                + "\"project\": \"{1}\", "
                + "\"path\": \"{2}\", "
                + "\"family\": \"{3}\", "
                + "\"symbol\": \"{4}\", "
                + "\"level\": \"{5}\", "
                + "\"x\": \"{6}\", "
                + "\"y\": \"{7}\", "
                + "\"z\": \"{8}\", "
                + "\"easting\": \"{9}\", "
                + "\"northing\": \"{10}\", "
                + "\"properties\": \"{11}\"",
                a.UniqueId, doc.Title, doc.PathName,
                symbol.FamilyName, symbol.Name,
                doc.GetElement(a.LevelId).Name,
                Util.RealString(location.X),
                Util.RealString(location.Y),
                Util.RealString(location.Z),
                Util.RealString(geolocation.X),
                Util.RealString(geolocation.Y),
                properties);

            return("{" + s + "}");
        }
Esempio n. 4
0
        private void CopyParameterValue(FamilyInstance rebar2dSymbol, FamilyInstance rebar)
        {
            IList <Parameter> orderedParameters = rebar2dSymbol.GetOrderedParameters();

            foreach (Parameter parameter in orderedParameters)
            {
                bool isReadOnly = parameter.IsReadOnly;
                if (!isReadOnly)
                {
                    string name = parameter.Definition.Name;
                    bool   flag = name != "SORTING_ORDER";
                    if (flag)
                    {
                        Parameter parameter2 = rebar.LookupParameter(name);
                        bool      flag2      = parameter2 == null;
                        if (!flag2)
                        {
                            bool flag3 = parameter2.StorageType == StorageType.Double && parameter.StorageType == StorageType.Double;
                            if (flag3)
                            {
                                double value = parameter2.AsDouble();
                                parameter.Set(value);
                            }
                            else
                            {
                                bool flag4 = parameter2.StorageType == StorageType.Integer && parameter.StorageType == StorageType.Integer;
                                if (flag4)
                                {
                                    int value2 = parameter2.AsInteger();
                                    parameter.Set(value2);
                                }
                                else
                                {
                                    bool flag5 = parameter2.StorageType == StorageType.String && parameter.StorageType == StorageType.String;
                                    if (flag5)
                                    {
                                        string value3 = parameter2.AsString();
                                        parameter.Set(value3);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Retrieve the family instance data to store in 
        /// the external database for the given component
        /// and return it as a dictionary-like object.
        /// Obsolete, replaced by InstanceData class.
        /// </summary>
        object GetInstanceData(
            FamilyInstance a,
            Transform geoTransform)
        {
            Document doc = a.Document;
              FamilySymbol symbol = a.Symbol;
              Category cat = a.Category;

              Debug.Assert( null != cat,
            "expected valid category" );

              string levelName = ElementId.InvalidElementId == a.LevelId
            ? "-1"
            : doc.GetElement( a.LevelId ).Name;

              XYZ location = Util.GetLocation( a );

              Debug.Assert( null != location,
            "expected valid location" );

              XYZ geolocation = geoTransform.OfPoint(
            location );

              string properties = Util.GetPropertiesJson(
            a.GetOrderedParameters() );

              // /a/src/web/CompHoundWeb/model/instance.js
              // _id         : UniqueId // suppress automatic generation
              // project    : String
              // path       : String
              // family     : String
              // symbol     : String
              // category   : String
              // level      : String
              // x          : Number
              // y          : Number
              // z          : Number
              // easting    : Number // Geo2d?
              // northing   : Number
              // properties : String // json dictionary of instance properties and values

              object data = new
              {
            _id = a.UniqueId,
            project = doc.Title,
            path = doc.PathName,
            family = symbol.FamilyName,
            symbol = symbol.Name,
            category = cat.Name,
            level = levelName,
            x = location.X,
            y = location.Y,
            z = location.Z,
            easting = geolocation.X,
            northing = geolocation.Y,
            properties = properties
              };

              return data;
        }
Esempio n. 6
0
        /// <summary>
        /// Retrieve the family instance data to store in 
        /// the external database for the given component
        /// and return it as a dictionary in a JSON 
        /// formatted string.
        /// Obsolete, replaced by GetInstanceData method.
        /// </summary>
        string GetComponentDataJson(
            FamilyInstance a,
            Transform geoTransform)
        {
            Document doc = a.Document;
              FamilySymbol symbol = a.Symbol;

              XYZ location = Util.GetLocation( a );

              XYZ geolocation = geoTransform.OfPoint(
            location );

              string properties = Util.GetPropertiesJson(
            a.GetOrderedParameters() );

              // /a/src/web/CompHoundWeb/model/instance.js
              // _id         : UniqueId // suppress automatic generation
              // project    : String
              // path       : String
              // family     : String
              // symbol     : String
              // level      : String
              // x          : Number
              // y          : Number
              // z          : Number
              // easting    : Number // Geo2d?
              // northing   : Number
              // properties : String // json dictionary of instance properties and values

              string s = string.Format(
            "\"_id\": \"{0}\", "
            + "\"project\": \"{1}\", "
            + "\"path\": \"{2}\", "
            + "\"family\": \"{3}\", "
            + "\"symbol\": \"{4}\", "
            + "\"level\": \"{5}\", "
            + "\"x\": \"{6}\", "
            + "\"y\": \"{7}\", "
            + "\"z\": \"{8}\", "
            + "\"easting\": \"{9}\", "
            + "\"northing\": \"{10}\", "
            + "\"properties\": \"{11}\"",
            a.UniqueId, doc.Title, doc.PathName,
            symbol.FamilyName, symbol.Name,
            doc.GetElement( a.LevelId ).Name,
            Util.RealString( location.X ),
            Util.RealString( location.Y ),
            Util.RealString( location.Z ),
            Util.RealString( geolocation.X ),
            Util.RealString( geolocation.Y ),
            properties );

              return "{" + s + "}";
        }