Valued Contributor
Posts: 94
Registered: ‎01-03-2007
Message 1 of 4 (240 Views)
Accepted Solution

How updating currentview ?

240 Views, 3 Replies
12-14-2012 11:07 AM



Developping an application, I have a problem with, I Think, the currentview.


What is needed ?

The user need to select texts in the drawing and, one after the other, these points have to be subjected to a treatment.


How do I developped the applications?

The application contents a while to know if the user pressed the escape button.

While escape is not pressed, I select the text by the following code

static public TopocomPoint PointSelection(string commandLineText)
            TopocomPoint topocomPoint = null;

            //Récupère le document courant et sa base de données
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            //Récupération de l'éditeur de la base de données courante
            Editor ed = acDoc.Editor;

            //Démarre une nouvelle transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                //Création d'un filtre pour récupérer uniquement les textes
                TypedValue[] acFilList = new TypedValue[1] { new TypedValue((int)DxfCode.Start, "TEXT") };
                SelectionFilter acFilter = new SelectionFilter(acFilList);
                PromptSelectionOptions acPSOpts = new PromptSelectionOptions();
                acPSOpts.MessageForAdding = commandLineText;
                acPSOpts.SingleOnly = true;

                //Sélection des textes
                PromptSelectionResult acPSResPoint = ed.GetSelection(acPSOpts, acFilter);

                //Si la sélection a réussi
                if (acPSResPoint.Status == PromptStatus.OK)
                    SelectionSet acSSetPoint = acPSResPoint.Value;
                    ObjectId[] acIdsPoint = acSSetPoint.GetObjectIds();
                    for (int i = 0; i < acIdsPoint.Length; i++)
                        //Récupération de l'objet texte saisi
                        DBText acTextPoint = (DBText)acTrans.GetObject(acIdsPoint[i], OpenMode.ForRead);
                        //Récupération des données du Texte saisi
                        Point3d textPoint = acTextPoint.Position;
                        topocomPoint = new TopocomPoint(acTextPoint.TextString.TrimStart(), 0, textPoint.X, textPoint.Y, textPoint.Z);
                else if (acPSResPoint.Status == PromptStatus.Cancel)
                    //Revenir à une nouvelle ligne de commande
                    StopAsked = true;
            return topocomPoint;


In that selection the user can pan, zoom, etc ... in the drawing to select a text.

returned in the while the text is treated.


The application works but that currentview problem.


What's my problem?

The ed.GetCurrentView() seems to be alway the same.

When the user zoom, pan, ... and select a text, the view return to the position at the start of the application however document, database and editor are loaded at each text selection.


What do I need to do?

If the user zoom, pan, ... and select a text, the view stay at that position when the text is selected.


What do I remarks?

ed.GetCurrentView().CenterPoint.X and .CenterPoint.Y stay the same throughout the application runs.


From my point of view, the ed.GetCurrentView() must be updated to fit with the actual drawing view.

But how to do this ?


Thanks for your advices,



*Expert Elite*
Posts: 986
Registered: ‎04-27-2009
Message 2 of 4 (225 Views)

Re: How updating currentview ?

12-14-2012 02:02 PM in reply to: Jean-Marc68

You can create a temporary view (named view) that save your current screen view, right before you let user do the selection, during which the user may pan and zoom in/out. After the user is done the selection, you restore the saved view. You continue this user selecting->restoring to the view when selecting is started process until user completes the selection. Then you can delete the saved view.


In .NET API, you do this by manlpulating VewTableRecord class (creating, setting it to current and deleting).

Valued Contributor
Posts: 94
Registered: ‎01-03-2007
Message 3 of 4 (207 Views)

Re: How updating currentview ?

12-15-2012 03:39 PM in reply to: norman.yuan

Thanks for your answer norman.yuan, but it's exactely the opposit.

When the user have made the selection, the view return to the precedent one. I need the view stay where it was zoomed, paned by the user during the selection.

When I ask the view infos just after the select, I saw the views infos are extely the same as before the selection, however the user had zoom in/out or pan during the selection.


Thanks for advices,


*Expert Elite*
Posts: 2,082
Registered: ‎04-29-2006
Message 4 of 4 (198 Views)

Re: How updating currentview ?

12-16-2012 01:47 AM in reply to: Jean-Marc68



I think this is due to the fact you do not commit the transaction so it 'is rolled back (Undone).


I purpose you another implementation (better IMO) on the French discussion group:


Gilles Chanteau
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.