乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 56|回复: 3

求高手解释一下ent.DwgOut(filer);

[复制链接]

1

主题

3

帖子

1

银币

初来乍到

Rank: 1

铜币
7
发表于 2012-7-11 15:45:00 | 显示全部楼层 |阅读模式
//Copyright 2004 byAutodesk, Inc.////Permission to use,copy, modify, and distribute this software in//object code formfor any purpose and without fee is hereby granted,//provided that theabove copyright notice appears in all copies and//that both thatcopyright notice and the limited warranty and//restricted rightsnotice below appear in all supporting//documentation.////AUTODESK PROVIDESTHIS PROGRAM "AS IS" AND WITH ALL FAULTS.//AUTODESKSPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF//MERCHANTABILITY ORFITNESS FOR A PARTICULAR USE.  AUTODESK, INC.//DOES NOT WARRANTTHAT THE OPERATION OF THE PROGRAM WILL BE//UNINTERRUPTED ORERROR FREE.////Use, duplication,or disclosure by the U.S. Government is subject to//restrictions setforth in FAR 52.227-19 (Commercial Computer//Software -Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)//(Rights inTechnical Data and Computer Software), as applicable. using System;using System.Collections;using System.Reflection;using Autodesk..Runtime;using Autodesk.AutoCAD.DatabaseServices;using Autodesk.AutoCAD.Geometry;using Autodesk.AutoCAD.EditorInput;using Autodesk.AutoCAD.ApplicationServices; namespace filer{      public class TestFiler     {         ///Defines a command which prompt a message on the AutoCAD command line         [CommandMethod("runfiler")]         public void filer()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               PromptEntityOptions opt = new PromptEntityOptions("Selectan object to dump");用户交互操作              PromptEntityResult res ;  用户操作的返回              do              {                   res = ed.GetEntity(opt); 通过 opt 获取一个实体                   opt.Message = "\nNo object selected. Select an object todump";              }              while (res.Status == PromptStatus.Error); 你懂得!              if (res.Status == PromptStatus.OK)              {                   using (Transaction t = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())事务操作                   {                       Entity ent = (Entity)t.GetObject(res.ObjectId,OpenMode.ForRead); 读取当前的这个实体                       MyFiler filer = new MyFiler();   类型为 MyFiler ,并且其值的类型为 MyFiler                       ent.DwgOut(filer);  这里没有看懂,大侠赐教~!                       t.Commit(); 提交事务操作                   }              }         }     }       class MyFiler :Autodesk.AutoCAD.DatabaseServices.DwgFiler     {         string fileType = "";         string dwgVersion = "";         public MyFiler()         {         }      ///  _____________________  Data Reading  _____________________             public override System.IntPtr ReadAddress()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new System.IntPtr ();         }          public override byte[] ReadBinaryChunk()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return null;         }          public override bool ReadBoolean()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return false;         }          public override byte ReadByte()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return 0;         }          public override void ReadBytes(byte[]value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");         }          public override double ReadDouble()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return 0;         }          public override Handle ReadHandle()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new Handle ();         }          public override ObjectId ReadHardOwnershipId()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new ObjectId ();         }          public override ObjectId ReadHardPointerId()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new ObjectId ();         }          public override short ReadInt16()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return 0;         }          public override int ReadInt32()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return 0;         }          public override Point2d ReadPoint2d()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new Point2d();         }          public override Point3d ReadPoint3d()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new Point3d();         }          public override Scale3d ReadScale3d()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new Scale3d();         }          public override ObjectId ReadSoftOwnershipId()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new ObjectId ();         }          public override ObjectId ReadSoftPointerId()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new ObjectId ();         }          public override string ReadString()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return null;         }          public override ushort ReadUInt16()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return 0;         }          public override uint ReadUInt32()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return 0;         }          public override Vector2d ReadVector2d()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new Vector2d();         }          public override Vector3d ReadVector3d()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              return new Vector3d();         }          public override void ResetFilerStatus()         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");         }          public override void Seek(int offset, int method)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");         }          ///  _____________________  Data Writing  _____________________                 public override void WriteAddress(System.IntPtr value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");              ed.WriteMessage(value.ToString()+"\n");          }          public override void WriteBinaryChunk(byte[]chunk)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");         }          public override void WriteBoolean(bool value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");          }          public override void WriteByte(byte value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteBytes(byte[]value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");          }          public override void WriteDouble(double value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteHandle(Handle handle)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");         }          public override void WriteHardOwnershipId(ObjectId value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteHardPointerId(ObjectId value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteInt16(short value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");          }          public override void WriteInt32(int value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WritePoint2d(Point2d value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteScale3d(Scale3d value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteSoftOwnershipId(ObjectId value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteSoftPointerId(ObjectId value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteString(string value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteUInt16(ushort value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteUInt32(uint value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteVector2d(Vector2d value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override void WriteVector3d(Vector3d value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+"\n");         }          public override FullDwgVersion DwgVersion         {              get              {                   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;                    if (dwgVersion != base.DwgVersion.ToString())                   {                       dwgVersion = base.DwgVersion.ToString();                       ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + dwgVersion +"\n");                   }                   return base.DwgVersion;              }         }                 public override ErrorStatus FilerStatus         {              get              {                   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;                    //ed.WriteMessage(MethodInfo.GetCurrentMethod().Name + " = " +FilerStatus.GetType() + "\n");                   return new ErrorStatus ();              }              set              {                   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;                    ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+  " = " + "\n");              }         }          public override FilerType FilerType         {              get              {                   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;                    if (fileType != FilerType.CopyFiler.ToString())                   {                    fileType = FilerType.CopyFiler.ToString();                       ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + fileType +" \n");                   }                   return FilerType.CopyFiler;              }                      }          public override int Position         {              get              {                   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;                    ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = " + "\n");                   return 0;              }         }          public override void WritePoint3d(Point3d value)         {              Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;               ed.WriteMessage(MethodInfo.GetCurrentMethod().Name+ " = ");              ed.WriteMessage(value.ToString()+ "\n");         }     }}
回复

使用道具 举报

1

主题

3

帖子

1

银币

初来乍到

Rank: 1

铜币
7
发表于 2012-7-11 15:46:00 | 显示全部楼层
这个是C:\ObjectARX 2008\samples\dotNet\FilerSample 这个例子
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2012-7-11 19:54:00 | 显示全部楼层
ent.DwgOut(filer);
按MyFiler的格式去解析
这应该是语法基础了、、、
回复

使用道具 举报

1

主题

3

帖子

1

银币

初来乍到

Rank: 1

铜币
7
发表于 2012-7-12 08:27:00 | 显示全部楼层
ent  获取了实体的信息,然后 .DwgOut(filer)让实体按照 MyFiler 的格式解析~!
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-29 19:07 , Processed in 0.343519 second(s), 61 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表