Exemplo n.º 1
0
        public static JobData Load()
        {
            using (var trans = ModelSpace.StartTransaction())
            {
                foreach (var objectId in ModelSpace.From(trans))
                {
                    if (IsJobDataBlock(trans, objectId))
                    {
                        var data = new JobData
                        {
                            CalculatedByCompany        = AttributeReader.TextString(trans, objectId, "CALCULATED_BY_COMPANY"),
                            JobNumber                  = AttributeReader.TextString(trans, objectId, "LEAD_NUMBER"),
                            JobName                    = AttributeReader.TextString(trans, objectId, "JOB_NAME"),
                            JobSiteAddress             = AttributeReader.TextString(trans, objectId, "SITE_LOCATION"),
                            SupplyStaticPressure       = AttributeReader.TextString(trans, objectId, "STATIC_PRESSURE"),
                            SupplyResidualPressure     = AttributeReader.TextString(trans, objectId, "RESIDUAL_PRESSURE"),
                            SupplyAvailableFlow        = AttributeReader.TextString(trans, objectId, "AVAILABLE_FLOW"),
                            SupplyElevation            = AttributeReader.TextString(trans, objectId, "METER_ELEVATION"),
                            SupplyPipeLength           = AttributeReader.TextString(trans, objectId, "METER_PIPE_LENGTH"),
                            SupplyPipeInternalDiameter = AttributeReader.TextString(trans, objectId, "METER_PIPE_INTERNAL_DIAMETER"),
                        };

                        return(data);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public static List <FloorTag> GetFloorTags()
        {
            using (var transaction = ModelSpace.StartTransaction())
            {
                var floorTags = new List <FloorTag>();
                foreach (ObjectId id in GetFloorTagIds(transaction))
                {
                    var block           = transaction.GetObject(id, OpenMode.ForRead) as BlockReference;
                    var elevationString = AttributeReader.TextString(
                        transaction,
                        id,
                        tag: "ELEVATION");

                    int.TryParse(elevationString, out int elevation);
                    floorTags.Add(new FloorTag
                    {
                        Position = new Point3d(
                            x: block.Position.X,
                            y: block.Position.Y,
                            z: block.Position.Z),
                        Name = AttributeReader.TextString(
                            transaction,
                            id,
                            tag: "NAME"),

                        Elevation = elevation
                    });
                }

                floorTags = floorTags.OrderBy(t => t.Elevation).ToList();

                return(floorTags);
            }
        }
Exemplo n.º 3
0
        public static int HighestNumber()
        {
            using (var transaction = ModelSpace.StartTransaction())
            {
                int lastNumber = 0;
                var labelIds   = GetRiserLabelIds(transaction);

                foreach (var id in labelIds)
                {
                    string text  = AttributeReader.TextString(transaction, id, tag: TagName);
                    var    match = Regex.Match(text, @"R\.(\d+)\.[A-Z]");
                    if (match.Success)
                    {
                        string numberString = match.Groups[1].Value;
                        int    number       = int.Parse(numberString);
                        if (number > lastNumber)
                        {
                            lastNumber = number;
                        }
                    }
                }

                return(lastNumber);
            }
        }
Exemplo n.º 4
0
        bool PropertiesMatch(Transaction transaction, BlockTableRecord record)
        {
            var attDef = AttributeReader.AttributeDefWithTagNamed(
                transaction,
                record.Id,
                specs.Tag);

            return(attDef != null &&
                   attDef.Position.X == specs.XOffset &&
                   attDef.Position.Y == specs.YOffset &&
                   attDef.Height == specs.TextHeight &&
                   attDef.Layer == specs.Layer &&
                   attDef.ColorIndex == ColorIndices.ByLayer);
        }
Exemplo n.º 5
0
        static List <string> GetRiserLabelTexts()
        {
            using (var transaction = ModelSpace.StartTransaction())
            {
                var texts    = new List <string>();
                var labelIds = GetRiserLabelIds(transaction);

                foreach (var id in labelIds)
                {
                    string text = AttributeReader.TextString(transaction, id, tag: TagName);
                    texts.Add(text);
                }

                return(texts);
            }
        }