彩票走势图

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

翻译|使用教程|编辑:黄竹雯|2018-10-24 14:07:41.000|阅读 264 次

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

一. 从一个点选择实体(提供四种方法)

问:如何从单个点选择锁定/未锁定图层中的实体?

答:在本文中,我们将使用四种方法从我们使用getUserPoint()(这是pt)获得的点中选择可能处于锁定或未锁定层中的实体,如:

            gPoint pt = vdScrollableControl1.BaseControl.ActiveDocument.ActionUtility.getUserPoint() as gPoint;
and for the Selection Set :
            vdSelection selectionSet = null;
            selectionSet = vdScrollableControl1.BaseControl.ActiveDocument.Selections.FindName(name);
            if (selectionSet == null)
            {
                selectionSet = vdScrollableControl1.BaseControl.ActiveDocument.Selections.Add(name);
            }
            gPoint p1 = m_ActiveDoc.World2PixelMatrix.Transform(pt as gPoint);

方法1:使用RenderSelect.SelectingMode.SingleEntitiyPoint进行选择

这将获得最顶层的实体。如果此实体位于锁定图层中,则返回的selectionSet将为空

            // Selection with RenderSelect.SelectingMode.SingleEntitiyPoint
            gPoints points = new gPoints();
            selectSet.RemoveAll();
            points.Add(pt);
            selectSet.Select(RenderSelect.SelectingMode.SingleEntitiyPoint, points);

            if (selectSet.Count > 0)
            {
                foreach (vdFigure fig in selectSet)
                {
                    MessageBox.Show("Found figure with Handle " + fig.HandleId.ToString() + " in Layer: " + fig.Layer.Name + " which is locked: " + fig.Layer.Lock.ToString(), "[Select with SingleEntitiyPoint]");
                }
            }
            else
            {
                MessageBox.Show("No object selected","[Select with SingleEntitiyPoint]");
            }

方法2:使用GetEntityFromPoint选择选择

即使此实体位于锁定层中,也将获得最顶层实体。

            // Selection with GetEntityFromPoint
            Point location1 = new Point((int)p1.x, (int)p1.y);
            vdFigure fig2 = m_ActiveDoc.ActiveLayOut.GetEntityFromPoint(location1, m_ActiveDoc.ActiveLayOut.Render.GlobalProperties.PickSize, false);
            if (fig2 != null)
            {
                MessageBox.Show("Found figure with Handle: " + fig2.HandleId.ToString() + " in Layer: " + fig2.Layer.Name + " which is locked: " + fig2.Layer.Lock.ToString(),"[Select with GetEntityFromPoint]" );
            }
            else
            {
                MessageBox.Show("No object selected", "[Select with GetEntityFromPoint]");
            }

方法3:使用RenderSelect.SelectingMode.CrossingWindowRectangle和光标的PickSize进行选择

这将获得当前点+ picksize中的所有实体,但不会获取锁定图层中的实体

            // Selection with RenderSelect.SelectingMode.CrossingWindowRectangle and the cursors PickSize
            selectSet.RemoveAll();
            gPoints points2 = new gPoints();
            int size = m_ActiveDoc.ActiveLayOut.Render.GlobalProperties.PickSize;
            Point location2 = new Point((int)p1.x-size/2, (int)p1.y-size/2);
            Point location3 = new Point((int)p1.x+size/2, (int)p1.y+size/2);
            points2.Add(m_ActiveDoc.ActiveLayOut.Render.Pixel2View(location2));
            points2.Add(m_ActiveDoc.ActiveLayOut.Render.Pixel2View(location3));
            
            selectSet.Select(RenderSelect.SelectingMode.CrossingWindowRectangle, points2);

            if (selectSet.Count > 0)
            {
                foreach (vdFigure fig in selectSet)
                {
                    MessageBox.Show("Found figure with Handle " + fig.HandleId.ToString() + " in Layer: " + fig.Layer.Name + " which is locked: " + fig.Layer.Lock.ToString(), "[Select with CrossingWindowRectangle & PickSize]");
                }
            }
            else
            {
                MessageBox.Show("No object selected", "[Select with CrossingWindowRectangle & PickSize]");
            }

方法4:使用Select3D和光标的PickSize选择

这将获得当前点中的所有实体+ picksize甚至锁定图层中的实体

注意:Select3d方法不适用于Handle属性大于UInt的实体(32位)无符号整数)。

            // Selection using Select3D and cursor's picksize
            Point location4 = new Point((int)p1.x , (int)p1.y );
            vdEntities ents = m_ActiveDoc.Select3d(location4, m_ActiveDoc.ActiveLayOut.Render.GlobalProperties.PickSize);
            if (ents.Count > 0)
            {
                foreach (vdFigure fig in ents)
                {
                    MessageBox.Show("Found figure with Handle " + fig.HandleId.ToString() + " in Layer: " + fig.Layer.Name + " which is locked: " + fig.Layer.Lock.ToString(), "[Select with Select3d & PickSize]");
                }
            }
            else
            {
                MessageBox.Show("No object selected", "[Select with Select3d & PickSize]");
            }

二. 在打印期间,DrawAfter事件使用render.PrinterMode PRINT_PRINTER多次触发

问:在C#中使用vdProControl并在打印期间使用render.PrinterMode = PRINT_PRINTER多次触发DrawAfter事件?

答:根据打印机及其分辨率,VDF将纸张分割成区域,以便可以在大型打印机中打印,这是因为图纸可能包含大尺寸位图,或者只能打印为位图(如3D渲染模式)。VDF 6中的渲染在版本5中发生了很大变化,这就是您遇到问题的原因。代码应该写成不同的代码:

如果你使用PRINT_PRINTER,那么你应该绘制你喜欢它们是绘图单位中的实际对象的对象,例如:

if (render.PrinterMode == VDrawI5.VdConstPrintMode.PRINT_PRINTER)
{
    VDrawI5.vdPrint printer = vdProControl.ActiveDocument.Printer;
    double[] rect = printer.PrintWindow as double[];
    double[] bottomLeft = new double[] { rect[0],rect[1] };
    double[] topRight = new double[] { rect[2], rect[3] };
    render.Select_Pen(VDrawI5.VdConstPen.VdPenSolid, 1, 0);
    render.PushMatrix();
    render.SelectWorldMatrix();
    render.Drawline(bottomLeft[0], bottomLeft[1], 0, topRight[0], topRight[1], 0, 0);
    render.Drawline(topRight[0], bottomLeft[1], 0, bottomLeft[0], topRight[1], 0, 0);
    render.Drawcircle((bottomLeft[0] + topRight[0]) / 2, (bottomLeft[1] + topRight[1]) / 2, 0, (-bottomLeft[1] + topRight[1]) / 2);
    render.PopMatrix();
}

if {}内的代码将运行4次(或者更多地取决于打印机/纸张/分辨率),并且只有部分线条/圆圈将在每个“区域”中呈现并绘制你喜欢的内容。

如果你使用PRINT_PRINTER_PAPER,那么你应该像你一样使用代码,这里的问题是你设置笔(颜色,类型,宽度),如:

if (render.PrinterMode == VDrawI5.VdConstPrintMode.PRINT_PRINTER_PAPER)
{
    Console.WriteLine(render.PrinterMode.ToString());
    render.Select_Pen(VDrawI5.VdConstPen.VdPenSolid, 1, 0);
    double[] bottomLeft = new double[3];
    double[] topRight = new double[3];
    int left = 0, top = 0, right = 0, bottom = 0;
    render.GetWindowExt(ref left, ref top, ref right, ref bottom);
    render.PixelToView(left, bottom, ref bottomLeft[0], ref bottomLeft[1]);
    render.PixelToView(right, top, ref topRight[0], ref topRight[1]);
    render.Drawline(bottomLeft[0], bottomLeft[1], 0, topRight[0], topRight[1], 0, 0);
    render.Drawline(topRight[0], bottomLeft[1], 0, bottomLeft[0], topRight[1], 0, 0);
    render.Drawcircle((bottomLeft[0] + topRight[0]) / 2, (bottomLeft[1] + topRight[1]) / 2, 0, (-bottomLeft[1] + topRight[1]) / 2);
}

这取决于你在打印输出时要绘制的内容,你应该遵循哪种方法。

你也可以使用VDF .Net库的Render和DrawAfter事件,如(在Form_Load中):

VectorDraw.Professional.vdObjects.vdDocument doc = vdProControl.ActiveDocument.WrapperObject as VectorDraw.Professional.vdObjects.vdDocument;
doc.OnDrawAfter += new VectorDraw.Professional.vdObjects.vdDocument.DrawAfterEventHandler(doc_OnDrawAfter);
and use the
void doc_OnDrawAfter(object sender, VectorDraw.Render.vdRender render)
        {
            //Do your things here
        }

编写代码以在printout中绘制额外的东西。在这种情况下,你将不得不在C#项目中添加额外的引用,如VectorDraw.Render,VectorDraw.Geometry,VectorDraw.Serialize和VectorDraw.Generics

未完待续......


标签:CAD工业4.0

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


为你推荐

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


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP