- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2009-5-30 10:32:00
|
显示全部楼层
本帖最后由 作者 于 2009-8-30 9:59:51 编辑
TlsCad开源部分的代码:
曲线转换类
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=77565
DBTransaction类
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=76123
曲线专贴
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=75636
2009/5/30
增强动画录制功能,可以将动作保存为动态Gif文件或多帧Tiff
点击 开始 录制
点击 停止 将在C盘下保存两个文件
将BlockView的窗体代码改下:)- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Drawing.Imaging;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.GraphicsInterface;
- using Autodesk.AutoCAD.Runtime;
- using Autodesk.AutoCAD.ApplicationServices;
- using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
- using TlsCad.Image;
- [assembly: CommandClass(typeof(TlsCad.frmBlockPreview))]
- namespace TlsCad
- {
- public partial class frmBlockPreview : Form
- {
- BlockPreviewCollection m_BlockPreviews;
- private ImageCreator m_Gif;
- private ImageCreator m_Tiff;
- public frmBlockPreview()
- {
- InitializeComponent();
- m_BlockPreviews =
- new BlockPreviewCollection(
- "D:\\TlsCad.dwg",
- Autodesk.AutoCAD.GraphicsSystem.RenderMode.GouraudShaded,
- VisualStyleType.Gouraud);
- m_BlockPreviews.BackColor = Color.White;
- List<Entity> ents = new List<Entity>();
- Line line = new Line(Point3d.Origin, new Point3d(0, 10.5, 0));
- line.SetDatabaseDefaults();
- ents.Add(line);
- Circle cir = new Circle(Point3d.Origin, Vector3d.ZAxis, 14);
- cir.SetDatabaseDefaults();
- ents.Add(cir);
- Line line1 = new Line(new Point3d(11, 0, 0), new Point3d(14, 0, 0));
- Line line2 = new Line(new Point3d(13, 0, 0), new Point3d(14, 0, 0));
- line1.SetDatabaseDefaults();
- line2.SetDatabaseDefaults();
- double angle = Math.PI / 30;
- for (int i = 0; i < 60; i++)
- {
- Line l;
- if (i % 5 == 0)
- l = (Line)line1.Clone();
- else
- l = (Line)line2.Clone();
- l.TransformBy(Matrix3d.Rotation(angle * i, Vector3d.ZAxis, Point3d.Origin));
- ents.Add(l);
- }
- m_BlockPreviews.Add(
- this.panel1,
- ents,
- new Extents3d(
- new Point3d(-20, -20, 0),
- new Point3d(20, 20, 0)));
- BlockPreview bpv = m_BlockPreviews.Add(panel2, "PressureVessel");
- }
- private void frmBlockPreview_FormClosed(object sender, FormClosedEventArgs e)
- {
- m_BlockPreviews.Dispose();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- button1.Text = (timer1.Enabled = !timer1.Enabled) ? "停止" : "继续";
- if (timer1.Enabled)
- {
- BlockPreview bpv = m_BlockPreviews[0];
- m_Gif = new GifCreator("c:\\1.gif", 100, 0);
- m_Tiff = new TiffCreator("c:\\1.tiff");
- Bitmap bp = m_BlockPreviews[0].GetImage();
- m_Gif.AddFrame(bp, FrameStatus.First);
- m_Tiff.AddFrame(bp, FrameStatus.First);
- }
- else
- {
- Bitmap bp = m_BlockPreviews[0].GetImage();
- m_Gif.AddFrame(bp, FrameStatus.End);
- m_Tiff.AddFrame(bp, FrameStatus.End);
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- m_BlockPreviews[0].Save("c://1.jpg", ImageFormat.Jpeg);
- m_BlockPreviews[1].Save("c://2.png", ImageFormat.Png);
- MessageBox.Show("文件已保存!");
- }
-
- private void timer1_Tick(object sender, EventArgs e)
- {
- BlockPreview bpv = m_BlockPreviews[0];
- Entity ent = bpv[0];
- ent.TransformBy(Matrix3d.Rotation(-Math.PI / 300, Vector3d.ZAxis, Point3d.Origin));
- bpv.Update(0);
- bpv.Refresh();
- Bitmap bp = m_BlockPreviews[0].GetImage();
- m_Gif.AddFrame(bp, FrameStatus.Other);
- m_Tiff.AddFrame(bp, FrameStatus.Other);
- }
- [CommandMethod("bview")]
- static public void bview()
- {
- using (frmBlockPreview dlg = new frmBlockPreview())
- {
- AcadApp.ShowModalDialog(dlg);
- }
- }
- }
- }
BlockView挺有意思的:),简单的做了个方块测试下
把测试代码还是放上吧,同时Debug目录下有TlsBasal.dll的新版本
这让我想起了自己编的第一个程序就是方块,哈哈
方块测试结束
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|