求高手解释一下ent.DwgOut(filer);
//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.AutoCAD.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 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"); } }}这个是C:\ObjectARX 2008\samples\dotNet\FilerSample 这个例子 ent.DwgOut(filer);
按MyFiler的格式去解析
这应该是语法基础了、、、 ent获取了实体的信息,然后 .DwgOut(filer)让实体按照 MyFiler 的格式解析~!
页:
[1]