cad.net 块裁剪边界反向修剪

参考

Querying for XCLIP information inside AutoCAD using .NET (这里下面观众讨论了)

How do I determine if an x-clip boundary is inverted?
翻译:
看起来Autodesk忘记了通过API公开此设置,或将其包含在DXF输出中.也许您可以通过调用 SpatialFilter.ClipVolumeIntersectsExtents() 来确定它,它的内容完全在边界之内.
该设置通过 DwgOutFields() 提交给DWG文件管理器,因此,如果所有其他操作均失败,则可以编写一个自定义AcDbDwgFiler来捕获该设置.

说明

根据以上的帖子,我们会得到一个消息是,
桌子并没有封装好cad的块裁剪边界翻转部分.

然后我翻了翻api,
在Acad2015版本上面是已经加了一个 SpatialFilter.Inverted 这个函数.
而我们低版本需要的就是自己写.
最后进行刷新.

而这个模块到底有什么用呢
实际上它是cad图元序列化
不过需要注意,单行文本会出错...没分析出原因...

img

但是要注意下面的函数,它们只是个例子,
没有提供撤销回滚的时候要刷新的操作...这个部分大家自己自行制作.

代码:

测试命令

子函数参考: cad.net的undo返回操作

#if !HC2020
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Acap = Autodesk.AutoCAD.ApplicationServices.Application;
#else
using GrxCAD.DatabaseServices;
using GrxCAD.EditorInput;
using GrxCAD.Runtime;
using Acap = GrxCAD.ApplicationServices.Application;
#endif
using System;

namespace JoinBox;

public static partial class Cmd_jjMoveBlockCropBoundary {
 
// 存在问题,undo撤回的时候无法代码刷新,只能用户自己去刷新...
// 选择图块,进行反向裁剪

[CommandMethod("JJ_Inverted", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Session)]
public static void JJ_Inverted() {
    var doc = Acap.DocumentManager.MdiActiveDocument;
    var ed = doc.Editor;
    var peo = new PromptEntityOptions(Environment.NewLine + "点选图块:")
    {
        AllowObjectOnLockedLayer = false,
         AllowNone                = false
    };
    var per = ed.GetEntity(peo);
    if (per.Status != PromptStatus.OK)
         return;
            
    CadSystem.Undo(true);

    //锁文档,用 CommandFlags.Session 就要锁,否则 eLockViolation
    doc.Action(() => {
        doc.Database.Action(tr => {
                    var ent = per.ObjectId.ToEntity(tr);
                    if (ent is BlockReference acBlkRef)
                    {
                        acBlkRef.SpatialFilterInverted(tr);
                    }
                });
            });
    CadSystem.Undo(false);
    }
}

SpatialFilter.cs

利用组合模式来制作同名的SpatialFilter类

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using System.Collections.Generic;

namespace JoinBox;

public class SpatialFilter  {
    bool _Inverted;
    public bool Inverted {
        get => _Inverted;
        set {
            if (_Inverted != value) {
                _Inverted = value;
               // 设定反向裁剪
                DwgFilerEx df = new(Filter);
                df.Inverted();
                df.DwgIn();
            }
        }
    }

    public Autodesk.AutoCAD.DatabaseServices.Filters.SpatialFilter Filter { get; set; }

    public SpatialFilter() {
        Filter = new();
    }
    public SpatialFilter(Autodesk.AutoCAD.DatabaseServices.Filters.SpatialFilter sp) {
        Filter = sp;
    }

    /// <summary>
    /// 生成块裁剪边界多段线
    /// </summary>
    /// <param name="filter_old">过滤器</param>
    /// <param name="tr">事务</param>
    /// <returns></returns>
    public ObjectId DrawPolygon(Transaction tr)  {
        var vertices = Filter.Definition.GetPoints();
        return DrawPolygon(vertices, tr, Filter.Database);
    }

    ObjectId DrawPolygon(Point2dCollection vertices, Transaction tr, Database db)
    {
            List<BulgeVertex> bulges = new();
            if (vertices.Count == 2)//生成一个矩形
            {
                bulges = new List<BulgeVertex>
                {
                    new BulgeVertex(vertices[0],0),
                    new BulgeVertex(new Point2d(vertices[0].X, vertices[1].Y),0),
                    new BulgeVertex(vertices[1],0),
                    new BulgeVertex(new Point2d(vertices[1].X, vertices[0].Y),0)
                };
            }
            else
            {
                foreach (Point2d item in vertices)
                {
                    bulges.Add(new BulgeVertex(item, 0));
                }
            }
            return tr.AddEntityToMsPs(db, EntityAdd.AddPolyLineToEntity(0, bulges.ToArray()));
    }

        /// <summary>
        /// 隐式转换(相当于是重载赋值运算符)
        /// </summary>
    public static implicit operator SpatialFilter(DBObject spatial)
    {
        if (spatial is Autodesk.AutoCAD.DatabaseServices.Filters.SpatialFilter sp)
        {
            return new SpatialFilter(sp);
        }
        throw new("错误");
    }
}

SpatialFilterHelper.cs

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.DatabaseServices.Filters;

namespace JoinBox
{
    public static class SpatialFilterHelper
    {
        /// <summary>
        /// 块裁剪边界翻转
        /// </summary>
        /// <param name="acBlkRef">块参照</param>
        /// <param name="tr">事务</param>
        public static void SpatialFilterInverted(this BlockReference acBlkRef, Transaction tr)
        {
            var info = acBlkRef.GetBlockBoundaryInfo(tr);
            if (info == null)
                return;
            //直接设置为反向
            info.Filter.UpgradeOpen();
            info.Inverted = !info.Inverted;
            info.Filter.DowngradeOpen();
            var ids = acBlkRef.ToIEnumerable().ToIds();
            tr.EntityRedraw(ids, Bright.RecordGraphicsModified);
        }

        //定义扩展词典和条目名称的名称
        const string dictName = "ACAD_FILTER";
        const string spName = "SPATIAL";

        /// <summary>
        /// 设置块裁剪边界
        /// </summary>
        /// <param name="tr">事务</param>
        /// <param name="filterDef">边界信息</param>
        /// <param name="acBlkRef">块参照</param>
        public static SpatialFilter SetBlockBoundaryInfo(this BlockReference acBlkRef, Transaction tr, SpatialFilterDefinition filterDef)
        {
            if (acBlkRef.ExtensionDictionary.IsNull)
            {
                acBlkRef.UpgradeOpen();
                acBlkRef.CreateExtensionDictionary();//创建扩展字典
                acBlkRef.DowngradeOpen();
            }
            var filter = new SpatialFilter();
            filter.Filter.Definition = filterDef;  //eInvalidInput错误 1:是因为矩形边界要从左下到右上 2:非当前空间

            //删除已有边界词典,再重新加入
            var extDict = tr.GetObject(acBlkRef.ExtensionDictionary, OpenMode.ForWrite) as DBDictionary;
            if (extDict.Contains(dictName))
            {
                var filterDict = tr.GetObject(extDict.GetAt(dictName), OpenMode.ForWrite) as DBDictionary;
                if (filterDict.Contains(spName))
                {
                    filterDict.Remove(spName);
                }
                filterDict.SetAt(spName, filter.Filter);
                filterDict.DowngradeOpen();
            }
            else
            {
                using (var filterDict = new DBDictionary())
                {
                    extDict.SetAt(dictName, filterDict);
                    tr.AddNewlyCreatedDBObject(filterDict, true);
                    filterDict.SetAt(spName, filter.Filter);
                }
            }
            extDict.DowngradeOpen();
            tr.AddNewlyCreatedDBObject(filter.Filter, true);

            return filter;
        }

        /// <summary>
        /// 获取块参照的裁剪边界信息
        /// </summary>
        /// <param name="acBlkRef">块参照</param>
        /// <param name="tr">事务</param>
        /// <returns>返回词条的裁剪信息,null表示没有裁剪</returns>
        public static SpatialFilter GetBlockBoundaryInfo(this BlockReference acBlkRef, Transaction tr)
        {
            SpatialFilter filter = null;
            //拓展词典存在,遇到没有裁剪就报错
            if (!acBlkRef.ExtensionDictionary.IsOk())
                return null;
            var extdict = tr.GetObject(acBlkRef.ExtensionDictionary, OpenMode.ForRead) as DBDictionary;
            if (extdict != null && extdict.Contains(dictName))
            {
                var dict = tr.GetObject(extdict.GetAt(dictName), OpenMode.ForRead) as DBDictionary;
                if (dict != null && dict.Contains(spName))
                {
                    filter = tr.GetObject(dict.GetAt(spName), OpenMode.ForRead);
                }
            }
            return filter;
        }

        /// <summary>
        /// 删除裁剪边界
        /// </summary>
        /// <param name="blockId">块参照的id</param>
        public static void DelBlockBoundary(this ObjectId blockId, Transaction tr)
        {
            if (!blockId.IsOk())
            {
                return;
            }

            Entity ent = blockId.ToEntity(tr);
            ent.UpgradeOpen();

            var acBlkRef = ent as BlockReference;
            if (acBlkRef.ExtensionDictionary.IsOk())
            {
                // var extDict = tr.GetObject(acBlkRef.ExtensionDictionary, OpenMode.ForWrite) as DBDictionary;
                var extDict = acBlkRef.ExtensionDictionary.ToDBDictionary(tr);
                if (extDict.Contains(dictName))
                {
                    var objid = extDict.GetAt(dictName);
                    if (objid.IsOk())
                    {
                        var filterDict = tr.GetObject(objid, OpenMode.ForWrite) as DBDictionary;
                        if (filterDict.Contains(spName))
                        {
                            filterDict.Remove(spName);
                        }
                        filterDict.DowngradeOpen();
                        extDict.Remove(dictName);
                    }
                }
                extDict.DowngradeOpen();
                // 块的裁剪边界词典直接删除"ACAD_FILTER"中的"SPATIAL"项目就可以释放词典了,删除边界
                acBlkRef.ReleaseExtensionDictionary();
            }
            ent.DowngradeOpen();
        }
    }
}

DwgFilerEx.cs

using Autodesk.AutoCAD.DatabaseServices;
using Newtonsoft.Json;
using System.Text.RegularExpressions;

namespace JoinBox
{
    public class DwgFilerEx
    {
        DBObject _entity;
        public DwgFiler DwgFiler { get; set; }
        public DwgFilerEx()
        {
            DwgFiler = new DwgFiler();
        }

        public DwgFilerEx(DBObject entity) : this()
        {
            DwgOut(entity);
        }

        public void DwgOut(DBObject entity)
        {
            _entity = entity;
            _entity.DwgOut(DwgFiler);
        }

        public void DwgIn()
        {
            _entity.DwgIn(DwgFiler);
        }

        /// <summary>
        /// 设定裁剪边界翻转
        /// </summary>
        public void Inverted()
        {
            if (DwgFiler.Uint16List[1] == 1)//true反向裁剪,false正向裁剪
            {
                DwgFiler.Uint16List[1] = 0;
            }
            else
            {
                DwgFiler.Uint16List[1] = 1;
            }
        }

        /// <summary>
        /// 序列化
        /// </summary>
        /// <returns></returns>
        public string SerializeObject()
        {
            return JsonConvert.SerializeObject(DwgFiler);  //序列化*类转字符串
            //Root = JsonConvert.DeserializeObject<Root>(json);//反序列化*字符串转类
        }

        public override string ToString()
        {
            var str = SerializeObject();
            //替换中括号以外的字符串,替换逗号为换行符 https://bbs.csdn.net/topics/370134253
            str = str.Substring(1, str.Length - 2);
            str = Regex.Replace(str, @"(?:,)(?![^\[]*?\])", "\r\n");
            return str;
        }
    }
}

DwgFiler.cs

所有的ObjectId部分都不能序列化,不然会出现报错.

#if !HC2020
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Acap = Autodesk.AutoCAD.ApplicationServices.Application;
#else
using GrxCAD.DatabaseServices;
using GrxCAD.EditorInput;
using GrxCAD.Geometry;
using GrxCAD.Runtime;
using Acap = GrxCAD.ApplicationServices.Application;
#endif
using System.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;

/*
  Arx自定义实体类,加 读函数(assertReadEnabled)和写函数(assertWriteEnabled)

  所有属性位置都不要改动位置,因为涉及序列化
  [Serializable]               设置类   可以序列化
  [Newtonsoft.Json.JsonIgnore] 设置成员 不可序列化
*/
namespace JoinBox
{
    [Serializable]
    public class DwgFiler : Autodesk.AutoCAD.DatabaseServices.DwgFiler
    {
#if NET35
        public int m_Position;
#else
        public long m_Position;
#endif
        public FilerType m_FilerType;
        public ErrorStatus m_FilerStatus;
        public List<IntPtr> AddressList { get; set; }
        public int AddressListPt = 0;
        public List<byte[]> BinaryChunkList { get; set; }
        public int BinaryChunkListPt = 0;
        public List<bool> BooleanList { get; set; }
        public int BooleanListPt = 0;
        public List<byte> ByteList { get; set; }
        public int ByteListPt = 0;
        public List<byte[]> BytesList { get; set; }
        public int BytesListPt = 0;
        public List<double> DoubleList { get; set; }
        public int DoubleListPt = 0;
        public List<Handle> HandleList { get; set; }
        public int HandleListPt = 0;
        [Newtonsoft.Json.JsonIgnore]
        public List<ObjectId> HardOwnershipIdList { get; set; }
        public int HardOwnershipIdListPt = 0;
        [Newtonsoft.Json.JsonIgnore]
        public List<ObjectId> HardPointerIdList { get; set; }
        public int HardPointerIdListPt = 0;
        public List<short> Int16List { get; set; }
        public int Int16ListPt = 0;
        public List<int> Int32List { get; set; }
        public int Int32ListPt = 0;
#if !NET35
        public List<long> Int64List { get; set; }
        public int Int64ListPt = 0;
#endif
        public List<Point2d> Point2dList { get; set; }
        public int Point2dListPt = 0;
        public List<Point3d> Point3dList { get; set; }
        public int Point3dListPt = 0;
        public List<Scale3d> Scale3dList { get; set; }
        public int Scale3dListPt = 0;
        [Newtonsoft.Json.JsonIgnore]
        public List<ObjectId> SoftOwnershipIdList { get; set; }
        public int SoftOwnershipIdListPt = 0;
        [Newtonsoft.Json.JsonIgnore]
        public List<ObjectId> SoftPointerIdList { get; set; }
        public int SoftPointerIdListPt = 0;
        public List<string> StringList { get; set; }
        public int StringListPt = 0;
        public List<ushort> Uint16List { get; set; }
        public int uint16ListPt = 0;
        public List<uint> Uint32List { get; set; }
        public int uint32ListPt = 0;
#if !NET35
        public List<ulong> Uint64List { get; set; }
        public int uint64ListPt = 0;
#endif
        public List<Vector2d> Vector2dList { get; set; }
        public int Vector2dListPt = 0;
        public List<Vector3d> Vector3dList { get; set; }
        public int Vector3dListPt = 0;

        public DwgFiler()
        {
            m_Position          = 0;
            m_FilerType         = FilerType.CopyFiler;
            m_FilerStatus       = ErrorStatus.OK;
            AddressList         = new List<IntPtr>();
            BinaryChunkList     = new List<byte[]>();
            BooleanList         = new List<bool>();
            ByteList            = new List<byte>();
            BytesList           = new List<byte[]>();
            DoubleList          = new List<double>();
            HandleList          = new List<Handle>();
            HardOwnershipIdList = new List<ObjectId>();
            HardPointerIdList   = new List<ObjectId>();
            Int16List           = new List<short>();
            Int32List           = new List<int>();
#if !NET35
            Int64List           = new List<long>();
#endif
            Point2dList         = new List<Point2d>();
            Point3dList         = new List<Point3d>();
            Scale3dList         = new List<Scale3d>();
            SoftOwnershipIdList = new List<ObjectId>();
            SoftPointerIdList   = new List<ObjectId>();
            StringList          = new List<string>();
            Uint16List          = new List<ushort>();
            Uint32List          = new List<uint>();
#if !NET35
            Uint64List          = new List<ulong>();
#endif
            Vector2dList        = new List<Vector2d>();
            Vector3dList        = new List<Vector3d>();
        }

#if NET35
        public override int Position => m_Position;
#else
        public override long  Position => m_Position;
#endif
        public override FilerType FilerType
        {
            get
            {
                return this.m_FilerType;
            }
        }

        public override ErrorStatus FilerStatus
        {
            get
            {
                return m_FilerStatus;
            }
            set
            {
                m_FilerStatus = value;
            }
        }

        public override IntPtr ReadAddress()
        {
            if (AddressList.Count() == 0)
            {
                return new IntPtr();
            }
            return AddressList[AddressListPt++];
        }

        public override byte[] ReadBinaryChunk()
        {
            if (BinaryChunkList.Count() == 0)
            {
                return null;
            }
            return BinaryChunkList[BinaryChunkListPt++];
        }

        public override bool ReadBoolean()
        {
            if (BooleanList.Count() == 0)
            {
                return false;
            }
            return BooleanList[BooleanListPt++];
        }

        public override byte ReadByte()
        {
            if (ByteList.Count() == 0)
            {
                return 0;
            }
            return ByteList[ByteListPt++];
        }

        public override void ReadBytes(byte[] value)
        {
            if (ByteList.Count() == 0)
            {
                return;
            }
            value = new byte[BytesList[BytesListPt].Length];
            BytesList[BytesListPt++].CopyTo(value, 0);
        }

        public override double ReadDouble()
        {
            if (DoubleList.Count() == 0)
            {
                return 0;
            }
            return DoubleList[DoubleListPt++];
        }

        public override Handle ReadHandle()
        {
            if (HandleList.Count() == 0)
            {
                return new Handle();
            }
            return HandleList[HandleListPt++];
        }

        public override ObjectId ReadHardOwnershipId()
        {
            if (HardOwnershipIdList.Count() == 0)
            {
                return new ObjectId();
            }
            return HardOwnershipIdList[HardOwnershipIdListPt++];
        }

        public override ObjectId ReadHardPointerId()
        {
            if (HardPointerIdList.Count() == 0)
            {
                return new ObjectId();
            }
            return HardPointerIdList[HardPointerIdListPt++];
        }

        public override short ReadInt16()
        {
            if (Int16List.Count() == 0)
            {
                return 0;
            }
            return Int16List[Int16ListPt++];
        }

        public override int ReadInt32()
        {
            if (Int32List.Count() == 0)
            {
                return 0;
            }
            return Int32List[Int32ListPt++];
        }

#if !NET35
        public override long ReadInt64()
        {
            if (Int64List.Count() == 0)
            {
                return 0;
            }
            return Int64List[Int64ListPt++];
        }
#endif

        public override Point2d ReadPoint2d()
        {
            if (Point2dList.Count() == 0)
            {
                return new Point2d();
            }
            return Point2dList[Point2dListPt++];
        }

        public override Point3d ReadPoint3d()
        {
            if (Point3dList.Count() == 0)
            {
                return new Point3d();
            }
            return Point3dList[Point3dListPt++];
        }

        public override Scale3d ReadScale3d()
        {
            if (Scale3dList.Count() == 0)
            {
                return new Scale3d();
            }
            return Scale3dList[Scale3dListPt++];
        }

        public override ObjectId ReadSoftOwnershipId()
        {
            if (SoftOwnershipIdList.Count() == 0)
            {
                return new ObjectId();
            }
            return SoftOwnershipIdList[SoftOwnershipIdListPt++];
        }

        public override ObjectId ReadSoftPointerId()
        {
            if (SoftPointerIdList.Count() == 0)
            {
                return new ObjectId();
            }
            return SoftPointerIdList[SoftPointerIdListPt++];
        }

        public override string ReadString()
        {
            if (StringList.Count() == 0)
            {
                return null;
            }
            return StringList[StringListPt++];
        }

        public override ushort ReadUInt16()
        {
            if (Uint16List.Count() == 0)
            {
                return 0;
            }
            return Uint16List[uint16ListPt++];
        }

        public override uint ReadUInt32()
        {
            if (Uint32List.Count() == 0)
            {
                return 0;
            }
            return Uint32List[uint32ListPt++];
        }

#if !NET35
        public override ulong ReadUInt64()
        {
            if (Uint64List.Count() == 0)
            {
                return 0;
            }
            return Uint64List[uint64ListPt++];
        }
#endif

        public override Vector2d ReadVector2d()
        {
            if (Vector2dList.Count() == 0)
            {
                return new Vector2d();
            }
            return Vector2dList[Vector2dListPt++];
        }

        public override Vector3d ReadVector3d()
        {
            if (Vector3dList.Count() == 0)
            {
                return new Vector3d();
            }
            return Vector3dList[Vector3dListPt++];
        }

        public override void ResetFilerStatus()
        {
            AddressList.Clear();
            AddressListPt = 0;
            BinaryChunkList.Clear();
            BinaryChunkListPt = 0;
            BooleanList.Clear();
            BooleanListPt = 0;
            ByteList.Clear();
            ByteListPt = 0;
            BytesList.Clear();
            BytesListPt = 0;
            DoubleList.Clear();
            DoubleListPt = 0;
            HandleList.Clear();
            HandleListPt = 0;
            HardOwnershipIdList.Clear();
            HardOwnershipIdListPt = 0;
            HardPointerIdList.Clear();
            HardPointerIdListPt = 0;
            Int16List.Clear();
            Int16ListPt = 0;
            Int32List.Clear();
            Int32ListPt = 0;
#if !NET35
            Int64List.Clear();
            Int64ListPt = 0;
#endif
            Point2dList.Clear();
            Point2dListPt = 0;
            Point3dList.Clear();
            Point3dListPt = 0;
            Scale3dList.Clear();
            Scale3dListPt = 0;
            SoftOwnershipIdList.Clear();
            SoftOwnershipIdListPt = 0;
            SoftPointerIdList.Clear();
            SoftPointerIdListPt = 0;
            StringList.Clear();
            StringListPt = 0;
            Uint16List.Clear();
            uint16ListPt = 0;
            Uint32List.Clear();
            uint32ListPt = 0;
#if !NET35
            Uint64List.Clear();
            uint64ListPt = 0;
#endif
            Vector2dList.Clear();
            Vector2dListPt = 0;
            Vector3dList.Clear();
            Vector3dListPt = 0;

            m_FilerType = FilerType.CopyFiler;
        }

        public override void Seek(
#if AC2008 || AC2009
        int
#else
        long
#endif
         offset, int method)
        {
            Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage(MethodInfo.GetCurrentMethod().Name + " = " + " \n ");
        }

        public override void WriteAddress(IntPtr value)
        {
            AddressList.Add(value);
        }

        public override void WriteBinaryChunk(byte[] chunk)
        {
            BinaryChunkList.Add(chunk);
        }

        public override void WriteBoolean(bool value)
        {
            BooleanList.Add(value);
        }

        public override void WriteByte(byte value)
        {
            ByteList.Add(value);
        }

        public override void WriteBytes(byte[] value)
        {
            BytesList.Add(value);
        }

        public override void WriteDouble(double value)
        {
            DoubleList.Add(value);
        }

        public override void WriteHandle(Handle handle)
        {
            HandleList.Add(handle);
        }

        public override void WriteHardOwnershipId(ObjectId value)
        {
            HardOwnershipIdList.Add(value);
        }

        public override void WriteHardPointerId(ObjectId value)
        {
            HardPointerIdList.Add(value);
        }

        public override void WriteInt16(short value)
        {
            Int16List.Add(value);
        }

        public override void WriteInt32(int value)
        {
            Int32List.Add(value);
        }

#if !NET35
        public override void WriteInt64(long value)
        {
            Int64List.Add(value);
        }
#endif
        public override void WritePoint2d(Point2d value)
        {
            Point2dList.Add(value);
        }

        public override void WritePoint3d(Point3d value)
        {
            Point3dList.Add(value);
        }

        public override void WriteScale3d(Scale3d value)
        {
            Scale3dList.Add(value);
        }

        public override void WriteSoftOwnershipId(ObjectId value)
        {
            SoftOwnershipIdList.Add(value);
        }

        public override void WriteSoftPointerId(ObjectId value)
        {
            SoftPointerIdList.Add(value);
        }

        public override void WriteString(string value)
        {
            StringList.Add(value);
        }

        public override void WriteUInt16(ushort value)
        {
            Uint16List.Add(value);
        }

        public override void WriteUInt32(uint value)
        {
            Uint32List.Add(value);
        }

#if !NET35
        public override void WriteUInt64(ulong value)
        {
            Uint64List.Add(value);
        }
#endif

        public override void WriteVector2d(Vector2d value)
        {
            Vector2dList.Add(value);
        }

        public override void WriteVector3d(Vector3d value)
        {
            Vector3dList.Add(value);
        }

        public override string ToString()
        {
            int ptCount = AddressListPt +
                          BinaryChunkListPt +
                          BooleanListPt +
                          ByteListPt +
                          BytesListPt +
                          DoubleListPt +
                          HandleListPt +
                          HardOwnershipIdListPt +
                          HardPointerIdListPt +
                          Int16ListPt +
                          Int32ListPt +
#if !NET35
                          Int64ListPt +
#endif
                          Point2dListPt +
                          Point3dListPt +
                          Scale3dListPt +
                          SoftOwnershipIdListPt +
                          SoftPointerIdListPt +
                          StringListPt +
                          uint16ListPt +
                          uint32ListPt +
#if !NET35
                          uint64ListPt +
#endif
                          Vector2dListPt +
                          Vector3dListPt;

            int ltCount = AddressList.Count() +
                          BinaryChunkList.Count() +
                          BooleanList.Count() +
                          ByteList.Count() +
                          BytesList.Count() +
                          DoubleList.Count() +
                          HandleList.Count() +
                          HardOwnershipIdList.Count() +
                          HardPointerIdList.Count() +
                          Int16List.Count() +
                          Int32List.Count() +
#if !NET35
                          Int64List.Count() +
#endif
                          Point2dList.Count() +
                          Point3dList.Count() +
                          Scale3dList.Count() +
                          SoftOwnershipIdList.Count() +
                          SoftPointerIdList.Count() +
                          StringList.Count() +
                          Uint16List.Count() +
                          Uint32List.Count() +
#if !NET35
                          Uint64List.Count() +
#endif
                          Vector2dList.Count() +
                          Vector3dList.Count();

            return "\nDataIn::" + ptCount + "\nDataOut::" + ltCount;
        }
    }
}

(完)

posted @ 2019-10-01 03:02  惊惊  阅读(4050)  评论(1编辑  收藏  举报