Is it possible to create a model space view port in a dialog box?
Where I could move / pan / select objects within the viewport that resides in dialog box?
yep, see https://adndevblog.typepad.com/autocad/2022/11/blockview-sample-refactored.html
I've done something similar in a palette
Thank you @daniel_cadext . This was so useful. With this, I finished doing a Proof of Concept version my addIn.
I made a floating dialog box of the present graphics view. And I made it to move with cursor. I did with a modeless dialog box.
But I stumbled upon major issue. After debugging step by step, I saw that the lockDocument method was creating a major issue. When I ran the command, it creates endless UNDO markers. I mean after issuing my command, although the dialog box shows up and control is given back to commandline, whenever I move the mouse, there is a lockDocument called and it is marked as a "Undo"able task. So I end up with so many markers.
Code snipped beolow:
AcApDocument* pDoc = acDocManager->document(pDb);
acDocManager->setCurDocument(pDoc);
acDocManager->lockDocument(pDoc);
If I remove the lockDocument (and its unlockDocument), the code still works without issue.
So my questions is, is it necessary to "lockDocument" if I don't intend to change anything in the document? What are the risks?
Thanks
Lock is normally only needed for write operations, or maybe to prevent a document switch.
I like to use AcAxDocLock in this case
Thx @daniel_cadext . I'll try AcAxDocLock.
But I would like to know where I can find more info about relationship between "lockDocument" method & "Undo". I want to why this approach did not work in the first place.
Where can I find complete documentation about "Undo" in a ObjectArx context?
-Thanks
You may want to think hard for why you use modeless UI to show drawing specific data (be it textual data or graphic data).
Showing modeless UI means user can do whatever/interact with the current drawing, or even switch the current drawing. What if user changes the data in the current drawing that was captured in your modeless UI? or, if user goes to another drawing, do your modeless UI update accordingly? The modeless UI supposedly runs in application context, not need to lock document. Only when user interaction from the modeless UI is to make changes to the current, you need to lock the document right prior the changes are to apply. better yet, the changes initiated from the modeless UI is to be wrapped as a command, so the document locking is automatically applied by the command, and the action is undoable.
Norman Yuan
thanks @norman.yuan . The modeless UI update itself all time to reflect the drawing content. And communication is one way. I mean info flow only from dwg-> modeless not otherwise. When the user switches, the modeless UI will reflect the active drawing info.
My main concern is that, if I read the "viewport" info of the drawing without locking it, is there a chance the autocad application will crash on me?
-Thx
personally, I lock the document anytime my palette or modeless dialog interacts with a document or database, like this sample where I generate block previews, https://github.com/CEXT-Dan/PyRx?tab=readme-ov-file#features. Even though I’m only reading data, I still want to protect against document switching something else. I don’t worry about undo in read only mode, I only think about that when I’m writing to the database. I usually use beginExecuteInCommandContext or something that sets an undo point
Can't find what you're looking for? Ask the community or share your knowledge.