当前位置: 首页 > news >正文

026集——CAD动态效果—瞬态实现——vs CAD二次开发

瞬态类特点是不写入dwg图形的数据库中,只是临时显示的效果。

通过按ESC键更新显示,效果如下:

首先创建瞬态类,代码如下:

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace AcTools
{public class Flash {public FlashEntity flash = null;public Entity ent = null;public Flash(Circle ent){this.ent = ent;flash = new FlashEntity(ent);Transient.CapturedDrawable = flash;TransientManager.CurrentTransientManager.AddTransient(flash,TransientDrawingMode.Main, 128, new IntegerCollection());}public void FlashUpdate(Circle ent){if (ent == null){this.ent = ent;flash = new FlashEntity(ent);Transient.CapturedDrawable = flash;TransientManager.CurrentTransientManager.AddTransient(flash,TransientDrawingMode.Main, 128, new IntegerCollection());}else{this.ent = ent;flash._ent = ent;TransientManager.CurrentTransientManager.UpdateTransient(flash, new IntegerCollection());}}public void FlashErase(){if (flash == null) return;flash._ent = null;TransientManager.CurrentTransientManager.EraseTransient(flash, new IntegerCollection());flash = null;}}public class FlashEntity : Transient{public Entity _ent;public FlashEntity(Entity ent){_ent = ent;}protected override int SubSetAttributes(DrawableTraits traits){traits.FillType = FillType.FillAlways;return (int)DrawableAttributes.IsAnEntity;}protected override void SubViewportDraw(ViewportDraw vd){vd.Geometry.Draw(_ent);}protected override bool SubWorldDraw(WorldDraw wd){return false;}}
}

然后开始用瞬态实现动画:

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AcTools;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Colors;
using System.Runtime.CompilerServices;
using Wform = System.Windows.Forms;
using System.IO;
using System.Windows.Forms;
using Excel=  Microsoft.Office.Interop.Excel.Application;
using Autodesk.AutoCAD.Windows;
//using UserControl = System.Windows.Controls.UserControl;
//PaletteSet integration
using System.Windows.Forms.Integration;
using Autodesk.AutoCAD.Internal;namespace AcTools
{public  class Class1{Flash _flash;//定义一个瞬态flash变量[CommandMethod("xx")]public  void XX(){List<Flash> listflash = new List<Flash>();//实例化一个瞬态flashList<Circle> listcircle = new List<Circle>();for (int i = 0; i < 30; i++)//创建50个圆并加入flash列表中{Circle circle = new Circle() { Radius = i+1,ColorIndex = i+1};listcircle.Add(circle);_flash = new Flash(listcircle[i]);listflash.Add(_flash);  }//Z.Zoom();Z.ed.GetPoint("");//20次esc键,观看动态效果for (int j = 0; j < 20; j++){   //瞬态中50个圆更新属性for (int i = 0; i < 30; i++){listcircle[i].Radius = listcircle[i].Radius+1;listcircle[i].ColorIndex = 255 - listcircle[i].ColorIndex;listflash[i].FlashUpdate(listcircle[i]);}Z.ed.GetPoint("");}for (int i = 0; i < 30; i++){listflash[i].FlashErase();//删除瞬态}}}
}

 


http://www.mrgr.cn/news/64875.html

相关文章:

  • clickhouse运维篇(三):生产环境一键生成配置并快速部署ck集群
  • 近期学习前端的心得
  • 23.智能停车计费系统(基于springboot和vue的Java项目)
  • SpringBoot学生请假系统:从零到一的构建过程
  • Hugging Face魔塔使用
  • 勒索软件通过易受攻击的 Cyber​​Panel 实例攻击网络托管服务器
  • 力扣题目解析--罗马数字转整型
  • Linux入门(2)
  • 手机App防沉迷系统
  • ValueError: images do not match
  • GB/T 28046.3-2011 道路车辆 电气及电子设备的环境条件和试验 第3部分:机械负荷(3)
  • 14. 数据的输入输出
  • 第六十三周周报 GGNN
  • scIDST:弱监督学习推断单细胞转录组数据中的疾病进展阶段
  • 数据结构与算法(1)
  • 从一到无穷大 #40:DB AI 融合
  • 第三次RHCSA作业
  • Java入门 (6) -- 动态编程的奥秘
  • 视频QoE测量学习笔记(二)
  • masm汇编字符输入输出演示
  • 20221403郑骁恒-TLCP 协议验证
  • IDEA控制台日志乱码问题
  • 我主编的电子技术实验手册(22)——RC并联电路
  • jsweb2
  • 从“被围剿”到“满堂彩”,3A游戏让中国游戏人挺直脊背
  • RAG流程