Hello,
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 Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt(); 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,
JM
Solved! Go to Solution.
Solved by _gile. Go to Solution.
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).
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,
JM
Hi,
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:
http://forums.autodesk.com/t5/AutoCAD-Francais/c-probl%C3%A8me-de-zoom/m-p/3735892#M37354