翻譯|使用教程|編輯:黃竹雯|2018-12-07 10:48:46.000|閱讀 324 次
概述:本系列教程整理了VectorDraw 最常見問題,教程整理的很齊全,非常適合新手學習,希望對大家有一定的幫助!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。該庫還支持許多矢量和柵格輸入和輸出格式,包括本地PDF和SVG導出。
【VectorDraw Developer Framework最新版下載】
VectorDraw web library (javascript)是一個矢量圖形庫。VectorDraw web library (javascript)不僅能打開CAD圖紙,而且能顯示任何支持HTML5標準平臺上的通用矢量對象,如Windows,安卓,iOS和Linux。無需任何安裝,VectorDraw web library (javascript)就可以運行在任何支持canvas標簽和Javascript的主流瀏覽器(Chrome, Firefox, Safari, Opera, Dolphin, Boat等等)中。
【VectorDraw web library (javascript)最新版下載】
一. 通過鍵盤鍵和要傳遞給活動命令的點通過命令透明地調用放大鏡
問:如何通過鍵盤鍵和要傳遞給活動命令的點通過命令透明地調用放大鏡?
答:你可以使用以下代碼:
private void Form1_Load(object sender,EventArgs e) { vdFramedControl.BaseControl.KeyDown + = new KeyEventHandler(BaseControl_KeyDown); } void BaseControl_KeyDown(object sender,KeyEventArgs e) { if(e.KeyCode == Keys .ControlKey )doc.ActionUtility.StartUserMagnifier(doc,3,210,-100); }
請注意,這適用于版本6016及更高版本。
二. 計算vdPolyHatch對象的面積和長度
問:如何計算vdPolyHatch對象的面積和長度?
答:你可以使用以下代碼計算復雜vdPolyhatch的面積和長度:
private void button1_Click(object sender, EventArgs e) { vdFramedControl1.BaseControl.ActiveDocument.Open(@"c:\321\Hatch\test.vdml"); // I have used a test drawing that containd a hatch VectorDraw.Professional.vdFigures.vdPolyhatch pHatch = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities[4] as VectorDraw.Professional.vdFigures.vdPolyhatch;// this is the vdPolyHatch object that I need to calculate the length and area if (pHatch == null) return; double area = pHatch.ToMesh(0).Area(); double length1 =0.0d; foreach (VectorDraw.Professional.vdCollections.vdCurves curves in pHatch.PolyCurves) { foreach (VectorDraw.Professional.vdFigures.vdCurve curve in curves) { length1 += curve.Length(); } } this.Text = "Area: " + area.ToString(); +" Length: " + length1.ToString(); }
三. 加速多圖紙印刷
問:如何加快多圖紙印刷?
答:為了使你的打印速度更快,你需要為所有圖紙選擇一個通用的vdPrint對象。
//A common printer for all drawings. VectorDraw.Professional.vdObjects.vdPrint mPrinter = new VectorDraw.Professional.vdObjects.vdPrint(); void SelectPrinter() { mPrinter.SetUnRegisterDocument(vdDrawingManager.BaseControl.ActiveDocument); mPrinter.PrinterName = "";//The default system printer mPrinter.SelectPaper("PRINTER-DEFAULT");//The default paper of selected system printer mPrinter.OutInBlackWhite = true; mPrinter.LandScape = true; //here you can change some additional properties for selected printer like Margings Resolution copies mPrinter.UpdatePrinterFromProperties();//this will update the internally selected System.Drawing.Printing.PrintDocument } void Print(vdDocument document) { mPrinter.DocumentName = "Printing Example(" + document.FileName +")"; mPrinter.SetLayout(document.ActiveLayOut); mPrinter.PrintExtents(); mPrinter.PrintScaleToFit(); mPrinter.PrintOut(); mPrinter.SetLayout(null); }
四. 將一些表格作為新圖紙或現有圖紙的模板
問:我需要在我的應用程序加載或創建模板的所有圖形中標注一些文本樣式和暗淡標準。我該怎么做?
答:可以通過在圖形中包含這些表(或更多取決于你的應用程序需要)來完成,并在臨時圖形中打開它們并使用MergeTables將它們合并。例如 :
namespace CreateAndMerge { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void AddTextstylesItems(VectorDraw.Professional.vdObjects.vdDocument doc) { //We add a textstyle with font name Verdana. VectorDraw.Professional.vdPrimaries.vdTextstyle style1 = new VectorDraw.Professional.vdPrimaries.vdTextstyle(); style1.SetUnRegisterDocument(doc); style1.setDocumentDefaults(); style1.Name = "TextStyle1"; style1.FontFile = "Verdana"; doc.TextStyles.AddItem(style1); VectorDraw.Professional.vdPrimaries.vdTextstyle style2 = new VectorDraw.Professional.vdPrimaries.vdTextstyle(); style2.SetUnRegisterDocument(doc); style2.setDocumentDefaults(); style2.Name = "TextStyle2"; style2.Extra.IsUnderLine = true; style2.Extra.IsStrikeOut = true; style2.FontFile = "Lucida Console"; doc.TextStyles.AddItem(style2); } private void AddDimstylesItems(VectorDraw.Professional.vdObjects.vdDocument doc) { //We create a vdDimstyle object. VectorDraw.Professional.vdPrimaries.vdDimstyle style1 = new VectorDraw.Professional.vdPrimaries.vdDimstyle(); style1.SetUnRegisterDocument(doc); style1.setDocumentDefaults(); //And change some properties. style1.Name = "DimStyle1"; style1.TextColor.ColorIndex = 1; style1.TextHeight = 0.5; //And add this object to the Dimstyles collection of the document. doc.DimStyles.AddItem(style1); //We can also add dimstyles using the Add function of the dimstyles collection which is much easier. VectorDraw.Professional.vdPrimaries.vdDimstyle style2 = doc.DimStyles.Add("DimStyle2"); style2.ExtLineVisible = false; style2.TextHeight = 0.5; VectorDraw.Professional.vdPrimaries.vdDimstyle style3 = doc.DimStyles.Add("DimStyle3"); style3.ExtLineColor.ColorIndex = 1; style3.DimTol = true; style3.DimTp = 0.3; style3.DimTm = 0.3; style3.TextHeight = 0.5; VectorDraw.Professional.vdPrimaries.vdDimstyle style4 = doc.DimStyles.Add("DimStyle4"); style4.DimAdec = 0; style4.DecimalPrecision = 0; style4.TextHeight = 0.5; VectorDraw.Professional.vdPrimaries.vdDimstyle style5 = doc.DimStyles.Add("DimStyle5"); style5.ArrowBlock = doc.Blocks.VDDIM_NONE; style5.TextHeight = 0.5; VectorDraw.Professional.vdPrimaries.vdDimstyle style6 = doc.DimStyles.Add("DimStyle6"); style6.ArrowSize *= 5.0; style6.TextHeight = 0.5; } private void btOpen_Click(object sender, EventArgs e) { //First we call the dialog to select the file to open and then open the file. object ret = vdFrameControl.BaseControl.ActiveDocument.GetOpenFileNameDlg(0, "", 0); if (ret == null) return; string fname = (string)ret; bool success = vdFrameControl.BaseControl.ActiveDocument.Open(fname); if (success) vdFrameControl.BaseControl.ActiveDocument.Redraw(true); } private void btMergeTables_Click(object sender, EventArgs e) { // This code will open the template drawing file which contains the tables (vdTextStyles, vdDimStyles, // vdLayers, vdBlocks etc) that we mostly use, in a vdDocument component and merge this with a new // drawing or with a drawing that already exists. VectorDraw.Professional.Components.vdDocumentComponent vdDocComponent; vdDocComponent = new VectorDraw.Professional.Components.vdDocumentComponent(); vdDocComponent.Document.Open(@"e:\tests\tables.vdcl"); DialogResult res= MessageBox.Show("Do you want to replace existing (if they exist already) tables in the document", "Overwrite Existing", MessageBoxButtons.YesNo); vdFrameControl.BaseControl.ActiveDocument.MergeTables(vdDocComponent.Document, false, (bool)(res == DialogResult.Yes)); vdFrameControl.BaseControl.ActiveDocument.CommandAction.RegenAll(); // this is needed to update the tables and entities vdDocComponent.Document.New(); vdDocComponent.Document.Dispose(); vdDocComponent.Dispose(); } private void btCreateTemplate_Click(object sender, EventArgs e) { //creating the drawing which contains the tables with the TextStyles and DimStyles that we need to use in other drawings // then the drawing is saved as vdcl file VectorDraw.Professional.Components.vdDocumentComponent vdDocComponent; vdDocComponent = new VectorDraw.Professional.Components.vdDocumentComponent(); AddTextstylesItems(vdDocComponent.Document); AddDimstylesItems(vdDocComponent.Document); vdDocComponent.Document.SaveAs(@"e:\tests\tables.vdcl", null); vdDocComponent.Document.New(); MessageBox.Show("The TextStyles and DimStyles are created. Now you can open the drawing you want and merge them to this drawing."); vdDocComponent.Document.Dispose(); vdDocComponent.Dispose(); } } }
五. 在vdInsert活躍后顯示屬性字符串
問:在vdInsert活躍后,是否可以顯示值而不是vdAttribute的標記?
答:對于內部具有屬性(vdAttribDef和vdAttribs)的插入,所有CAD軟件都會發生這種情況。這不算是錯誤或者問題,如果你希望保持文本顯示相同,則必須使用“special”活躍,這將更改這些attrib-definitions的TagString屬性。請參閱以下代碼:
private void button2_Click(object sender, EventArgs e) { VectorDraw.Professional.vdFigures.vdInsert ins = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities[0] as VectorDraw.Professional.vdFigures.vdInsert; // assume that the drawing contains only a vdInsert with attributes so this is Entity 0. if (ins == null) return; VectorDraw.Professional.vdCollections.vdEntities exploded_entities = ins.Explode(); vdFramedControl1.BaseControl.ActiveDocument.UndoHistory.StoreUndoGroup(true, "EXPLODE"); ins.Deleted = true; foreach (VectorDraw.Professional.vdPrimaries.vdFigure var in exploded_entities) { vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities.AddItem(var); VectorDraw.Professional.vdFigures.vdAttribDef def = var as VectorDraw.Professional.vdFigures.vdAttribDef; if (def != null) { def.TagString = def.ValueString.ToString(); // this is the code that you want that the default explode function do not have } var.Invalidate(); } vdFramedControl1.BaseControl.ActiveDocument.UndoHistory.StoreUndoGroup(false, "EXPLODE"); }
未完待續~
好消息!慧都為了感謝大家的支持和關注,現免費送出30套正版ABViewer軟件~走過路過的同學千萬不要錯過
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn