彩票走势图

VDF常见问题整理(六十四):如何删除特定图层的所有实体

翻译|使用教程|编辑:李显亮|2021-01-06 10:31:44.347|阅读 211 次

概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习。本文将会介绍如何删除Layer1的所有实体。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。该库还支持许多矢量和栅格输入和输出格式,包括本地PDF和SVG导出。

点击下载VectorDraw Developer Framework


问:如何删除Layer1的所有实体?

答:在下面的示例中,我们从所有布局和块中删除所有引用Layer1的实体,因此,如果一个块包含来自多个图层的实体,则将删除引用第1层的实体。

 //returns the handle of the layer of the passed entity
       function GetEntityLayerHandle(vdrawobj, document, entity) {
           var ret = entity.Layer;
           if (!ret) {//if not exist asume that it belongs to Layer '0'
               ret = vdrawobj.FindLayer("0");
               if (!ret) ret = 'h_';
               else ret = "h_" + ret.HandleId.toString();
           }
           return ret;
       }
       //set the Deleted property of the entities that belongs to layer with passed layerHandle, to true
       //Note: Entities with Deleted == true are not draw and they are not saved
       function deleteEntitiesOnLayer(vdrawobj,document, handlecollection, layerHandle) {
           for (var i = 0; i < handlecollection.Items.length; i++) {
               var ent = vdrawobj.GetDictItem(handlecollection, handlecollection.Items[i]);
               if (!ent) continue;
               var layerentity = GetEntityLayerHandle(vdrawobj,document,ent);
               if (layerentity == layerHandle)
                   ent.Deleted = true;
           }
           
       }
 
       function test() {
           //Mark all the entities, of all layouts and all blocks, that have property Layer == Layer 1 handle as Deleted = true
           var layer1 = vdcanvas.FindLayer('Layer1');
           var layerHandle = "h_" + layer1.HandleId.toString();
           var vddoc = vdcanvas.GetDocument();
 
           deleteEntitiesOnLayer(vdcanvas, vddoc, vddoc.Model.Entities, layerHandle);
           if (vddoc.LayOuts) {
               for (var i = 0; i < vddoc.LayOuts.Items.length; i++) {
                   deleteEntitiesOnLayer(vdcanvas, vddoc, vddoc.LayOuts.Items[i].Entities, layerHandle);
               }
           }
           if (vddoc.Blocks) {
               for (var i = 0; i < vddoc.Blocks.Items.length; i++) {
                   var block = vdcanvas.GetDictItem(vddoc.Blocks, vddoc.Blocks.Items[i]);
                   if (!block) continue;
                   deleteEntitiesOnLayer(vdcanvas, vddoc, block.Entities, layerHandle);
               }
           }
           vdcanvas.UpdateLayout();
           setTimeout(vdcanvas.redraw);
       }

=======================================================

如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。


标签:

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


为你推荐

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


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP