Author Topic: Updating model space display extents  (Read 9808 times)

0 Members and 1 Guest are viewing this topic.

pkohut

  • Guest
Re: Updating model space display extents
« Reply #15 on: March 19, 2010, 11:35:56 PM »
Below I am posting my code as it stands and a LISP snippet that shows how the ARX will be used.  If you try it you will see the problem.

Can you post a VC project with the minimal amount of code that demonstrates the problem.  Also, what system variable do you think are suspect?

pkohut

  • Guest
Re: Updating model space display extents
« Reply #16 on: March 20, 2010, 12:42:30 AM »
1. The first MYVIEW call and autocad with two documents open and noticed the results (using your original code and also the other one by Paul).
2. Second call of MYVIEW and a single document open.
3. Third call of MYVIEW and single document open and the code below - if I use the zoomExtents() function inside the arx it does the zoom, the one from the lisp not.

Clarify, are you saying that the ARX call of zoomExtents() *always works* and the one called in lisp does not?  I watched the GIF but could not follow what you are trying to show.  What are the pass fail results for items 1, 2, 3?  Sorry for being dense here, maybe it cause I finally read the whole thread carefully, have not tested any code, and am still confused.

LE3

  • Guest
Re: Updating model space display extents
« Reply #17 on: March 20, 2010, 11:35:40 AM »
-The zoomExtents() (posted on reply#9) is a custom made function and it was used in of the tests and after changing the document view size it does a full zoom extents, if you try the code in the lisp after the view size change it is using the built-in zoom extents and that one (at least here it simple does not do an extents).

-On item one, if you have two documents open, and then the arx routine it is called, it won't paint the title bar of the changed doc view, nor the upper right corner icons/buttons.

-On item two, if is there a single doc open and the arx routine it is called it happen the same, but also the full previous view (maximized) it won't be repaint, so the background on autocad will still have the same view twice.
-On the third one, it does the repaint and avoids the previous issues mentioned above, the only issue still is that if the built-in zoom extents command it is used from the lisp routine it won't do it right.

-On fourth - I am like you confused too.

1. The first MYVIEW call and autocad with two documents open and noticed the results (using your original code and also the other one by Paul).
2. Second call of MYVIEW and a single document open.
3. Third call of MYVIEW and single document open and the code below - if I use the zoomExtents() function inside the arx it does the zoom, the one from the lisp not.

Clarify, are you saying that the ARX call of zoomExtents() *always works* and the one called in lisp does not?  I watched the GIF but could not follow what you are trying to show.  What are the pass fail results for items 1, 2, 3?  Sorry for being dense here, maybe it cause I finally read the whole thread carefully, have not tested any code, and am still confused.

pkohut

  • Guest
Re: Updating model space display extents
« Reply #18 on: March 20, 2010, 12:14:10 PM »
How about letting your routine sleep for a millisecond so the OS and potentially Autocad has a time slice to make some screen updates?

shawndoe

  • Guest
Re: Updating model space display extents
« Reply #19 on: March 20, 2010, 07:15:24 PM »
Hi,

The two screen shots I posted were a before and an after of just the ARX SetWindow() and zoomExtents().  I believe that if we get it to work in the ARX it will work when you zoom from the LISP. 

Really beyond the code posted everything else is an out of the box ObjectArx Wizard setup with MFC support.  I'm running 2010 and Visual Studio 2008 Pro on a fresh XP machine.  I can post my LISP code, but really I don't think it is the issue,  the snippet I post uses a Zoom Extents in place of the third party publish function (Tririga Cad Integrator if anybodies interested) the results are the same. 

The publish function zooms to extents in the drawing window, creates a DWF of the display, then attaches a bunch of database links to the DWF, and finally uploads it to our server.  At the root of this is a need to get the aspect ratio of the client window the same as the titleblock, so I don't have any dead space around edges of the DWF throwing off the scale.

(1)  I had not noticed the lose of the window buttons on the title bar from the LISP, but I wasn't looking so might have missed it.  I'll check on that when I'm back in front of my machine at work, unfortunately my remote access is down. 

(2)  I didn't see that, but I run with Drawing1 in the background most of the time.  I'll check that as well.  I did see that when I sized the client window directly instead of the frame.

(3)  I was looking at the zoomExtents() results and I don't think it does zoom properly.  A section on top and bottom seemed cut off to me.  It's as if it shifts the old window view and centers it in the new window. 

(4)  I'm pretty confused my self, I'm just used to it.   :-D  It's like there is a buffer that is loaded from the system variables at the start of a routine be it LISP, VBA or ARX, and it is not updated when the system variables change.  As a result we can change system variables like VIEWSIZE, but the buffer data remains unchanged.  When you reach the command prompt the buffer is flushed, or refreshed at the start of the next operation.  We need to find a refresh the data in that buffer with the new values.  That's why I had such high hopes for Paul's enableGraphicFlush().

I don't think a time delay will do anything, I have tried that in LISP and VBA.

Thanks again for your efforts, and have a good weekend.
Shawn

frtfff

  • Bull Frog
  • Posts: 215
Re: Updating model space display extents
« Reply #20 on: March 21, 2010, 08:49:30 AM »
Good code. :kewl:

shawndoe

  • Guest
Re: Updating model space display extents
« Reply #21 on: March 23, 2010, 05:09:22 PM »
OK,

Really? good code...  :P  Posting the full project is embarrassing it reveals just what a noob I am at ARX.  Never the less the full project is posted.  All my code resides in acrxEntryPoint.cpp, and has been redone with subfunctions.  I added some diagnostic functions, as I have yet to be able to run in debug without a complete lock up or fatal error from AutoCAD.  The code compiles with no errors or warnings.

Might as well a formating lessons now.  Should my code be in a separate file included in the acrxEntryPoint, or is where it is correct?  It feels like it should be elsewhere.

I've spent some time trying to research the problem a bit more, and I was checking out the acgs class.  I found acgsGetDisplayInfo(), it returns the drawingWidth, and drawingHeight, as well as aspect ratio for the display Frame.  Its values are the same as held in the screeensize sysvar.  If you look at the results of a run you will see that after the drawing window is resized, the drawingHeight, and drawingWidth remain unchanged.

I have yet to find a way to change that value.  I am sure it is held in a buffer, but where and how to access it is still an open question.  I tried switching between a 3d view and the back to 2D, but that doesn't seem to have triggered the update. My experiments at setting the drawingWidth and drawingHeight are in SetWindowTestCode().

I'll take any suggestions I can get.

Thanks again, and have a good one.
Shawn

pkohut

  • Guest
Re: Updating model space display extents
« Reply #22 on: March 23, 2010, 05:18:16 PM »
OK,

Really? good code...  :P  Posting the full project is embarrassing it reveals just what a noob I am at ARX.  Never the less the full project is posted.  All my code resides in acrxEntryPoint.cpp, and has been redone with subfunctions.  I added some diagnostic functions, as I have yet to be able to run in debug without a complete lock up or fatal error from AutoCAD.  The code compiles with no errors or warnings.

Might as well a formating lessons now.  Should my code be in a separate file included in the acrxEntryPoint, or is where it is correct?  It feels like it should be elsewhere.

I've spent some time trying to research the problem a bit more, and I was checking out the acgs class.  I found acgsGetDisplayInfo(), it returns the drawingWidth, and drawingHeight, as well as aspect ratio for the display Frame.  Its values are the same as held in the screeensize sysvar.  If you look at the results of a run you will see that after the drawing window is resized, the drawingHeight, and drawingWidth remain unchanged.

I have yet to find a way to change that value.  I am sure it is held in a buffer, but where and how to access it is still an open question.  I tried switching between a 3d view and the back to 2D, but that doesn't seem to have triggered the update. My experiments at setting the drawingWidth and drawingHeight are in SetWindowTestCode().

I'll take any suggestions I can get.

Thanks again, and have a good one.
Shawn

I'm not on a Windows box to look at the code under VS or have any ARX documentation, but why in zoomExtents is view not a pointer? You need to get the view your interested in somehow (again no docs in front of me).  What you've done is created an instance of view, but it's not associated with a view in Autocad.

pkohut

  • Guest
Re: Updating model space display extents
« Reply #23 on: March 23, 2010, 05:27:56 PM »
OK,
I added some diagnostic functions, as I have yet to be able to run in debug without a complete lock up or fatal error from AutoCAD.  The code compiles with no errors or warnings.

Are you getting an exception when you press F5 to start the Autocad session?  If so just hit F5 again (maybe more than once), till the Autocad comand line is available.

I'm also not seeing your include or lib settings for the ObjectARX sdk in the vcproj file.  Maybe you've got them set globally for VS??

shawndoe

  • Guest
Re: Updating model space display extents
« Reply #24 on: March 23, 2010, 07:47:38 PM »
Hi,

When attempting to debug the first thing I notice is that not all the menus show up, only File, Window, and Help.  I reach the AutoCAD command line, but as soon as I load and start the ARX function it locks up.  My ignorance may be showing again. 

I do have the inc and lib paths set globally.  Am I better off not doing that, or does it matter?

I'm still getting the hang of pointers and how to use them.  Having created an instance of view, I'm not quite sure how to use it.  I also believe that creating a view without dealing with the stored pixel dimensions, as returned by acgsGetDisplayInfo(), will fail when Zoom Extents is call from the LISP.

Thanks again, you both have really given me a good start in ARX, I only feel overwhelmed about half the time now.  :)

Have a good one.
Shawn

pkohut

  • Guest
Re: Updating model space display extents
« Reply #25 on: March 23, 2010, 08:01:12 PM »
I'm still getting the hang of pointers and how to use them.  Having created an instance of view, I'm not quite sure how to use it.  I also believe that creating a view without dealing with the stored pixel dimensions, as returned by acgsGetDisplayInfo(), will fail when Zoom Extents is call from the LISP.

You don't want to create an instance of AcDbViewTableRecord, you want to get the pointer to one of the table records already maintained by Autocad.

edit: after looking at the AcadIMouse code I see that statement isn't correct. Look in the SDK documentation for acedSetCurrentView, code follows next post.
« Last Edit: March 23, 2010, 08:28:25 PM by pkohut »

pkohut

  • Guest
Re: Updating model space display extents
« Reply #26 on: March 23, 2010, 08:13:26 PM »
AcDbViewTableRecord * pViewRcd = new AcDbViewTableRecord;
pViewRcd->setALL_PROPERTIESS_YOU_WANT/NEED();
.
.
.
acedSetCurrentView(pViewRcd, NULL);

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6956
  • AKA Daniel
Re: Updating model space display extents
« Reply #27 on: March 24, 2010, 04:50:47 AM »
Weird, it seems that acad does not want to update until after the command has finished
I tried all what I could think of.. no luck


Code: [Select]
(defun c:test () (setwindow 500 500) (vla-zoomextents (vlax-get-acad-object)))

  static int ads_setwindow(void)
  {
    struct resbuf *pArgs =acedGetArgs ();
    int width, height;
    if(pArgs)
      width = pArgs->resval.rint;
    if((pArgs = pArgs->rbnext))
      height = pArgs->resval.rint;
    CRect ChildRect (0, 0, width, height);
    CWnd* DocFrame = acedGetAcadDwgView()->GetParent();
    DocFrame->SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0L);
    DocFrame->MoveWindow (ChildRect);
    acedRetVoid () ;
    return (RSRSLT) ;
  }
« Last Edit: March 24, 2010, 05:45:22 AM by Daniel »

LE3

  • Guest
Re: Updating model space display extents
« Reply #28 on: March 24, 2010, 10:39:46 AM »
will try to play again on this later this afternoon, but why if it works by using the arx zoom extents function....
as in the Reply #14 and removing the zoomExtents(); that it is on Reply #9

As per my previous tests here, but will double check as said later today...

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6956
  • AKA Daniel
Re: Updating model space display extents
« Reply #29 on: March 24, 2010, 10:47:46 AM »
Luis, yours did not work for me either, when applied from a single command. I tried using other command flags but no go  :mrgreen:
« Last Edit: March 24, 2010, 10:54:54 AM by Daniel »