新手入门必看: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)最新版下载

一. 使cmdScale具有引用和复制选项

问:是否可以制作“Scale命令”以获得参考和复制选项/p>

答:可以创建自己的自定义cmdScale命令。在C#中查看此示例代码:

                vdDocument doc = vdFramedControl.BaseControl.ActiveDocument;                doc.Prompt("Select objects:");                doc.CommandAction.CmdSelect("user");                doc.Prompt(null);                if (!success) return;                vdSelection documentSelection = doc.Selections.Add("VDRAW_PREVIOUS_SELSET");                if (documentSelection.Count == 0) return;                               doc.Prompt("Specify base point:");                gPoint origin = doc.ActionUtility.getUserPoint() as gPoint;                doc.Prompt(null);                if (origin == null) return;                bool copymode = false;                vdSelection set = null;                double scalevalue = 1.0d;                do                {                    doc.Prompt("Specify scale factor or [Copy/Reference]:");                    VectorDraw.Professional.CommandActions.ActionGetTranfromSelection AScale = new VectorDraw.Professional.CommandActions.ActionGetTranfromSelection(origin, doc.ActiveLayOut, documentSelection, VectorDraw.Professional.CommandActions.ActionTransformParameter.ScaleXY);                    AScale.SetAcceptedStringValues(new string[] { "Copy;c;C", "Reference;r;R" }, null);                    doc.ActionAdd(AScale);                    StatusCode scode = AScale.WaitToFinish();                    doc.Prompt(null);                    if (scode != StatusCode.Success) return;                    if (AScale.Value is double)                    {                        set = documentSelection;                        scalevalue = (double)AScale.Value;                        break;                    }                    else if (AScale.Value.Equals("Copy"))                    {                        copymode = true;                    }                    else if (AScale.Value.Equals("Reference"))                    {                        doc.Prompt("Specify reference length:");                        object aret = doc.ActionUtility.getUserDist(null);                        doc.Prompt(null);                        if (aret is double)                        {                            double referencelength = (double)aret;                            doc.Prompt("Specify new length:");                            aret = doc.ActionUtility.getUserDist(null);                            doc.Prompt(null);                            if (aret is double)                            {                                double newlength = (double)aret;                                set = documentSelection;                                scalevalue = newlength / referencelength;                                break;                            }                        }                    }                    else                    {                        return;                    }                } while (true);                if (set != null)                {                    if (copymode)                    {                        set = new vdSelection();                        set.SetUnRegisterDocument(doc);                        foreach (vdFigure fig in documentSelection)                        {                            vdFigure clonefig = fig.Clone(doc) as vdFigure;                            doc.ActiveLayOut.LayoutOrViewPortEntities().AddItem(clonefig);                            set.AddItem(clonefig, false, vdSelection.AddItemCheck.Nochecking);                        }                    }                    doc.CommandAction.CmdScale(set, origin, scalevalue);                }

二. ActionEntity用于文本圆弧椭圆和尺寸对象的用法

问:ActionEntity用于文本圆弧椭圆和尺寸对象的用法/p>

答:请参见以下代码:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using VectorDraw.Professional.vdObjects;using VectorDraw.Professional.vdFigures;using VectorDraw.Professional.vdPrimaries;using VectorDraw.Generics;using VectorDraw.Geometry;using VectorDraw.Professional.vdCollections;using VectorDraw.Actions;using VectorDraw.Render;using VectorDraw.Professional.Actions;using VectorDraw.Serialize;namespace vdtest{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private vdDocument doc { get { return vdFramedControl1.BaseControl.ActiveDocument; } }        private void CmdText_Click(object sender, EventArgs e)        {            #region example of prompt the user to type a text on VectorDraw screen            doc.Prompt("Text Insertion Point:");            gPoint pt = doc.ActionUtility.getUserPoint() as gPoint;            doc.Prompt(null);            if (pt == null) return;            VectorDraw.Professional.CommandActions.ActionText aFig = new VectorDraw.Professional.CommandActions.ActionText(pt, 0.0d, doc.ActionLayout);            doc.Prompt("Text string:");            doc.ActionAdd(aFig);            StatusCode scode = aFig.WaitToFinish();            doc.Prompt(null);            if (scode != StatusCode.Success) return;            string text = aFig.Value as string;            if (text == null) return;            vdText vdtext = new vdText();            vdtext.SetUnRegisterDocument(doc);            vdtext.setDocumentDefaults();            vdtext.InsertionPoint = pt;            vdtext.Rotation = 0.0d;            vdtext.TextString = text;            vdtext.Transformby(doc.User2WorldMatrix);            doc.ActionLayout.Entities.AddItem(vdtext);            doc.ActionDrawFigure(vdtext);            #endregion        }        private void CmdArc_Click(object sender, EventArgs e)        {            #region example of prompt the user to select arc properties  on VectorDraw screen            doc.Prompt("Arc center Point:");            gPoint arccen = doc.ActionUtility.getUserPoint() as gPoint;            doc.Prompt(null);            if (arccen == null) return;            doc.Prompt("Arc radius:");            object arcrad = doc.ActionUtility.getUserDist(arccen);            doc.Prompt(null);            if (arcrad == null) return;            doc.Prompt("Arc StartAngle:");            object arcSangle = doc.ActionUtility.getUserAngle(arccen);            doc.Prompt(null);            if (arcSangle == null) return;            doc.Prompt("Arc EndAngle:");            object arcEAngle = doc.ActionUtility.getUserActionEntity(new VectorDraw.Professional.CommandActions.ActionArc(arccen, (double)arcrad, (double)arcSangle, doc.ActionLayout));            doc.Prompt(null);            if (arcEAngle == null) return;            vdArc vdarc = new vdArc();            vdarc.SetUnRegisterDocument(doc);            vdarc.setDocumentDefaults();            vdarc.Center = arccen;            vdarc.Radius = (double)arcrad;            vdarc.StartAngle = (double)arcSangle;            vdarc.EndAngle = (double)arcEAngle;            vdarc.Transformby(doc.User2WorldMatrix);            doc.ActionLayout.Entities.AddItem(vdarc);            doc.ActionDrawFigure(vdarc);            #endregion        }        private void CmdEllipse_Click(object sender, EventArgs e)        {            #region example of prompt the user to select ellipse properties  on VectorDraw screen            doc.Prompt("Ellipse Center Point:");            gPoint ellCen = doc.ActionUtility.getUserPoint() as gPoint;            doc.Prompt(null);            if (ellCen == null) return;            doc.Prompt("Ellipse First Axis End Point:");            gPoint ellAxis1End = doc.ActionUtility.getUserRefPoint(ellCen as gPoint) as gPoint;            doc.Prompt(null);            if (ellAxis1End == null) return;            doc.Prompt("Ellipse Second Axis Distance:");            object ellMajorLen = doc.ActionUtility.getUserActionEntity(new VectorDraw.Professional.CommandActions.ActionEllipse(ellCen, ellAxis1End, doc.ActionLayout));            doc.Prompt(null);            if (ellMajorLen == null) return;            vdEllipse ell = new vdEllipse();            ell.SetUnRegisterDocument(doc);            ell.setDocumentDefaults();            ell.Center = ellCen;            ell.MajorAngle = VectorDraw.Geometry.Globals.GetAngle(ellCen, ellAxis1End);            ell.MajorLength = VectorDraw.Geometry.gPoint.Distance3D(ellCen, ellAxis1End);            ell.MinorLength = (double)ellMajorLen;            ell.Transformby(doc.User2WorldMatrix);            doc.ActionLayout.Entities.AddItem(ell);            doc.ActionDrawFigure(ell);            #endregion        }        private void CmdDim_Click(object sender, EventArgs e)        {            #region example of prompt the user to select aligned dimension  on VectorDraw screen            doc.Prompt("Dimension First Point:");            gPoint dimPt1 = doc.ActionUtility.getUserPoint() as gPoint;            doc.Prompt(null);            if (dimPt1 == null) return;            doc.Prompt("Dimension Second Point:");            gPoint dimPt2 = doc.ActionUtility.getUserRefPoint(dimPt1) as gPoint;            doc.Prompt(null);            if (dimPt2 == null) return;            doc.Prompt("Dimension Location:");            gPoint dimPt3 = doc.ActionUtility.getUserActionEntity(new VectorDraw.Professional.CommandActions.ActionDimension(VectorDraw.Professional.Constants.VdConstDimType.dim_Aligned, dimPt1, dimPt2, dimPt2, 0.0d, doc.ActionLayout)) as gPoint;            doc.Prompt(null);            if (dimPt3 == null) return;            vdDimension dim = new vdDimension();            dim.SetUnRegisterDocument(doc);            dim.setDocumentDefaults();            dim.dimType = VectorDraw.Professional.Constants.VdConstDimType.dim_Aligned;            dim.DefPoint1 = dimPt1;            dim.DefPoint2 = dimPt2;            dim.LinePosition = dimPt3;            dim.Transformby(doc.User2WorldMatrix);            doc.ActionLayout.Entities.AddItem(dim);            doc.ActionDrawFigure(dim);            #endregion        }    }}

三. 在命令行中禁用右键单击上下文(弹出)菜单

问:如何禁用vdCommandLine中的弹出菜单(上下文菜单)/p>

答:此菜单是默认显示的默认Microsoft System.Windows.Forms.TextBox菜单。你可以使用以下代码来禁用它:

            commandLine.History.ContextMenu = new ContextMenu();            commandLine.UserText.ContextMenu = new ContextMenu();

或者

            vdFramedControl1.CommandLine.History.ContextMenu = new ContextMenu();            vdFramedControl1.CommandLine.UserText.ContextMenu = new ContextMenu();

如果你愿意,还可以创建自己的上下文菜单并通过右键单击显示它。

未完待续~

好消息!为了感谢大家的支持和关注,现免费送30套正版ABViewer软件~走过路过的同学千万不要错过

ABViewer免费送

标签:CAD

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

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

相关推荐

发表回复

登录后才能评论