Shawndoe 发表于 2010-3-17 16:16:32

更新模型空间显示范围

嗨,
我正在做我的第一个ARX程序。它调整了画框的大小,以便我可以调整它的纵横比。这很好,但我的例程是从LISP内部调用的。我不知道如何使系统变量更新,以便在LISP退出之前进行最大化。我只有默认的“模型空间”视口。我怀疑我需要更改模型空间视口设置,但我不确定如何更改。我已经发布了我的代码,所以你可以看到我正在尝试做什么
static void SetDwgWindow_SetWindow(void) {
        int Width        = 0; // 830
        int Height        = 0; // 564
        acedGetInt (_T("\nEnter a new width in pixels for the drawing window: "), &Width);
        acedGetInt (_T("\nEnter a new height in pixels for the drawing window: "), &Height);
        CRect rect (0, 0, 2 * Width, 2 * Height);
        CRect ChildRect (0, 0, Width, Height);
//
//
//
        CWnd* DocFrame = acedGetAcadDwgView()->GetParent();
        DocFrame->MoveWindow (ChildRect);
        DocFrame->UpdateWindow ();
}//SetDwgWindow

我应该为此使用acdbViewport类吗?我会接受任何我能得到的暗示
肖恩
**** Hidden Message *****

LE3 发表于 2010-3-17 17:35:09

你读过/研究过updateExt()吗?
以下是步骤:
1.定义AcDbViewTableRecord
2.您需要提取extmax()和extmin()
3.从上面的值计算AcGePoint2d的
4.计算/设置视图setCentPoint()
的中心点5.使用setHeight()和setWidth()
定义高度和宽度6.使用acedSetTrentView()
7设置当前视图。并通过调用updateExt()更新扩展阅读有关此内容,看看哪些参数更适合您的使用。
祝你好运,ARX将要求你更多地参与进来。

Shawndoe 发表于 2010-3-17 20:45:00

嗨,
议员,你戳我的是一根棍子吗?
再次感谢您的帮助。事实上,当我觉得自己有贡献时,我会更加投入,但说实话,我很少需要问问题,因为我很擅长寻找我需要的东西。只是要搜索ARX的信息库要有限得多。
//
//        Test of VP Reset
//
                AcDbViewTableRecord View;
                AcDbExtents ExtentsTest;
                AcGePoint2d ExtentsMax_2d (ExtentsTest.maxPoint(), ExtentsTest.maxPoint());
                AcGePoint2d ExtentsMin_2d (ExtentsTest.minPoint(), ExtentsTest.minPoint());
                View.setCenterPoint (ExtentsMin_2d + (ExtentsMax_2d - ExtentsMin_2d) / 2.0) ;
                View.setHeight (ExtentsMax_2d - ExtentsMin_2d) ;
                View.setWidth (ExtentsMax_2d - ExtentsMin_2d) ;
//
//
                acedSetCurrentView (&View, NULL);
                acdbHostApplicationServices()->workingDatabase()->updateExt(TRUE);
//
//        End of VP Reset
//

它的缩放没有任何不同,所以很明显我做错了什么,尽管在编译期间或运行时我没有收到任何错误或警告。我是否正确使用了UpdateText(),我缺少了什么
肖恩

LE3 发表于 2010-3-17 20:57:11

不需要AcDbExtents代码2]

pkohut 发表于 2010-3-18 12:46:53


看看AcadIMouse.cpp文件中的内容是否有帮助。这是相当旧的,可能是VC6,并为R14增加了鼠标滚轮缩放支持。你能相信我每年还是会收到5到6个更新这个程序的请求吗?不管怎样,我想它最后一次更新是在2000年。
我特此将此通知发布到“公共领域”。

LE3 发表于 2010-3-18 12:58:46

嘿,巴勃罗,
你做编程多久了?-还是更具体地针对基于AutoCAD的
<em>(也许是时候采访一些沼泽成员了)

pkohut 发表于 2010-3-18 13:13:04


我猜你是在问我? 是的。 我现在变老了,但我想我在89年或90年开始编写Autocad。

LE3 发表于 2010-3-18 13:19:37


我想你是在问我?是的。我现在老了,但我想我是在89年或90年开始编程Autocad的。
是的。
哇!好久不见。

Shawndoe 发表于 2010-3-18 15:34:41

只是一个更新,
绘图以调整大小的绘图窗口为中心,但它仍然看到旧的客户端窗口尺寸。Pkohut在我面前放了很多信息,我将在带着更多问题回来之前浏览一下。
下面我发布了我的代码和一个LISP片段,显示了如何使用ARX。如果您尝试一下,您会发现问题。
        static void SetDwgWindow_SetWindow(void) {
//
//        Set Variables
//
//                                               Client          Borders,Sliders,Ect.
                int Width        = 0; // ViewAreaWidth(802) + 28 = Width = 830
                int Height        = 0; // ViewAreaHeight(493) + 71 = Height = 564
                acedGetInt (_T("\nEnter a new width in pixels for the drawing window: "), &Width);
                acedGetInt (_T("\nEnter a new height in pixels for the drawing window: "), &Height);
                CRect rect (0, 0, 2 * Width, 2 * Height);
                CRect ChildRect (0, 0, Width, Height);
                AcGePoint3d Min (0, 0, 0);
                AcGePoint3d Max (830, 564, 0);
//
//        Resize Document Frame
//
                CWnd* DocFrame = acedGetAcadDwgView()->GetParent();
                DocFrame->MoveWindow (ChildRect);
                DocFrame->UpdateWindow ();
//
//        Test of VP Reset
//
                AcDbViewTableRecord View;
                AcGePoint3d ExtentsMax = acdbHostApplicationServices()->workingDatabase()->extmax();
                AcGePoint3d ExtentsMin = acdbHostApplicationServices()->workingDatabase()->extmin();
                AcGePoint2d ExtentsMax_2d (ExtentsMax, ExtentsMax);
                AcGePoint2d ExtentsMin_2d (ExtentsMin, ExtentsMin);
                View.setCenterPoint (ExtentsMin_2d + (ExtentsMax_2d - ExtentsMin_2d) / 3.0) ;
                View.setHeight (ExtentsMax_2d - ExtentsMin_2d) ;
                View.setWidth (ExtentsMax_2d - ExtentsMin_2d) ;
//
//
                acedSetCurrentView (&View, NULL);
                acdbHostApplicationServices()->workingDatabase()->updateExt(TRUE);
//
//        End of VP Reset
//
        }//SetDwgWindow
LISP snippet
(defun C:Test ()
(command "SetWindow" "830" "564")
(command "._Zoom" "Extents")
(getstring "Press any key to continue: ")
); Defun

再次感谢您的帮助。
肖恩

LE3 发表于 2010-3-18 17:36:42

不知道这是否是你想做/拥有的东西 - 试一试,看看是否有效。
static void zoomExtents()
{
        AcDbViewTableRecord view;
        AcGePoint3d max = acdbHostApplicationServices()->workingDatabase()->extmax(),
        min = acdbHostApplicationServices()->workingDatabase()->extmin();
        AcGePoint2d max_2d (max, max);
        AcGePoint2d min_2d (min, min);
        view.setCenterPoint (min_2d + (max_2d - min_2d) / 2.0);
        view.setHeight(max_2d - min_2d);
        view.setWidth (max_2d - min_2d);
        acedSetCurrentView (&view, NULL);
        acdbHostApplicationServices()->workingDatabase()->updateExt(TRUE);
}
static void SetDwgWindow_SetWindow(void) {
        //
        // Set Variables
        //
        // Client Borders,Sliders,Ect.
        int Width = 0; // ViewAreaWidth(802) + 28 = Width = 830
        int Height = 0; // ViewAreaHeight(493) + 71 = Height = 564
        acedGetInt (_T("\nEnter a new width in pixels for the drawing window: "), &Width);
        acedGetInt (_T("\nEnter a new height in pixels for the drawing window: "), &Height);
        CRect rect (0, 0, 2 * Width, 2 * Height);
        CRect ChildRect (0, 0, Width, Height);
        AcGePoint3d Min (0, 0, 0);
        AcGePoint3d Max (830, 564, 0);
        //
        // Resize Document Frame
        //
        CWnd* DocFrame = acedGetAcadDwgView()->GetParent();
        DocFrame->MoveWindow (ChildRect);
        DocFrame->UpdateWindow ();
        zoomExtents();
        DocFrame->SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0L);
        DocFrame->SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0L);
        DocFrame->SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0L);
}//SetDwgWindow

页: [1] 2
查看完整版本: 更新模型空间显示范围