Example #1
0
 public void WriteVersionSpecificBlockRecordTest_R2000()
 {
     var file = new DxfFile();
     file.Header.Version = DxfAcadVersion.R2000;
     var blockRecord = new DxfBlockRecord()
     {
         Name = "<name>",
         XData = new DxfXData("ACAD",
             new DxfXDataItem[]
             {
                 new DxfXDataString("DesignCenter Data"),
                 new DxfXDataControlGroup(
                     new []
                     {
                         new DxfXDataInteger(0),
                         new DxfXDataInteger(1),
                         new DxfXDataInteger(2)
                     })
             }),
         BitmapData = new byte[]
         {
             0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
             0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09
         }
     };
     file.BlockRecords.Add(blockRecord);
     VerifyFileContains(file, @"
       0
     TABLE
       2
     BLOCK_RECORD
       5
     2
     330
     0
     100
     AcDbSymbolTable
      70
     0
       0
     BLOCK_RECORD
       5
     A
     330
     0
     100
     AcDbSymbolTableRecord
     100
     AcDbBlockTableRecord
       2
     <name>
     340
     0
     310
     010203040506070809010203040506070809
     1001
     ACAD
     1000
     DesignCenter Data
     1002
     {
     1070
     0
     1070
     1
     1070
     2
     1002
     }
       0
     ENDTAB
     ");
 }
Example #2
0
        internal static DxfBlockRecord FromBuffer(DxfCodePairBufferReader buffer)
        {
            var item = new DxfBlockRecord();
            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == 0)
                {
                    break;
                }

                buffer.Advance();
                switch (pair.Code)
                {
                    case DxfCodePairGroup.GroupCodeNumber:
                        var groupName = DxfCodePairGroup.GetGroupName(pair.StringValue);
                        item.ExtensionDataGroups.Add(DxfCodePairGroup.FromBuffer(buffer, groupName));
                        break;
                    case 340:
                        item.LayoutHandle = UIntHandle(pair.StringValue);
                        break;
                    case 70:
                        item.InsertionUnits = (DxfUnits)(pair.ShortValue);
                        break;
                    case 280:
                        item.Explodability = BoolShort(pair.ShortValue);
                        break;
                    case 281:
                        item.Scalability = BoolShort(pair.ShortValue);
                        break;
                    case 310:
                        item._bitmapPreviewData.Add((pair.StringValue));
                        break;
                    case (int)DxfXDataType.ApplicationName:
                        item.XData = DxfXData.FromBuffer(buffer, pair.StringValue);
                        break;
                    default:
                        item.TrySetPair(pair);
                        break;
                }
            }

            return item;
        }