找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 3722|回复: 0

[每日一码] 利用反射获取 DBObject 的所有 Methods

[复制链接]

已领礼包: 859个

财富等级: 财运亨通

发表于 2015-1-11 12:33:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

  1.        [LispFunction("mGetMethods")]
  2.         public void MyGetMethods(ResultBuffer rb)
  3.         {
  4.             if (rb != null)
  5.             {
  6.                 TypedValue[] values = rb.AsArray();
  7.                 if (values.Length == 1 && values[0].TypeCode == (int)LispDataType.ObjectId)
  8.                 {
  9.                     Document doc = Application.DocumentManager.MdiActiveDocument;
  10.                     Editor ed = doc.Editor;
  11.                     Database db = doc.Database;
  12.                     Transaction tr = db.TransactionManager.StartTransaction();
  13.                     var id = (ObjectId)values[0].Value;
  14.                     using (tr)
  15.                     {
  16.                         try
  17.                         {
  18.                             var obj = (DBObject)id.GetObject(OpenMode.ForRead);
  19.                             var methodInfos = obj.GetType().GetMethods();
  20.                             foreach (var tParam in methodInfos)
  21.                             {
  22.                                 var pams = tParam.GetParameters();
  23.                                 string sString = "";
  24.                                 foreach (var type in pams)
  25.                                 {
  26.                                     sString += (type.ParameterType.ToString()).Split(new Char[] { '.' }).Last() + ",";
  27.                                 }
  28.                                 var rString = tParam.ReturnParameter.ToString();
  29.                                 if (rString .Contains( "."))
  30.                                 {
  31.                                     rString = rString.Split(new[] {'.'}).Last();
  32.                                 }
  33.                                 ed.WriteMessage("\n{0}({1}), ReturnParameter is {2}",
  34.                                     tParam.Name,
  35.                                     sString.TrimEnd(new char[] { ',' }),
  36.                                     rString
  37.                                     );
  38.                             }
  39.                             tr.Commit();
  40.                         }
  41.                         catch (Autodesk.AutoCAD.Runtime.Exception)
  42.                         {
  43.                             return;
  44.                         }
  45.                     }
  46.                 }
  47.             }
  48.         }
以 Line  为例
Command: (mgetmethods (entlast))

get_StartPoint(), ReturnParameter is Point3d
set_StartPoint(Point3d), ReturnParameter is Void
get_EndPoint(), ReturnParameter is Point3d
set_EndPoint(Point3d), ReturnParameter is Void
get_Thickness(), ReturnParameter is Double
set_Thickness(Double), ReturnParameter is Void
get_Normal(), ReturnParameter is Vector3d
set_Normal(Vector3d), ReturnParameter is Void
get_Delta(), ReturnParameter is Vector3d
get_Angle(), ReturnParameter is Double
get_Length(), ReturnParameter is Double
get_Closed(), ReturnParameter is Boolean value
get_IsPeriodic(), ReturnParameter is Boolean value
get_StartParam(), ReturnParameter is Double
get_EndParam(), ReturnParameter is Double
GetPointAtParameter(Double), ReturnParameter is Point3d
GetParameterAtPoint(Point3d), ReturnParameter is Double
GetDistanceAtParameter(Double), ReturnParameter is Double
GetParameterAtDistance(Double), ReturnParameter is Double
GetDistAtPoint(Point3d), ReturnParameter is Double
GetPointAtDist(Double), ReturnParameter is Point3d
GetFirstDerivative(Point3d), ReturnParameter is Vector3d
GetFirstDerivative(Double), ReturnParameter is Vector3d
GetSecondDerivative(Point3d), ReturnParameter is Vector3d
GetSecondDerivative(Double), ReturnParameter is Vector3d
GetClosestPointTo(Point3d,Vector3d,Boolean), ReturnParameter is Point3d
GetClosestPointTo(Point3d,Boolean), ReturnParameter is Point3d
GetOrthoProjectedCurve(Plane), ReturnParameter is Curve
GetProjectedCurve(Plane,Vector3d), ReturnParameter is Curve
GetOffsetCurves(Double), ReturnParameter is DBObjectCollection
GetOffsetCurvesGivenPlaneNormal(Vector3d,Double), ReturnParameter is DBObjectCollection
get_Spline(), ReturnParameter is Spline
GetSplitCurves(Point3dCollection), ReturnParameter is DBObjectCollection
GetSplitCurves(DoubleCollection), ReturnParameter is DBObjectCollection
Extend(Boolean,Point3d), ReturnParameter is Void
Extend(Double), ReturnParameter is Void
get_Area(), ReturnParameter is Double
ReverseCurve(), ReturnParameter is Void
GetGeCurve(), ReturnParameter is Curve3d
GetGeCurve(Tolerance), ReturnParameter is Curve3d
SetFromGeCurve(Curve3d), ReturnParameter is Void
SetFromGeCurve(Curve3d,Tolerance), ReturnParameter is Void
SetFromGeCurve(Curve3d,Vector3d), ReturnParameter is Void
SetFromGeCurve(Curve3d,Vector3d,Tolerance), ReturnParameter is Void
get_BlockId(), ReturnParameter is ObjectId
get_Color(), ReturnParameter is Color
set_Color(Color), ReturnParameter is Void
get_ColorIndex(), ReturnParameter is Int32
set_ColorIndex(Int32), ReturnParameter is Void
get_EntityColor(), ReturnParameter is EntityColor
get_Transparency(), ReturnParameter is Transparency
set_Transparency(Transparency), ReturnParameter is Void
get_PlotStyleName(), ReturnParameter is String
set_PlotStyleName(String), ReturnParameter is Void
get_PlotStyleNameId(), ReturnParameter is PlotStyleDescriptor
set_PlotStyleNameId(PlotStyleDescriptor), ReturnParameter is Void
get_Layer(), ReturnParameter is String
set_Layer(String), ReturnParameter is Void
get_LayerId(), ReturnParameter is ObjectId
set_LayerId(ObjectId), ReturnParameter is Void
SetLayerId(ObjectId,Boolean), ReturnParameter is Void
get_Linetype(), ReturnParameter is String
set_Linetype(String), ReturnParameter is Void
get_LinetypeId(), ReturnParameter is ObjectId
set_LinetypeId(ObjectId), ReturnParameter is Void
get_LinetypeScale(), ReturnParameter is Double
set_LinetypeScale(Double), ReturnParameter is Void
get_Visible(), ReturnParameter is Boolean value
set_Visible(Boolean), ReturnParameter is Void
get_LineWeight(), ReturnParameter is LineWeight
set_LineWeight(LineWeight), ReturnParameter is Void
get_CollisionType(), ReturnParameter is CollisionType
SetPropertiesFrom(Entity), ReturnParameter is Void
get_IsPlanar(), ReturnParameter is Boolean value
GetPlane(), ReturnParameter is Plane
get_Ecs(), ReturnParameter is Matrix3d
get_GeometricExtents(), ReturnParameter is Extents3d
AddSubentityPaths(FullSubentityPath[]), ReturnParameter is Void
DeleteSubentityPaths(FullSubentityPath[]), ReturnParameter is Void
TransformSubentityPathsBy(FullSubentityPath[],Matrix3d), ReturnParameter is Void
GetGripPointsAtSubentityPath(FullSubentityPath,GripDataCollection,Double,Int32,Vector3d,GetGripPointsFlags), ReturnParameter is Boolean value
MoveGripPointsAtSubentityPaths(FullSubentityPath[],IntPtr[],Vector3d,MoveGripPointsFlags), ReturnParameter is Void
GetSubentityGeometricExtents(FullSubentityPath), ReturnParameter is Extents3d
GetSubentityPathsAtGraphicsMarker(SubentityType,IntPtr,Point3d,Matrix3d,ObjectId[]), ReturnParameter is FullSubentityPath[]
GetSubentityPathsAtGraphicsMarker(SubentityType,Int64,Point3d,Matrix3d,Int32,ObjectId[]), ReturnParameter is FullSubentityPath[]
GetGraphicsMarkersAtSubentityPathIntPtr(FullSubentityPath), ReturnParameter is IntPtrCollection
Highlight(FullSubentityPath,Boolean), ReturnParameter is Void
Highlight(), ReturnParameter is Void
Unhighlight(FullSubentityPath,Boolean), ReturnParameter is Void
Unhighlight(), ReturnParameter is Void
PushHighlight(FullSubentityPath,HighlightStyle), ReturnParameter is Void
PopHighlight(FullSubentityPath), ReturnParameter is Void
HighlightState(FullSubentityPath), ReturnParameter is HighlightStyle
GetObjectSnapPoints(ObjectSnapModes,Int32,Point3d,Point3d,Matrix3d,Point3dCollection,IntegerCollection,Matrix3d), ReturnParameter is Void
GetObjectSnapPoints(ObjectSnapModes,Int32,Point3d,Point3d,Matrix3d,Point3dCollection,IntegerCollection), ReturnParameter is Void
IsContentSnappable(), ReturnParameter is Boolean value
GetGripPoints(GripDataCollection,Double,Int32,Vector3d,GetGripPointsFlags), ReturnParameter is Boolean value
GetGripPoints(Point3dCollection,IntegerCollection,IntegerCollection), ReturnParameter is Void
MoveGripPointsAt(GripDataCollection,Vector3d,MoveGripPointsFlags), ReturnParameter is Void
MoveGripPointsAt(IntegerCollection,Vector3d), ReturnParameter is Void
GetStretchPoints(Point3dCollection), ReturnParameter is Void
MoveStretchPointsAt(IntegerCollection,Vector3d), ReturnParameter is Void
IntersectWith(Entity,Intersect,Plane,Point3dCollection,IntPtr,IntPtr), ReturnParameter is Void
IntersectWith(Entity,Intersect,Point3dCollection,IntPtr,IntPtr), ReturnParameter is Void
IntersectWith(Entity,Intersect,Plane,Point3dCollection,Int64,Int64), ReturnParameter is Void
IntersectWith(Entity,Intersect,Point3dCollection,Int64,Int64), ReturnParameter is Void
BoundingBoxIntersectWith(Entity,Intersect,Point3dCollection,IntPtr,IntPtr), ReturnParameter is Void
BoundingBoxIntersectWith(Entity,Intersect,Plane,Point3dCollection,IntPtr,IntPtr), ReturnParameter is Void
BoundingBoxIntersectWith(Entity,Intersect,Point3dCollection,Int64,Int64), ReturnParameter is Void
BoundingBoxIntersectWith(Entity,Intersect,Plane,Point3dCollection,Int64,Int64), ReturnParameter is Void
List(), ReturnParameter is Void
TransformBy(Matrix3d), ReturnParameter is Void
GetTransformedCopy(Matrix3d), ReturnParameter is Entity
GetSubentity(FullSubentityPath), ReturnParameter is Entity
Explode(DBObjectCollection), ReturnParameter is Void
RecordGraphicsModified(Boolean), ReturnParameter is Void
Draw(), ReturnParameter is Void
SaveAs(WorldDraw,SaveType), ReturnParameter is Void
get_CompoundObjectTransform(), ReturnParameter is Matrix3d
SetDatabaseDefaults(Database), ReturnParameter is Void
SetDatabaseDefaults(), ReturnParameter is Void
get_CloneMeForDragging(), ReturnParameter is Boolean value
SetDragStatus(DragStatus), ReturnParameter is Void
SetGripStatus(GripStatus), ReturnParameter is Void
SetSubentityGripStatus(GripStatus,FullSubentityPath), ReturnParameter is Void
get_Hyperlinks(), ReturnParameter is HyperLinkCollection
get_CastShadows(), ReturnParameter is Boolean value
set_CastShadows(Boolean), ReturnParameter is Void
get_ReceiveShadows(), ReturnParameter is Boolean value
set_ReceiveShadows(Boolean), ReturnParameter is Void
get_Material(), ReturnParameter is String
set_Material(String), ReturnParameter is Void
get_MaterialId(), ReturnParameter is ObjectId
set_MaterialId(ObjectId), ReturnParameter is Void
get_MaterialMapper(), ReturnParameter is Mapper
set_MaterialMapper(Mapper), ReturnParameter is Void
get_BlockName(), ReturnParameter is String
get_ForceAnnoAllVisible(), ReturnParameter is Boolean value
set_ForceAnnoAllVisible(Boolean), ReturnParameter is Void
get_VisualStyleId(), ReturnParameter is ObjectId
set_VisualStyleId(ObjectId), ReturnParameter is Void
get_FaceStyleId(), ReturnParameter is ObjectId
set_FaceStyleId(ObjectId), ReturnParameter is Void
get_EdgeStyleId(), ReturnParameter is ObjectId
set_EdgeStyleId(ObjectId), ReturnParameter is Void
JoinEntity(Entity), ReturnParameter is Void
JoinEntities(Entity[]), ReturnParameter is IntegerCollection
get_IsPersistent(), ReturnParameter is Boolean value
get_Id(), ReturnParameter is ObjectId
get_ObjectId(), ReturnParameter is ObjectId
get_OwnerId(), ReturnParameter is ObjectId
set_OwnerId(ObjectId), ReturnParameter is Void
get_Handle(), ReturnParameter is Handle
get_Database(), ReturnParameter is Database
DeepClone(DBObject,IdMapping,Boolean), ReturnParameter is DBObject
WblockClone(RXObject,IdMapping,Boolean), ReturnParameter is DBObject
DecomposeForSave(DwgVersion), ReturnParameter is DecomposeForSaveReplacementRecord
get_Drawable(), ReturnParameter is Drawable
CreateExtensionDictionary(), ReturnParameter is Void
get_ExtensionDictionary(), ReturnParameter is ObjectId
ReleaseExtensionDictionary(), ReturnParameter is Void
UpgradeOpen(), ReturnParameter is Void
UpgradeFromNotify(), ReturnParameter is Boolean value
DowngradeOpen(), ReturnParameter is Void
DowngradeToNotify(Boolean), ReturnParameter is Void
Cancel(), ReturnParameter is Void
Close(), ReturnParameter is Void
CloseAndPage(Boolean), ReturnParameter is Void
Erase(), ReturnParameter is Void
Erase(Boolean), ReturnParameter is Void
HandOverTo(DBObject,Boolean,Boolean), ReturnParameter is Void
SwapIdWith(ObjectId,Boolean,Boolean), ReturnParameter is Void
SwapReferences(IdMapping), ReturnParameter is Void
Audit(AuditInfo), ReturnParameter is Void
DwgIn(DwgFiler), ReturnParameter is Void
DwgOut(DwgFiler), ReturnParameter is Void
DxfIn(DxfFiler), ReturnParameter is Void
DxfOut(DxfFiler), ReturnParameter is Void
get_MergeStyle(), ReturnParameter is DuplicateRecordCloning
set_MergeStyle(DuplicateRecordCloning), ReturnParameter is Void
get_XData(), ReturnParameter is ResultBuffer
set_XData(ResultBuffer), ReturnParameter is Void
XDataTransformBy(Matrix3d), ReturnParameter is Void
GetXDataForApplication(String), ReturnParameter is ResultBuffer
get_IsEraseStatusToggled(), ReturnParameter is Boolean value
get_IsErased(), ReturnParameter is Boolean value
get_IsReadEnabled(), ReturnParameter is Boolean value
get_IsWriteEnabled(), ReturnParameter is Boolean value
get_IsNotifyEnabled(), ReturnParameter is Boolean value
get_IsModified(), ReturnParameter is Boolean value
get_IsModifiedXData(), ReturnParameter is Boolean value
get_IsModifiedGraphics(), ReturnParameter is Boolean value
get_IsNewObject(), ReturnParameter is Boolean value
get_IsNotifying(), ReturnParameter is Boolean value
get_IsUndoing(), ReturnParameter is Boolean value
get_IsCancelling(), ReturnParameter is Boolean value
get_IsReallyClosing(), ReturnParameter is Boolean value
get_IsTransactionResident(), ReturnParameter is Boolean value
get_IsAProxy(), ReturnParameter is Boolean value
DisableUndoRecording(Boolean), ReturnParameter is Void
get_UndoFiler(), ReturnParameter is DwgFiler
ApplyPartialUndo(DwgFiler,RXClass), ReturnParameter is Void
HasPersistentReactor(ObjectId), ReturnParameter is Boolean value
GetReactors(), ReturnParameter is RXObject]
GetTransientReactors(), ReturnParameter is RXObject]
GetPersistentReactorIds(), ReturnParameter is ObjectIdCollection
SetObjectIdsInFlux(), ReturnParameter is Void
get_IsObjectIdsInFlux(), ReturnParameter is Boolean value
get_HasSaveVersionOverride(), ReturnParameter is Boolean value
set_HasSaveVersionOverride(Boolean), ReturnParameter is Void
GetObjectSaveVersion(DxfFiler), ReturnParameter is FullDwgVersion
GetObjectSaveVersion(DwgFiler), ReturnParameter is FullDwgVersion
get_ObjectBirthVersion(), ReturnParameter is FullDwgVersion
get_ClassID(), ReturnParameter is Guid
get_AcadObject(), ReturnParameter is Object
GetField(String), ReturnParameter is ObjectId
GetField(), ReturnParameter is ObjectId
SetField(String,Field), ReturnParameter is ObjectId
SetField(Field), ReturnParameter is ObjectId
get_HasFields(), ReturnParameter is Boolean value
RemoveField(ObjectId), ReturnParameter is Void
RemoveField(String), ReturnParameter is ObjectId
RemoveField(), ReturnParameter is ObjectId
get_Annotative(), ReturnParameter is AnnotativeStates
set_Annotative(AnnotativeStates), ReturnParameter is Void
SetFromStyle(), ReturnParameter is Boolean value
ResetScaleDependentProperties(), ReturnParameter is Void
get_PaperOrientation(), ReturnParameter is PaperOrientationStates
SetPaperOrientation(Boolean), ReturnParameter is Void
ApplyPaperOrientationTransform(Viewport), ReturnParameter is Void
SupportsCollection(String), ReturnParameter is Boolean value
HasContext(ObjectContext), ReturnParameter is Boolean value
AddContext(ObjectContext), ReturnParameter is Void
RemoveContext(ObjectContext), ReturnParameter is Void
GetEventExtender(Boolean), ReturnParameter is DBObjectEventExtender
add_Cancelled(EventHandler), ReturnParameter is Void
remove_Cancelled(EventHandler), ReturnParameter is Void
add_Copied(ObjectEventHandler), ReturnParameter is Void
remove_Copied(ObjectEventHandler), ReturnParameter is Void
add_Erased(ObjectErasedEventHandler), ReturnParameter is Void
remove_Erased(ObjectErasedEventHandler), ReturnParameter is Void
add_Goodbye(EventHandler), ReturnParameter is Void
remove_Goodbye(EventHandler), ReturnParameter is Void
add_OpenedForModify(EventHandler), ReturnParameter is Void
remove_OpenedForModify(EventHandler), ReturnParameter is Void
add_Modified(EventHandler), ReturnParameter is Void
remove_Modified(EventHandler), ReturnParameter is Void
add_SubObjectModified(ObjectEventHandler), ReturnParameter is Void
remove_SubObjectModified(ObjectEventHandler), ReturnParameter is Void
add_ModifyUndone(EventHandler), ReturnParameter is Void
remove_ModifyUndone(EventHandler), ReturnParameter is Void
add_ModifiedXData(EventHandler), ReturnParameter is Void
remove_ModifiedXData(EventHandler), ReturnParameter is Void
add_Unappended(EventHandler), ReturnParameter is Void
remove_Unappended(EventHandler), ReturnParameter is Void
add_Reappended(EventHandler), ReturnParameter is Void
remove_Reappended(EventHandler), ReturnParameter is Void
add_ObjectClosed(ObjectClosedEventHandler), ReturnParameter is Void
remove_ObjectClosed(ObjectClosedEventHandler), ReturnParameter is Void
GetParameterInterface(String,Boolean), ReturnParameter is IParameter
SetAttributes(DrawableTraits), ReturnParameter is Int32
WorldDraw(WorldDraw), ReturnParameter is Boolean value
ViewportDraw(ViewportDraw), ReturnParameter is Void
ViewportDrawLogicalFlags(ViewportDraw), ReturnParameter is Int32
get_DrawableType(), ReturnParameter is DrawableType
get_Bounds(), ReturnParameter is Extents3d]
get_DrawStream(), ReturnParameter is DrawStream
set_DrawStream(DrawStream), ReturnParameter is Void
X(RXClass), ReturnParameter is IntPtr
QueryX(RXClass), ReturnParameter is IntPtr
GetRXClass(), ReturnParameter is RXClass
CompareTo(Object), ReturnParameter is Int32
Clone(), ReturnParameter is Object
CopyFrom(RXObject), ReturnParameter is Void
get_UnmanagedObject(), ReturnParameter is IntPtr
get_IsDisposed(), ReturnParameter is Boolean value
get_AutoDelete(), ReturnParameter is Boolean value
Equals(Object), ReturnParameter is Boolean value
GetHashCode(), ReturnParameter is Int32
Dispose(), ReturnParameter is Void
GetLifetimeService(), ReturnParameter is Object
InitializeLifetimeService(), ReturnParameter is Object
CreateObjRef(Type), ReturnParameter is ObjRef
ToString(), ReturnParameter is String
GetType(), ReturnParameter is Type

方法名(参数类型1,参数类型2 ...) 返回值类型

void 无返回值

利用 InvokeMember 写个 LispFuntion 就可以使用上面属性中的绝大部分了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-18 22:47 , Processed in 0.383612 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表