Пример #1
0
        public void DimensionDefaultValuesTest()
        {
            var dim = new DxfAlignedDimension();

            Assert.Equal("*MODEL_SPACE", dim.BlockName);
            Assert.Equal("STANDARD", dim.DimensionStyleName);
        }
Пример #2
0
        public void WriteDimStyleXDataTest()
        {
            var dim = new DxfAlignedDimension();

            dim.XData.Add("ACAD",
                          new DxfXDataApplicationItemCollection(
                              new DxfXDataString("DSTYLE"),
                              new DxfXDataItemList(
                                  new DxfXDataInteger(271),
                                  new DxfXDataInteger(9)
                                  )
                              ));
            var file = new DxfFile();

            file.Header.Version = DxfAcadVersion.R14;
            file.Entities.Add(dim);
            VerifyFileContains(file,
                               DxfSectionType.Entities,
                               (1001, "ACAD"),
                               (1000, "DSTYLE"),
                               (1002, "{"),
                               (1070, 271),
                               (1070, 9),
                               (1002, "}")
                               );
        }
Пример #3
0
        protected void RoundTripDimensionWithXData(Func <DxfFile, DxfFile> roundTripper)
        {
            var dim = new DxfAlignedDimension();

            dim.XData.Add("ACAD",
                          new DxfXDataApplicationItemCollection(
                              new DxfXDataString("DSTYLE"),
                              new DxfXDataItemList(
                                  new DxfXDataItem[]
            {
                new DxfXDataInteger(271),
                new DxfXDataInteger(9),
            })
                              ));
            var file = new DxfFile();

            file.Header.Version = DxfAcadVersion.R14;
            file.Entities.Add(dim);

            // perform round trip
            var result = roundTripper(file);

            // verify
            var roundTrippedDim = (DxfAlignedDimension)result.Entities.Single();
            var xdataPair       = roundTrippedDim.XData.Single();

            Assert.Equal("ACAD", xdataPair.Key);

            var styleItems = xdataPair.Value;

            Assert.Equal("DSTYLE", ((DxfXDataString)styleItems.First()).Value);
            var dataItems = (DxfXDataItemList)styleItems.Last();

            Assert.Single(dataItems.Items.OfType <DxfXDataInteger>().Where(i => i.Value == 271));
        }
Пример #4
0
        private void RoundTripDimensionWithXData(Func <DxfFile, DxfFile> roundTripper)
        {
            var dim = new DxfAlignedDimension();

            dim.XData = new DxfXData("ACAD",
                                     new DxfXDataItem[]
            {
                new DxfXDataString("DSTYLE"),
                new DxfXDataItemList(
                    new DxfXDataItem[]
                {
                    new DxfXDataInteger(271),
                    new DxfXDataInteger(9),
                })
            });
            var file = new DxfFile();

            file.Header.Version = DxfAcadVersion.R14;
            file.Entities.Add(dim);

            // perform round trip
            var result = roundTripper(file);

            // verify
            var roundTrippedDim = (DxfAlignedDimension)result.Entities.Single();
            var xdata           = roundTrippedDim.XData;

            Assert.Equal("ACAD", xdata.ApplicationName);

            var namedList = (DxfXDataNamedList)xdata.Items.Single();

            Assert.Equal("DSTYLE", namedList.Name);
            Assert.Single(namedList.Items.OfType <DxfXDataInteger>().Where(i => i.Value == 271));
        }
Пример #5
0
        public void WriteDimensionWithStyleDifferenceXData()
        {
            var file             = new DxfFile();
            var standardDimStyle = file.DimensionStyles.Single(ds => ds.Name == "STANDARD");
            var customDimStyle   = new DxfDimStyle()
            {
                DimensioningSuffix = "some suffix"
            };
            var dim = new DxfAlignedDimension();

            dim.XData = DxfDimStyle.GenerateStyleDifferenceAsXData(standardDimStyle, customDimStyle);
            EnsureFileContainsEntity(dim, @"
1001
ACAD
1000
DSTYLE
1002
{
1070
   3
1000
some suffix
1002
}
  0
ENDSEC
", DxfAcadVersion.R14);
        }
Пример #6
0
        public void WriteDimensionWithTrailingXDataTest()
        {
            var dim = new DxfAlignedDimension();

            dim.XData = new DxfXData("ACAD",
                                     new DxfXDataItem[]
            {
                new DxfXDataString("DSTYLE"),
                new DxfXDataItemList(
                    new DxfXDataItem[]
                {
                    new DxfXDataInteger(271),
                    new DxfXDataInteger(9),
                })
            });
            EnsureFileContainsEntity(dim, @"
1001
ACAD
1000
DSTYLE
1002
{
1070
   271
1070
     9
1002
}
  0
ENDSEC
", DxfAcadVersion.R14);
            // the trailing 0/ENDSEC ensures the XData is the last thing written
        }