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)最新版下载可登录慧都网进行免费下载

一. 导出背景色的SVG文件

问:是否可以导出背景颜色不同于白色的SVG文件?

答:可以通过一些代码行来指示VDF(VectorDraw Developer Framework)组件在OnDrawBackground事件中使用Palette的背景颜色,例如:

// 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!
}
 

二. 在非XY平面中创建polyhatch

问:如何在非X / Y平面中创建polyhatch?

答:在创建剖面线时,多边形曲线和剖面线应位于X / Y平面中,因此如果在相同但不是X / Y平面中有折线,则需要将它们“带”到X / Y平面,创建聚阴影线,然后让他们回到他们的平面。请看以下代码:

private void Test()
{
vdDocument doc = vdFramedControl.BaseControl.ActiveDocument;
doc.New(); #region create 2 random polylines
// we will use two circles in order to get some random points from them to create the polylines.
vdCircle cir1 = new vdCircle(doc, new gPoint(, ), );
vdCircle cir2 = new vdCircle(doc, new gPoint(, ), );
Vector vec = new Vector(0.3, 0.7, -0.2); vec.Normalize();
cir1.ExtrusionVector = vec;
cir2.ExtrusionVector = vec;
// 2 circles are created in the same "random" plane // get some points from these just to "have" two polylines
gPoints pts1 = cir1.geomMeasure(); // points of 1st polyline
gPoints pts2 = cir2.geomMeasure(); // points of 2nd polyline
#endregion Matrix mat = new Matrix(); // this is the matrix of the plane that the circles belong to
mat.SetToViewDirection(vec, 0.0d);
Matrix invmat = new Matrix(mat.GetInvertion()); // create the curves for the polyhatch
vdPolyline pl = new vdPolyline(doc, pts1); // vector should be perpendicular in the plane where the polyline is and can also calculated using CalculateNormal3P, like:
Vector vec2 = new Vector();
Vector.CalculateNormal3P(pl.VertexList[] as gPoint, pl.VertexList[] as gPoint, pl.VertexList[] as gPoint, out vec2);
// in this case we already have it from the circle, as we set it above. pl.ExtrusionVector = vec;
pl.Flag = VdConstPlineFlag.PlFlagCLOSE;
pl.Transformby(mat); // we need to bring these points to X/Y plane
pl.Update(); VectorDraw.Professional.vdCollections.vdCurves curves_Outer = new VectorDraw.Professional.vdCollections.vdCurves();
curves_Outer.AddItem(pl); pl = new vdPolyline(doc, pts2);
pl.ExtrusionVector = vec;
pl.Flag = VdConstPlineFlag.PlFlagCLOSE;
pl.Transformby(mat); pl.Update(); // we need to bring these points to X/Y plane VectorDraw.Professional.vdCollections.vdCurves curves_Inside = new VectorDraw.Professional.vdCollections.vdCurves();
curves_Inside.AddItem(pl); //'create polyhatch
vdPolyhatch onehatch = new vdPolyhatch(doc);
onehatch.PolyCurves.AddItem(curves_Outer);
onehatch.PolyCurves.AddItem(curves_Inside);
onehatch.HatchProperties = new VectorDraw.Professional.vdObjects.vdHatchProperties(VectorDraw.Professional.Constants.VdConstFill.VdFillModeSolid); onehatch.Transformby(invmat); // bring this to the plane where the circles are.
doc.Model.Entities.AddItem(onehatch); //just add the circles for display reasons. There is no need to add them
cir1.PenColor.FromSystemColor(Color.Red);
cir2.PenColor.FromSystemColor(Color.Red);
doc.Model.Entities.AddItem(cir1);
doc.Model.Entities.AddItem(cir2); doc.CommandAction.Zoom("E", , );
}

三. 导出txt文件中的xyz坐标

问:如何将图形中的折线和折线的x,y,z数据导出到txt文件中?

答:VDF没有自动化此功能,但很容易从加载到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(" ");
}
}
}
}

您所需要的只是循环遍历文档中的所有对象(线,折线等)并获取其x,y,z值并使用StreamWriter将它们写入txt文件。

四. 如何覆盖折线的夹点

问:我想以不同的方式绘制折线的第一个夹点。我如何才能做到这一点?

答:以下是使用FigureDrawGrips事件执行此操作的示例:

..... // need to have these
doc.FreezeEntityDrawEvents.Push(false);
doc.OnFigureDrawGrips += new vdDocument.FigureDrawGripsEventHandler(doc_OnFigureDrawGrips);
....
and
//overrides the default draw grip
//draw the first grip of all vdFigures as red circle
//and the others as rectangle using the default grip color
void doc_OnFigureDrawGrips(object sender, vdRender render, ref bool cancel)
{
vdFigure fig = sender as vdFigure;
if (fig == null) return; //calculate the circle points and grip box points relative to grip center.
double half_viewsize = render.PixelSize * render.GlobalProperties.GripSize * 0.5d;
gPoint offsetPoint = new gPoint(half_viewsize, half_viewsize);
Box GripBox = new Box(offsetPoint * -, offsetPoint);
gPoints circlepts = Globals.GetArcSamplePoints(, half_viewsize, , Globals.VD_TWOPI);
Matrix morigin = new Matrix(); gPoints pts = fig.GetGripPoints();//points are in world CS int i = ;
foreach (gPoint pt in pts)
{
if (!render.IsSectionVisible(pt)) continue;//check the 3d section clip visibility
gPoint ptInView = render.CurrentMatrix.Transform(pt);
System.Drawing.Point p = render.View2PixelMatrix.Transform2GDIPoint(ptInView);
if (!render.Contains(p)) continue;//check if grip is inside the screen //initialize a new offset matrix represents the center of grip in current view CS
morigin.IdentityMatrix();
morigin.TranslateMatrix(ptInView); //push to matrix where the grip figure points are reference(see GripBox and circlepts)
render.PushToViewMatrix();
render.PushMatrix(morigin); if (i == )//if it is the first grip
{
render.PushPenstyle(Color.Red, true);
render.DrawPLine(sender, circlepts);
render.PopPenstyle();
}
else render.DrawBoundBox(sender, GripBox); render.PopMatrix();
render.PopMatrix(); //if a rendering procedure was break usually by a user pan / zoom in-out
if (render.StatusDraw == vdRender.DrawStatus.Break) break;
i++;
}
render.IsMessageQueEmpty();//update the render StatusDraw by checking if a mouse action was placed by the user
cancel = true;//do not call the default VectorDraw grip draw.
}

五. VDF滚动的鼠标滚轮控制
问:我想禁用鼠标平移和鼠标滚轮缩放,而不是使用滚轮,我想控制绘图的滚动,水平和垂直。我如何才能做到这一点?

答:您可以按照以下操作来禁用鼠标中键平移和鼠标滚轮放大/缩小:

//For the wrapper we have to get the vdDocument object like below.
VectorDraw.Professional.vdObjects.vdDocument doc = vd.ActiveDocument.WrapperObject as VectorDraw.Professional.vdObjects.vdDocument; doc.MouseWheelZoomScale = 1.0; //1.0 means disabled mouse wheel. 0.8(less than 1.0) or 1.2(more than 1.0) values can reverse the mouse wheel functionality.

要禁用平移,您必须使用如下的JobStart事件。

vd.JobStart += new AxVDrawLib5._DVdrawEvents_JobStartEventHandler(vd_JobStart);

void vd_JobStart(object sender, AxVDrawLib5._DVdrawEvents_JobStartEvent e)
{if (e.jobName == "BaseAction_ActionPan") e.cancel = ;}

要滚动视图,请使用以下代码:

... // these events must be used
doc.MouseWheelZoomScale = 1.0d; // disable mouse wheel zoom doc.ActionStart += new vdDocument.ActionStartEventHandler(doc_ActionStart);
vdFramedControl1.BaseControl.MouseWheel += new MouseEventHandler(BaseControl_MouseWheel);
... void BaseControl_MouseWheel(object sender, MouseEventArgs e)
{
if ((e != null) && (e.Delta != ))
{
vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument;
double height = doc.ActiveRender.Height * doc.ActiveRender.PixelSize;
double width = doc.ActiveRender.Width * doc.ActiveRender.PixelSize;
double stepY = height * (e.Delta / Math.Abs(e.Delta)) / 10.0d;
double stepX = width * (-1.0d * e.Delta / Math.Abs(e.Delta)) / 10.0d;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{ // if Shift key is pressed scroll horizontally
doc.ScrollActiveActionRenderView(stepX, 0.0d, true); // scroll only in dX
}
else //else scroll vertically
{
doc.ScrollActiveActionRenderView(0.0d, stepY, true); // scroll only in dY
}
}
} void doc_ActionStart(object sender, string actionName, ref bool cancel)
{
if (actionName == "BaseAction_ActionPan") cancel = true; // cancel middle mouse button pan
}

新手入门必看:VectorDraw 常见问题整理大全(一)的更多相关文章

  1. Liunx新手入门必看

    安装CentOS(Linux的一个常用发行版本,互联网公司经常使用这个发行版)用到的软件: VMware_workstation_full_12.5.2.exe 虚拟机软件,虚拟机由这个软件安装.管理 ...

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

    VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库.有了VDF提供的功能,您可以轻松地创建.编辑.管理.输出.输入和打印2D和3D图形文件.该库 ...

  3. 1.16 Linux该如何学习(新手入门必看)

    本节旨在介绍对于初学者如何学习 Linux 的建议.如果你已经确定对 Linux 产生了兴趣,那么接下来我们介绍一下学习 Linux 的方法. 如何去学习 学习大多类似庖丁解牛,对事物的认识一般都是由 ...

  4. vue入门笔记(新手入门必看)

    一.什么是Vue? 1.    vue为我们提供了构建用户界面的渐进式框架,让我们不再去操作dom元素,直接对数据进行操作,让程序员不再浪费时间和精力在操作dom元素上,解放了双手,程序员只需要关心业 ...

  5. Node笔记(新手入门必看)

    . 初识Node.js 1.1 Node.js是什么 Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. ...

  6. Django新手入门必看

    pip install django==2.1.7 (现在Django3.0出来,推荐大家可以使用一下Django3.0) pip list查看

  7. Java编程学习知识点分享 入门必看

    Java编程学习知识点分享 入门必看 阿尔法颜色组成(alpha color component):颜色组成用来描述颜色的透明度或不透明度.阿尔法组成越高,颜色越不透明. API:应用编程接口.针对软 ...

  8. STM32环境搭建/学习观点/自学方法 入门必看

    文章转自armfly开发板V4软件开发手册,分享学习~ 今天有幸看到armfly的开发板软件开发手册,开头的基础知识,真的很有用,还好有看到,一切都不迟,感悟很多,摘抄部分,学习分享~ 关于开发环境的 ...

  9. PHP高级程序员必看知识点:目录大全(不定期更新)

    面试题系列: 分享一波腾讯PHP面试题 2019年PHP最新面试题(含答案) Redis 高级面试题 学会这些还怕进不了大厂? 阿里面试官三年经验PHP程序员知识点汇总,学会你就是下一个阿里人! ph ...

随机推荐

  1. swift(五)swift的函数

    /** * 函数的定义和调用 */ func showIntegerArray(array:[Int]) { for a in array { println("\(a)") } ...

  2. [b0026] python 归纳 (十一)_线程_threading.Thread

    总结: 默认父线程跑完,子线程并不会马上退出,不像 thread.start_threadXXXX 父线程跑完了,并没有退出,一直在那里 线程启动速度很快,不占多少开销,不到1毫 秒 代码: # -* ...

  3. MySQL 部署分布式架构 MyCAT (一)

    架构 环境 主机名 IP db1 192.168.31.205 db2 192.168.31.206 前期准备 开启防火墙,安装配置 mysql (db1,db2) firewall-cmd --pe ...

  4. mySql创建带解释的表及给表和字段加注释的实现代码

    1.创建带解释的表 CREATE TABLE test_table( t_id INT(11) PRIMARY KEY AUTO_INCREMENT COMMENT '设置主键自增', t_name ...

  5. [Go] gocron源码阅读-go语言的结构体

    结构体类型 type 名字 struct{},下面这段是github.com/urfave/cli包里的代码,声明了一个App的结构体类型 type App struct { // The name ...

  6. windows系统下mount创建的.vhd

    自己无聊时候分出了几个磁盘用来练习,存放个人东西,cdef盘除了c盘都是随便乱存的(粗心-_-),于是分出了两个20G的vhd文件,但是每次开机都要去d盘点击挂载太麻烦,现在分享自己的方法. 创建mo ...

  7. Jenkins之插件Publish HTML reports的使用

    前提: 下载插件HTML Publisher plugin 一.安装 安装好HTML Publisher plugin之后,会在新建或者编辑项目时,在[增加构建后操作步骤]出现[Publish HTM ...

  8. c# 第31节 构造函数与析构函数、new关键字作用

    本节内容: 1:构造和析构的简介 2:构造函数的定义和使用 3:new关键字的作用 4:析构函数的定义和使用 1:构造和析构的简介 2:构造函数的定义和使用 构造函数: 当实例化的一个对象,就默认执行 ...

  9. conda基础命令

    1.首先在所在系统中安装Anaconda.可以打开命令行输入conda -V检验是否安装以及当前conda的版本. 2.conda常用的命令. 1)conda list 查看安装了哪些包. 2)con ...

  10. 剑指Offer-3.从尾到头打印链表(C++/Java)

    题目: 输入一个链表,按链表从尾到头的顺序返回一个ArrayList. 分析: 很简单的一道题,其实也就是从尾到头打印链表,题目要求返回ArrayList,其实也就是一个数组. 可以将链表中的元素全部 ...