彩票走势图

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

翻译|使用教程|编辑:黄竹雯|2018-12-10 10:20:11.000|阅读 308 次

概述:本系列教程整理了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)最新版下载

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

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

答:可以创建自己的自定义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用于文本圆弧椭圆和尺寸对象的用法?

答:请参见以下代码:

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中的弹出菜单(上下文菜单)?

答:此菜单是默认显示的默认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

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP