翻譯|使用教程|編輯:況魚杰|2020-01-03 11:39:54.083|閱讀 319 次
概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常見問題,教程整理的很齊全,非常適合新手學習。本文將會介紹如何在VectorDraw Developer Framework中導出文件,將會主要介紹如何導出具有背景色的SVG文件和在txt文件中如何導出xyz坐標。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。該庫還支持許多矢量和柵格輸入和輸出格式,包括本地PDF和SVG導出。
點擊立即下載VectorDraw Developer Framework
本文將會介紹如何在VectorDraw Developer Framework中導出文件,將會主要介紹如何導出具有背景色的SVG文件和在txt文件中如何導出xyz坐標。
如何導出具有背景色的SVG文件?
問:
是否可以導出背景顏色不同于白色的SVG文件?
答:
這可以通過一些代碼行來指示VDF組件在OnDrawBackground事件中使用調(diào)色板的背景色,例如:
// the form conatins a vdFramedControl and a Button bool isOnSVGSave = false; // use this global boolean in the form and make it true just before saving the SVG and then again to false after save is finished private void button1_Click(object sender, EventArgs e) { vdDocument doc = vdFramedControl.BaseControl.ActiveDocument; doc.Open(@"C:\test\simple1.vdml"); // open a test file doc.Palette.Background = Color.LightYellow; // change the background color doc.Palette.Forground = Color.DarkSlateGray; // and the foreground color ..... ..... isOnSVGSave = true; //set this flag to true before saving SVG doc.OnDrawBackground += new vdDocument.DrawBackgroundEventHandler(doc_OnDrawBackground); // enable the event doc.SaveAs(@"c:\test\svg1.svg"); // save the SVG doc.OnDrawBackground -= new vdDocument.DrawBackgroundEventHandler(doc_OnDrawBackground); // disable the event isOnSVGSave = false;//set this flag back to false after saving SVG } void doc_OnDrawBackground(object sender, vdRender render, ref bool cancel) { if (isOnSVGSave && render!=null && render is RenderFormats.SvgRender) // check that is on "save" and render is SvgRender { cancel = true; // you need to pass this as tru render.Clear(vdFramedControl.BaseControl.ActiveDocument.Palette.Background); // clear the render and use the Palette’s Background color! } }在txt文件中如何導出xyz坐標?
問:
如何將圖形中線和折線的x,y,z數(shù)據(jù)導出到txt文件中?
答:
VDF無法自動執(zhí)行此功能,但是從加載到VDF組件中的任何圖形中導出此txt文件非常容易。請參見下面的代碼:
private void button1_Click(object sender, EventArgs e) { vdDocument doc = vdFramedControl.BaseControl.ActiveDocument; doc.New(); doc.Open(@"c:\test\MyModel Layout_1.0.dxf"); using (StreamWriter writer = new StreamWriter(doc.FileName+".txt")) //export c:\test\MyModel Layout_1.0.dxf.txt file containing the points of lines and polylines only { foreach (vdFigure item in doc.Model.Entities) { if (item != null && item is vdLine) { writer.WriteLine("vdLine " + (item as vdLine).StartPoint.ToString() + " " + (item as vdLine).EndPoint.ToString()); } if (item != null && item is vdPolyline) { writer.Write("vdPolyline "); foreach (Vertex item2 in (item as vdPolyline).VertexList) { writer.Write(item2.AsgPoint().ToString() + " "); } writer.WriteLine(" "); } } } }您所需要做的就是循環(huán)文檔中的所有對象(線,折線等),獲取它們的x,y,z值,然后使用StreamWriter將它們寫入txt文件中。
熱門文章推薦:
=======================================================
如果您對想要購買正版授權VectorDraw Developer Framework(VDF),可以聯(lián)系咨詢相關問題。
關注慧聚IT微信公眾號 ???,了解產(chǎn)品的最新動態(tài)及最新資訊。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務必注明出處、不得修改原文相關鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: