Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        void _AddAngleDimension(AngleDimension dim)
        {
            _InitDimensionBlock();

            dim.ComputeParameters(out var p);

            var textMidPos = p.TextOrigin.Translated(Dir2d.DX.Rotated(-p.TextRotation).ToVec(p.TextWidth * 0.5))
                             .Translated(Dir2d.DX.Rotated(-p.TextRotation + Maths.HalfPI).ToVec(p.TextHeight * 0.5));
            var rimPoint = dim.CenterPoint.Translated(p.FirstExtensionVector.Normalized().Lerped(p.SecondExtensionVector.Normalized(), 0.5).Normalized().Scaled(p.Radius));

            var entity = new DxfDomDimension(_CurrentLayerName, _CurrentBlock.Name, textMidPos, -Maths.NormalizeAngleRad(p.TextRotation).ToDeg());

            entity.SetAngularDimension(rimPoint, dim.FirstPoint, dim.SecondPoint, dim.CenterPoint);
            if (!dim.AutoText)
            {
                entity.Text = dim.Text;
            }

            _Document.Entities.Add(entity); // Add to document, not to block
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        void _AddLengthDimension(LengthDimension dim)
        {
            _InitDimensionBlock();

            dim.ComputeParameters(out var p);

            var textMidPos = p.TextOrigin.Translated(p.DimensionDirection.ToVec(p.TextWidth * 0.5))
                             .Translated(p.ExtensionVector.Normalized().Scaled(p.TextHeight * 0.5));
            var dimLinePoint = dim.SecondPoint.Translated(p.DimensionOffset);

            var entity = new DxfDomDimension(_CurrentLayerName, _CurrentBlock.Name, textMidPos, -Maths.NormalizeAngleRad(p.DimensionRotation).ToDeg());

            entity.SetAlignedDimension(dimLinePoint, dim.FirstPoint, dim.SecondPoint);
            if (!dim.AutoText)
            {
                entity.Text = dim.Text;
            }

            _Document.Entities.Add(entity); // Add to document, not to block
        }