• <menu id="w2i4a"></menu>
  • logo VectorDraw教程
    文檔首頁>>VectorDraw教程>>新手入門必看:VectorDraw 常見問題整理大全(五)

    新手入門必看:VectorDraw 常見問題整理大全(五)


    VectorDraw Developer Framework(VDF)是一個用于應(yīng)用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。該庫還支持許多矢量和柵格輸入和輸出格式,包括本地PDF和SVG導(dǎo)出。

    VectorDraw Developer Framework最新版下載

    VectorDraw web library (javascript)是一個矢量圖形庫。VectorDraw web library (javascript)不僅能打開CAD圖紙,而且能顯示任何支持HTML5標(biāo)準(zhǔn)平臺上的通用矢量對象,如Windows,安卓,iOS和Linux。無需任何安裝,VectorDraw web library (javascript)就可以運(yùn)行在任何支持canvas標(biāo)簽和Javascript的主流瀏覽器(Chrome, Firefox, Safari, Opera, Dolphin, Boat等等)中。

    VectorDraw web library (javascript)最新版下載

    一. 選擇XRef的實(shí)體

    問:查找光標(biāo)下顯示的實(shí)體的最佳方法是什么?

    答:附加的XRef文檔在圖形中用vdInserts視為vdBlocks。因此,當(dāng)您附加外部參考文件時,會在文檔中添加一個塊并插入此塊。在vdfCAD中,如果打開圖形并單擊附加的XRef,您將看到vdInsert對象。

    您可以使用以下代碼獲取您單擊的內(nèi)部實(shí)體(vdInsert):

    object ret = vdFramedControl1.BaseControl.ActiveDocument.ActionUtility.getUserPoint();
    if (ret is VectorDraw.Geometry.gPoint)
    {
        VectorDraw.Geometry.gPoint p1 = vdFramedControl1.BaseControl.ActiveDocument.World2PixelMatrix.Transform(ret as VectorDraw.Geometry.gPoint);
        Point location = new Point((int)p1.x, (int)p1.y);
    
        // This code will return the xREF as vdInsert
        VectorDraw.Professional.vdPrimaries.vdFigure fig = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.GetEntityFromPoint(location, vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Render.GlobalProperties.PickSize, false);
        if (fig != null)
        {
            fig.HighLight = true;
            fig.Invalidate();
            MessageBox.Show("Figure is a : " + fig.ToString());
            fig.HighLight = false;
            fig.Invalidate();
        }
    
    // This code will return the inner entity, this is what you want
        VectorDraw.Professional.vdPrimaries.vdFigure outerfig; // this should be the xREF vdInsert
        VectorDraw.Geometry.Matrix matr = new VectorDraw.Geometry.Matrix();
        VectorDraw.Professional.vdPrimaries.vdFigure innerfig = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.GetInnerEntityFromPoint(out matr, out outerfig, location, vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Render.GlobalProperties.PickSize, false);
        if (innerfig != null && outerfig != null)
        {
            innerfig.HighLight = true; //This is the inner entity you want.
            innerfig.Invalidate();
            MessageBox.Show("Figure is a : " + innerfig.ToString() + " contained in " + outerfig.ToString());
            innerfig.HighLight = false;
            innerfig.Invalidate();
        }
    }

    二. 將LineType Penstyle設(shè)置為Render

    問:如何更改渲染對象的線型(solid,dashdot等)?我知道vdLineType可以在Vdraw.BaseControl.ActiveDocument.LineTypes中選擇,但我找不到渲染線類型的類似集合。

    答:在空項(xiàng)目中添加一個調(diào)用cmdLine“user”和VDScrollable控件的按鈕。添加OnActionDraw事件處理程序,并在ActiveDocument_OnActionDraw中使用如下代碼:

    void ActiveDocument_OnActionDraw(object sender, object action, bool isHideMode, ref bool cancel)
    {
        if (!(action is VectorDraw.Actions.ActionGetRefPoint)) return;
        VectorDraw.Actions.BaseAction act = action as VectorDraw.Actions.BaseAction;
        VectorDraw.Geometry.gPoint refpoint = act.ReferencePoint;
        VectorDraw.Geometry.gPoint currentpoint = act.OrthoPoint;
    
        // Draw the circle using vdCircle object 
    
        VectorDraw.Professional.vdFigures.vdCircle circle = new VectorDraw.Professional.vdFigures.vdCircle();
        circle.SetUnRegisterDocument(vdSC.BaseControl.ActiveDocument);
        circle.setDocumentDefaults();
        circle.LineType = vdSC.BaseControl.ActiveDocument.LineTypes.DPIDashDotDot; // The Linetype here
        circle.Center = VectorDraw.Geometry.gPoint.MidPoint(refpoint, currentpoint);
        circle.Radius = circle.Center.Distance3D(refpoint);
        circle.Draw(act.Render);
    
        // OR you can use the Render.Draw....
    
        act.Render.PushPenstyle(Color.Red, 0.1d, vdSC.BaseControl.ActiveDocument.LineTypes.FindName("CENTER").GetgrLineType());
        act.Render.DrawLine(sender, new VectorDraw.Geometry.gPoint(0, 0, 0), currentpoint);
        act.Render.PopPenstyle(); // THIS IS NECESSARY after every push
    }

    三. 使用打印機(jī)導(dǎo)出到光柵和PDF / SVG / EMF / HPGL文件

    問:如何使用打印機(jī)導(dǎo)出到光柵JPG / BMP / TIF / GIF和PDF / SVG / EMF / HPGL文件?

    答:在版本6010及更高版本中,vdPrinter對象可用于將整個圖形或部分圖形導(dǎo)出為柵格(BMP JPG GIF TIF)和PDF,SVG,HPGL和EMF文件。下面是C#中可用于此的示例代碼:

    private void button1_Click(object sender, EventArgs e)
    {
    
    // Except for EMF, the same can be done with PDF, BMP, JPG, SVG, HPG (HPGL)
    // From version 6010 and above the printer can be used in order to export an area or the whole drawing in a
    // raster format (BMP, JPG), PDF, SVG, or HGPL
    
    #region create simple drawing
       //create a simple drawing
       vdFC.BaseControl.ActiveDocument.New();
        vdFC.BaseControl.ActiveDocument.CommandAction.CmdBox3d(new VectorDraw.Geometry.gPoint(10, 10), 10, 12, 14, 10);
        vdFC.BaseControl.ActiveDocument.CommandAction.CmdCircle(new VectorDraw.Geometry.gPoint(3, 3), 5.0d);
    #endregion
    
    #region save as EMF the Extends using fixed EMF width
       //save as EMF the Extends using fixed EMF width
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrinterName = "c:\\test_extends.emf"; // or PDF bmp jpg svg
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution=96; //Screen DPI
       VectorDraw.Geometry.Box Extends= vdFC.BaseControl.ActiveDocument.ActiveLayOut.Entities.GetBoundingBox(true,true);
       int EMFwidth = 500; //fixed width
       int EMFheight = (int) (EMFwidth * Extends.Height/Extends.Width); // keep propotions
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.paperSize = new Rectangle(0, 0, (int)(EMFwidth * 100 / vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution), (int)(EMFheight * 100 / vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution));
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintExtents();
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintScaleToFit();
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintOut();
    #endregion
    
    #region save as EMF the screen using fixed EMF height
       //save as EMF the screen using fixed EMF height
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrinterName = "c:\\test_screen.emf"; // or PDF bmp jpg svg
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution = 96; //Screen DPI
       VectorDraw.Geometry.Box screen_Box = new VectorDraw.Geometry.Box();
       double screen_width = vdFC.BaseControl.ActiveDocument.ActiveLayOut.PixelSize * vdFC.BaseControl.Width;
       double screen_height = vdFC.BaseControl.ActiveDocument.ActiveLayOut.ViewSize;
        screen_Box.AddPoint(vdFC.BaseControl.ActiveDocument.ActiveLayOut.ViewCenter - new VectorDraw.Geometry.gPoint(screen_width / 2.0d, screen_height / 2.0d));
        screen_Box.AddPoint(vdFC.BaseControl.ActiveDocument.ActiveLayOut.ViewCenter + new VectorDraw.Geometry.gPoint(screen_width / 2.0d, screen_height / 2.0d));
        EMFheight = 500; // this is fixed
       EMFwidth = (int)(EMFheight * screen_width / screen_height); //keeping the propotion
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.paperSize = new Rectangle(0, 0, (int)(EMFwidth * 100 / vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution), (int)(EMFheight * 100 / vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution));
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintWindow = screen_Box; // Here the code can be changed so
        // the user can select a rectangle in screen and this area is saved to file.
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintScaleToFit();
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintOut();
    #endregion
    
    #region call the PrintPreview in order the user to select the area to export to file
       // call the PrintPreview in order the user to select the area to export to file
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrinterName = "*.emf"; // Using *.emf or *.pdf etc the print dialog will prompt a dialog to input the file name
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution = 96; //Screen DPI
       EMFwidth = 500; //fixed width
       EMFheight = 500; // and height
       vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.paperSize = new Rectangle(0, 0, (int)(EMFwidth * 100 / vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution), (int)(EMFheight * 100 / vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.Resolution));
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintExtents();
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.PrintScaleToFit();
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.InitializePreviewFormProperties(true, true, false, false);
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.CenterDrawingToPaper();
        vdFC.BaseControl.ActiveDocument.ActiveLayOut.Printer.DialogPreview();
    #endregion
    
    }

    使用VDF Wrapper ActiveX(vdraw.ocx)和VectorDraw.Geometry.tlb以及VectorDraw.Professional.tlb,您可以使用以下代碼執(zhí)行相同操作:

    Private Sub Command1_Click()
     Dim doc As VectorDraw_Professional.vdDocument
     Dim box As Variant
     Dim EMFwidth As Long 
     Dim EMFheight As Long
     Dim extends As New VectorDraw_Geometry.box
    
        Set doc = VDraw1.ActiveDocument.WrapperObject
        
        doc.ActiveLayOut.Printer.PrinterName = App.Path + "\10165.emf"
        doc.ActiveLayOut.Printer.Resolution = 96
    
        extends.AddBox doc.ActiveLayOut.entities.GetBoundingBox(True, False)
        extends.Transformby doc.World2ViewMatrix
        extends.AddWidth doc.ActiveLayOut.Render.PixelSize * CDbl(0.5)
        
        EMFwidth = 1000
        EMFheight = CLng(EMFwidth * extends.Height / extends.Width + 0.5)
    
        doc.ActiveLayOut.Printer.SelectPaper "CUSTOM"
        doc.ActiveLayOut.Printer.MARGINS.Top = 0
        doc.ActiveLayOut.Printer.MARGINS.Bottom = 0
        doc.ActiveLayOut.Printer.MARGINS.Left = 0
        doc.ActiveLayOut.Printer.MARGINS.Right = 0
        doc.ActionLayout.Printer.Update
        
        VDraw1.ActiveDocument.ActiveLayOut.Printer.ActivePaperWidth = CLng(100# * CDbl(EMFwidth)  / CDbl(doc.ActiveLayOut.Printer.Resolution))
        VDraw1.ActiveDocument.ActiveLayOut.Printer.ActivePaperHeight = CLng(100# * CDbl(EMFheight) / CDbl(doc.ActiveLayOut.Printer.Resolution))
        
        
        Set doc.ActiveLayOut.Printer.PrintWindow = extends
        doc.ActiveLayOut.Printer.PrintScaleToFit
        doc.ActiveLayOut.Printer.PrintOut
    End Sub

    未完待續(xù)......

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();