• AutoCAD.Net/C#.Net QQ群:193522571 镜像mirror后原来块实体中的XDATA丢失了?


    更多讨论请加我的QQ群:193522571

    下面代码是我前面的代码,发现对于块参照,镜像后,XDATA中会丢失!

            public static ObjectId Mirror(this ObjectId id, Point3d mirrorPt1, Point3d mirrorPt2, bool eraseSourceObject)
            {
                Line3d miLine = new Line3d(mirrorPt1, mirrorPt2);
                Matrix3d mt = Matrix3d.Mirroring(miLine);
                ObjectId mirrorId = id;
                Entity ent = (Entity)id.GetObject(OpenMode.ForWrite);
                if (eraseSourceObject == true)
                    ent.TransformBy(mt);
                else
                {
                    Entity entCopy = ent.GetTransformedCopy(mt);
                    mirrorId = id.Database.AddToCurrentSpace(entCopy);
                }
                return mirrorId;
            }

    下面代码增加了深度克隆deepclone,然后再进行矩阵转换就不会发生丢失了!

            public static ObjectId Mirror(this ObjectId id, Point3d mirrorPt1, Point3d mirrorPt2, bool eraseSourceObject)
            {
                Line3d miLine = new Line3d(mirrorPt1, mirrorPt2);
                Matrix3d mt = Matrix3d.Mirroring(miLine);
                ObjectId mirrorId = id;
                Entity ent = (Entity)id.GetObject(OpenMode.ForWrite);
                Database db = id.Database;
                if (!eraseSourceObject)
                {
                    var ids = new ObjectIdCollection();
                    ids.Add(id);
                    var mapping = new IdMapping();
                    db.DeepCloneObjects(ids, db.CurrentSpaceId, mapping, false);
                    mirrorId = mapping[id].Value;
                }
                ent.TransformBy(mt);
                return mirrorId;
            }
  • 相关阅读:
    shiro什么时候会进入doGetAuthorizationInfo(PrincipalCollection principals)
    Kali2安装完成后的设置
    Springboot打包war
    2017总结及2018计划
    gitlab数据库
    Entity Framework学习
    从零开始编写操作系统——bochs
    Docker基本操作
    Jenkins打包安卓时提示没同意constraintLayout的license的解决方法
    env:bash 解决
  • 原文地址:https://www.cnblogs.com/swtool/p/14491133.html
Copyright © 2020-2023  润新知