<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: After Mirroring Entity with XData, XData lost in new Entity? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122647#M17371</link>
    <description>&lt;P&gt;It looks like GetTransfomedCopy does not deep clone block references. Tou should use Database.DeepCloneObjects instead.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        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;
        }&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 02 Mar 2021 06:26:07 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2021-03-02T06:26:07Z</dc:date>
    <item>
      <title>After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10118008#M17365</link>
      <description>&lt;P&gt;Hi,all:&lt;/P&gt;&lt;P&gt;I want to mirror an entity with XData,&lt;/P&gt;&lt;P&gt;But after mirroring, the new entity has no XData.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the method,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone tell me whether there is an easy way to reallize it?&lt;/P&gt;&lt;LI-CODE lang="general"&gt;		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;
		}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2021 08:00:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10118008#M17365</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2021-02-28T08:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10118240#M17366</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;The code you show should work, the issue you have may come from elsewhere in your plugin.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2021 11:20:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10118240#M17366</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-02-28T11:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10119688#M17367</link>
      <description>&lt;P&gt;Hi,Gile:&lt;/P&gt;&lt;P&gt;I tried with the following code, but failed.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;    [CommandMethod("COOO")]
    public static void COOO()
    {
      Database db = HostApplicationServices.WorkingDatabase;
      Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
      using (Transaction trans = db.TransactionManager.StartTransaction())
      {
        Point3d ptMirr1 = new Point3d();
        Point3d ptMirr2 = ptMirr1.dPolar(90, 100);
				PromptEntityResult per= ed.GetEntity("Select a ref with xdata:");
				if (per.Status!=PromptStatus.OK)
				{
					return;
				}
        per.ObjectId.Mirror(ptMirr1, ptMirr2, false);
        trans.Commit();
      }
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Mar 2021 06:34:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10119688#M17367</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2021-03-01T06:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10121333#M17368</link>
      <description>&lt;P&gt;Works for me.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 18:22:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10121333#M17368</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-03-01T18:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10121586#M17369</link>
      <description>&lt;P&gt;Well, in your original post and this reply, your code uses custom extension method (Database.AddToCurrentSpace() and ObjectId.Mirror()). Since no one knows how the extension methods are implemented, the code would not help here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the ARX/.NET API document, Entity.GetTransformedCopy() method is basically the same as doing 2 calls in one step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var newEntity = TheEntity.Clone()/DeepClone();&lt;/P&gt;
&lt;P&gt;newEntity.TransformBy();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to consult the ARX API document for this method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, entities derived from Entity would call Clone() method usually, but it is up to the derived object's implementation to decide to use Clone() or DeepClone(), or even does not do cloning at all. Since you did not say what type of entity you are working against, it is hard to say what is happening (you did left a vague hint when asking user to pick an entity by "Select a ref with XData", where "ref" implies the entity may not be a regular/simple entity (Line, Circle...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested calling GetTransformedCopy() with simple entity (Circle, Line, Polyline), which has XData attached. And yes, the newly cloned and transformed entity does have the same XData, as its source entity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 19:45:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10121586#M17369</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2021-03-01T19:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122608#M17370</link>
      <description>&lt;P&gt;Hi,Giles,Yuan,&lt;/P&gt;&lt;P&gt;My ref. means block reference.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 05:53:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122608#M17370</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2021-03-02T05:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122647#M17371</link>
      <description>&lt;P&gt;It looks like GetTransfomedCopy does not deep clone block references. Tou should use Database.DeepCloneObjects instead.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        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;
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 02 Mar 2021 06:26:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122647#M17371</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-03-02T06:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: After Mirroring Entity with XData, XData lost in new Entity?</title>
      <link>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122886#M17372</link>
      <description>&lt;P&gt;THANKS A LOT GILES AND YUAN.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 08:31:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/after-mirroring-entity-with-xdata-xdata-lost-in-new-entity/m-p/10122886#M17372</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2021-03-02T08:31:34Z</dc:date>
    </item>
  </channel>
</rss>

