Beispiel #1
0
        private void SetAttributes(AcBlockRef blockRef, XyzPoint pt)
        {
            if (blockRef.IdAttribute != null)
            {
                blockRef.IdAttribute.TextString = pt.Id;
            }

            var attrH = blockRef.HeightAttribute;

            if ((attrH != null) && (this.SaveThirdCoordinateAsHeightAttribute))
            {
                if (this.HeightAttributePrecision.StartsWith("0"))
                {
                    attrH.TextString = pt.Z.ToString(this.HeightAttributePrecision);
                }
                else
                {
                    attrH.TextString = pt.Z.ToString();
                }
            }

            var attrCode = blockRef.CodeAttribute;

            if ((attrCode != null) && (this.UseCode))
            {
                attrCode.TextString = pt.Code;
            }
        }
Beispiel #2
0
        private void UpdateAdditionalFieldNames(AcBlockRef sampleBlockRef)
        {
            this.AdditionalFieldNames.Clear();
            this.AdditionalFieldNames.Add("Layer");
            this.AdditionalFieldNames.Add("Block");

            foreach (var attr in sampleBlockRef.Attributes)
            {
                this.AdditionalFieldNames.Add("Attr_" + attr.Tag);
            }
        }
Beispiel #3
0
        private XyzPoint ToPoint(AcBlockRef block)
        {
            var pt = new XyzPoint();

            pt.X = block.Position.X;
            pt.Y = block.Position.Y;
            pt.Z = block.Position.Z;

            // Do not change coordinates order, this will be done by PointTextStorageWriter.GetPointFields()
            //if (this.ChangeCoordinatesOrder)
            //{
            //    pt.X = block.Position.Y;
            //    pt.Y = block.Position.X;
            //}

            if (block.IdAttribute != null)
            {
                pt.Id = block.IdAttribute.TextString;
            }

            if (block.CodeAttribute != null)
            {
                pt.Code = block.CodeAttribute.TextString;
            }

            if (this.UseHeightAttribute)
            {
                double hAttrVal = 0.0;
                if (block.HeightAttribute != null)
                {
                    var hAttr = block.HeightAttribute.TextString;
                    hAttr.TryParse(ref hAttrVal);
                }
                pt.Z = hAttrVal;
            }

            pt.AdditionalFields.Clear();
            pt.AdditionalFields.Add(block.Layer);
            pt.AdditionalFields.Add(block.Name);
            foreach (var attr in block.Attributes)
            {
                pt.AdditionalFields.Add(attr.TextString);
            }

            pt.Coord1.Precision = CoordinatesPrecision;
            pt.Coord2.Precision = CoordinatesPrecision;
            pt.Coord3.Precision = ThirdCoordinatePrecision;

            return(pt);
        }
Beispiel #4
0
        public List <AcBlockRef> GetSelectedBlocks()
        {
            var res = new List <AcBlockRef>();

            using (var trans = Ac.StartTransaction())
            {
                foreach (var id in _selectedIds)
                {
                    var block = new AcBlockRef(id, trans);
                    res.Add(block);
                }
            }

            return(res);
        }