天天看點

VectorDraw入門必備手冊(十一):如何建立一個複制模型視圖中顯示的3D視圖的視口?

    VectorDraw Developer Framework(VDF)是一個用于應用程式可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地建立、編輯、管理、輸出、輸入和列印2D和3D圖形檔案。   

    VectorDraw web library (javascript)不僅能打開CAD圖紙,而且能顯示任何支援HTML5标準平台上的通用矢量對象,如Windows,安卓,iOS和Linux。無需任何安裝,VectorDraw web library (javascript)就可以運作在任何支援canvas标簽和Javascript的主流浏覽器(Chrome, Firefox, Safari, Opera, Dolphin, Boat等等)中。這意味着可以用DXF,DWG,DGN,SKP(Google的Sketchup),VDML等多種格式在任何台式、平闆電腦,智能手機和便攜式筆記本上展現出你的業務。

問:

    我想在一個旋轉的3D圖像的布局中建立一個視口。我希望新的視口能夠準确顯示模型視圖中的内容,具有相同的旋轉,目标點,範圍等。您是否在其中一個示例應用程式或其他地方有一些代碼可以完成我正在尋找的内容?這是建立一個複制模型視圖中顯示的3D視圖的視口。

答:

    您可以使用vdView對象,它可以将布局或模型的所有視圖屬性複制到另一個布局/視訊。

    請參閱以下代碼:

private void button3_Click(object sender, EventArgs e)
{
    vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument; 
    vdLayout lay = new vdLayout(doc, "BBB");
    doc.LayOuts.AddItem(lay);
    vdViewport vp = new vdViewport(); vp.SetUnRegisterDocument(doc); 
    vp.setDocumentDefaults();
    vp.Height = doc.Model.ViewSize / doc.Model.PixelSize;
    vp.Width = vdFramedControl1.BaseControl.Width;
    vp.Center = new gPoint(vp.Width/2.0, vp.Height / 2.0d);
 
    vdView viewTMP = new vdView(doc, "mYvIEW1");
    viewTMP.SetFromLayout(doc.Model);
    vp.SetFromView(viewTMP);// viewTMP is not necessary to be 
         //  added to the document in such occasions 
 
    // or by hard code, without using the vdView object like :
    //vp.World2ViewMatrix = new Matrix(doc.Model.World2ViewMatrix);
    //vp.ViewCenter = new gPoint(doc.Model.ViewCenter);
    //vp.ViewSize = doc.Model.ViewSize;
    //vp.RenderMode = doc.Model.RenderMode;
    // set also PerspectiveMod,LensAngle, FocalLength etc if you use them
    
    lay.Entities.AddItem(vp);
    if (vp.Height < vp.Width) lay.Printer.LandScape = true;
    lay.Printer.PrintExtents(); lay.Printer.PrintScaleToFit(); 
    lay.Printer.Update(); lay.Update();
    doc.ActiveLayOut = lay;
    doc.CommandAction.Zoom("E", 0, 0);
}

Send comments o
           

    以上回答希望對您使用VectorDraw産品有幫助,如果您有其他的疑問或者建議可以在評論區留言,我們會及時處理。