<?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: Ctrl-Z behavior in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498086#M5955</link>
    <description>&lt;P&gt;The approach I'll be taking is more like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawingHelper.StartTransaction(); // Lock and start a new transaction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawingHelper.DrawLine(...);&lt;/P&gt;&lt;P&gt;DrawingHelper.DrawBox(...);&lt;/P&gt;&lt;P&gt;DrawingHelper.DrawCircle(...);&lt;/P&gt;&lt;P&gt;DrawingHelper. Draw...(...);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawingHelper.CloseTrasaction();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm almost done now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2024 19:38:56 GMT</pubDate>
    <dc:creator>alain.holloway</dc:creator>
    <dc:date>2024-01-15T19:38:56Z</dc:date>
    <item>
      <title>Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12495827#M5945</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've added some RibbonButton that insert multiple entities in the drawing database, all these entities are then grouped together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When CTRL-Z is clicked after the previous action, everything gets removed entity by entity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I just remove the group on a ctrl-z and not all entities one by one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2024 11:32:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12495827#M5945</guid>
      <dc:creator>alain.holloway</dc:creator>
      <dc:date>2024-01-14T11:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12496517#M5946</link>
      <description>&lt;P dir="ltr"&gt;Your question is very limited in that you do not describe how you are inserting the entities. Is it through code? If so then you need to show that code. We cannot guess about how you are inserting the objects and what you may or may not be doing right.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 02:34:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12496517#M5946</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-15T02:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497213#M5947</link>
      <description>&lt;P&gt;Code example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say this one here, a DrawBox() function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline plBox = new Polyline(4)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Closed = true,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Layer = layer,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Normal = Vector3d.ZAxis,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;LineWeight = LineWeight.ByLayer&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;plBox.AddVertexAt(0, new Point2d(startPoint.X, startPoint.Y), 0.0, 1.0, 1.0);&lt;BR /&gt;Point3d endPoint = AcadTools.CalculateEndPoint(startPoint, length, orientationDepart);&lt;BR /&gt;plBox.AddVertexAt(1, new Point2d(endPoint.X, endPoint.Y), 0.0, 1.0, 1.0);&lt;BR /&gt;endPoint = AcadTools.CalculateEndPoint(endPoint, width, MathTools.AddAngle(orientationDepart, 90));&lt;BR /&gt;plBox.AddVertexAt(2, new Point2d(endPoint.X, endPoint.Y), 0.0, 1.0, 1.0);&lt;BR /&gt;endPoint = AcadTools.CalculateEndPoint(endPoint, length, MathTools.AddAngle(orientationDepart, 180));&lt;BR /&gt;plBox.AddVertexAt(3, new Point2d(endPoint.X, endPoint.Y), 0.0, 1.0, 1.0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;btr.AppendEntity(plBox);&lt;BR /&gt;Tx.AddNewlyCreatedDBObject(plBox, true);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group.AppendEntity(plBox.ObjectId);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you call the DrawBox() routine multiple times passing it the same Group..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawBox(Group1, StartPoint1, ...);&lt;/P&gt;&lt;P&gt;DrawBox(Group1, StartPoint2, ...);&lt;/P&gt;&lt;P&gt;DrawBox(Group1, StartPoint3, ...);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then CTRL-Z (_u), each of the polylines added will be removed one by one, I would like to remove all of them at once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be easy if the entities where be added to the group and then the group added to the database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I doing something wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 11:55:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497213#M5947</guid>
      <dc:creator>alain.holloway</dc:creator>
      <dc:date>2024-01-15T11:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497787#M5948</link>
      <description>&lt;P&gt;It looks like you only posted part of the function that you call Drawbox(), because I do not see any reference to a transaction starting or ending.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately the parts that you omitted are relevant. When posting code in a message please use the insert code button on the toolbar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 16:56:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497787#M5948</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-15T16:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497817#M5949</link>
      <description>&lt;LI-CODE lang="general"&gt;internal static Polyline DrawBox(Database db, Group autocadGroup, string layer, Point3d startPoint, double length, double width, double orientationDepart, bool drawHatch, byte transparency = 0)
        {
            Polyline plBox = default;

            AcadTools.AddLayerFromDatabase(layer);

            using (DocumentLock docLock = NewGeboCAD.AcDoc.LockDocument())
            {
                using (Transaction Tx = db.TransactionManager.StartTransaction())
                {
                    ObjectId ModelSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(db);
                    BlockTableRecord btr = Tx.GetObject(ModelSpaceId, OpenMode.ForWrite) as BlockTableRecord;

                    plBox = new Polyline(4)
                    {
                        Closed = true,
                        Layer = layer,
                        Normal = Vector3d.ZAxis,
                        LineWeight = LineWeight.ByLayer
                    };

                    plBox.AddVertexAt(0, new Point2d(startPoint.X, startPoint.Y), 0.0, 1.0, 1.0);
                    Point3d endPoint = AcadTools.CalculateEndPoint(startPoint, length, orientationDepart);
                    plBox.AddVertexAt(1, new Point2d(endPoint.X, endPoint.Y), 0.0, 1.0, 1.0);
                    endPoint = AcadTools.CalculateEndPoint(endPoint, width, MathTools.AddAngle(orientationDepart, 90));
                    plBox.AddVertexAt(2, new Point2d(endPoint.X, endPoint.Y), 0.0, 1.0, 1.0);
                    endPoint = AcadTools.CalculateEndPoint(endPoint, length, MathTools.AddAngle(orientationDepart, 180));
                    plBox.AddVertexAt(3, new Point2d(endPoint.X, endPoint.Y), 0.0, 1.0, 1.0);

                    ObjectId pLineId = btr.AppendEntity(plBox);
                    Tx.AddNewlyCreatedDBObject(plBox, true);

                    ObjectIdCollection ObjIds = new ObjectIdCollection { pLineId };
                    Hatch oHatch = default;

                    if (drawHatch)
                    {
                        oHatch = new Hatch();

                        Vector3d normal = new Vector3d(0.0, 0.0, 1.0);

                        oHatch.Transparency = new Autodesk.AutoCAD.Colors.Transparency((byte)transparency);

                        oHatch.Normal = normal;
                        oHatch.Elevation = 0.0;
                        oHatch.PatternScale = 1.0;
                        oHatch.Layer = layer;
                        oHatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");

                        btr.AppendEntity(oHatch);

                        Tx.AddNewlyCreatedDBObject(oHatch, true);

                        oHatch.Associative = true;

                        oHatch.AppendLoop((int)HatchLoopTypes.Default, ObjIds);
                        oHatch.EvaluateHatch(true);
                    }

                    autocadGroup.AppendEntity(plBox.ObjectId);

                    if (drawHatch) autocadGroup.AppendEntity(oHatch.ObjectId);

                    Tx.Commit();

                    if (drawHatch) AcadTools.SetDrawOrder(oHatch, eDrawOrder.Bottom);
                }
            }

            return plBox;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sory about that, here is the full code to DrawBox() function&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 17:14:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497817#M5949</guid>
      <dc:creator>alain.holloway</dc:creator>
      <dc:date>2024-01-15T17:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497961#M5950</link>
      <description>&lt;P&gt;There is a separate undo of each object created because each time you create one object you start and end a transaction, which creates the equivalent of an undo group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To solve that problem you need to decouple the code that draws the objects from the code that starts and commits the transaction and locks/unlocks the document.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 18:33:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497961#M5950</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-15T18:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497972#M5951</link>
      <description>&lt;P&gt;That makes sense, so, if I did understand correctly, I should first lock the document, open a new transaction, happen entities in the database / transaction and then commit the transaction when completed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 18:38:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12497972#M5951</guid>
      <dc:creator>alain.holloway</dc:creator>
      <dc:date>2024-01-15T18:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498006#M5952</link>
      <description>&lt;P&gt;Yes, there should only be one transaction and one document lock And while they are active you can draw any number of objects, and all of them will be undone as a group&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 18:55:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498006#M5952</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-15T18:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498015#M5953</link>
      <description>&lt;P&gt;Wow ok great,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lot's of changes in my code, I will try this now and let you know of the results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you my friend &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 18:58:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498015#M5953</guid>
      <dc:creator>alain.holloway</dc:creator>
      <dc:date>2024-01-15T18:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498054#M5954</link>
      <description>&lt;P&gt;The changes aren't really that extensive. You just need to remove the code that starts and commits the transaction and locks and unlocks the document from the method that draws the objects. Then, pass a transaction into that method as an argument , that it can use to draw the objects.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 19:22:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498054#M5954</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-15T19:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Ctrl-Z behavior</title>
      <link>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498086#M5955</link>
      <description>&lt;P&gt;The approach I'll be taking is more like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawingHelper.StartTransaction(); // Lock and start a new transaction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawingHelper.DrawLine(...);&lt;/P&gt;&lt;P&gt;DrawingHelper.DrawBox(...);&lt;/P&gt;&lt;P&gt;DrawingHelper.DrawCircle(...);&lt;/P&gt;&lt;P&gt;DrawingHelper. Draw...(...);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DrawingHelper.CloseTrasaction();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm almost done now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 19:38:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/ctrl-z-behavior/m-p/12498086#M5955</guid>
      <dc:creator>alain.holloway</dc:creator>
      <dc:date>2024-01-15T19:38:56Z</dc:date>
    </item>
  </channel>
</rss>

