Is it possible to view the output drawing as I debug?

Is it possible to view the output drawing as I debug?

Anonymous
Not applicable
695 Views
2 Replies
Message 1 of 3

Is it possible to view the output drawing as I debug?

Anonymous
Not applicable

Folks, I am just getting started with Autocad .net api integration. I have been provided with a large chunk of code. In a high level overview it draws circles, hashes them, trims the circles at some points etc.. I am able to debug the lines of code via the Visual studio. In my case as I am trying to understand the code written by the previous developer, is it possible for me to see the output of drawing as I debug line by line to understand? 

 

Could you also point me to some references on how to see the different instructions sent from my c# to Autocad? some sort of profiler?

 

 

Accepted solutions (2)
696 Views
2 Replies
Replies (2)
Message 2 of 3

mujibur.rahman
Enthusiast
Enthusiast
Accepted solution

transaction need to be committed and also entity need to be appended to database to see the changes that we are making....
so,
1. append the entity to the database if any thing newly created....
2.commit the transaction
3.finally exit the sub to see the changes

if nothing is added then just commit transaction after a command and then exit sub

 

i hope this helps...
pls accept solution if this helps

0 Likes
Message 3 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

You can force the graphic changes to display within a transaction within a single transaction before committing it with the TransactionManager.QueueForGraphicsFlush method.

 

Here's a simple using example:

[CommandMethod("TEST")]
public static void Test()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
    var ed = doc.Editor;

    var ppr = ed.GetPoint("\nSpecify the center: ");
    if (ppr.Status != PromptStatus.OK)
        return;

    var center = ppr.Value;
    var pdo = new PromptDistanceOptions("\nSpecify the radius or hit Enter to quit: ");
    pdo.AllowNone = true;
    pdo.AllowZero = false;
    pdo.AllowNegative = false;
    pdo.BasePoint = center;
    pdo.UseBasePoint = true;

    using (var tr = db.TransactionManager.StartTransaction())
    {
        var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
        // loop while the user specify a distance
        while (true)
        {
            var pdr = ed.GetDistance(pdo);

            // user cancells => rollback and exit
            if (pdr.Status == PromptStatus.Cancel)
                return;

            // user hits "Enter" => break the loop
            if (pdr.Status == PromptStatus.None)
                break;

            // user specify a distance => create a new  circle
            var circle = new Circle() { Center = center, Radius = pdr.Value };
            circle.TransformBy(ed.CurrentUserCoordinateSystem);
            curSpace.AppendEntity(circle);
            tr.AddNewlyCreatedDBObject(circle, true);

            // display the newly created circle
            db.TransactionManager.QueueForGraphicsFlush();
        }
        tr.Commit();
    }
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub