新手入门必看:VectorDraw 常见问题整理大全(十六)

本系列教程整理了VectorDraw 最常见问题,教程整理的很齐全,非常适合新手学习,希望对大家有一定的帮助!

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)最新版下载

一. 通过键盘键和要传递给活动命令的点通过命令透明地调用放大镜

问:如何通过键盘键和要传递给活动命令的点通过命令透明地调用放大镜/p>

答:你可以使用以下代码:

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对象的面积和长度/p>

答:你可以使用以下代码计算复杂vdPolyhatch的面积和长度:

private void button1_Click(object sender, EventArgs e){   vdFramedControl1.BaseControl.ActiveDocument.Open(@"c:321Hatchtest.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();}

三. 加速多图纸印刷

问:如何加快多图纸印刷/p>

答:为了使你的打印速度更快,你需要为所有图纸选择一个通用的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 printermPrinter.SelectPaper("PRINTER-DEFAULT");//The default paper of selected system printermPrinter.OutInBlackWhite = true;mPrinter.LandScape = true;//here you can change some additional properties for selected printer like Margings Resolution copiesmPrinter.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);}

四. 将一些表格作为新图纸或现有图纸的模板

问:我需要在我的应用程序加载或创建模板的所有图形中标注一些文本样式和暗淡标准。我该怎么做/p>

答:可以通过在图形中包含这些表(或更多取决于你的应用程序需要)来完成,并在临时图形中打开它们并使用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:teststables.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:teststables.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的标记/p>

答:对于内部具有属性(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软件~走过路过的同学千万不要错过

ABViewer免费送

标签:CAD

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2018年11月4日
下一篇 2018年11月4日

相关推荐

发表回复

登录后才能评论