当前位置:   article > 正文

5.基于C#的CAD二次开发-对象选择(实体类Entity对象介绍)

5.基于C#的CAD二次开发-对象选择(实体类Entity对象介绍)

对象选择的本质

每一个CAD文件(DWG或者是DXF)都对应了一个数据库(Database),数据库中保存了CAD的所有对象。包括但不限于点、线、文字、块,图层、线型、线宽、颜色、标注等。
CAD二次开发的本质就是通过对数据库(Database)的操作。通过往数据库(Database)中写入数据,从而实现图形的绘制。通过获取数据库(Database)中保存的数据,对其中的数据进行修改,从而实现对图形的修改。
CAD二次开发中对象选择的本质,就是选择数据库(Database)外在的表象(点、线、文字、块,图层、标注、字典等),从而获得其保存在数据库(Database)的ObjectId,从而达到对CAD对象操作的目的。
实体类(Entity)对象,其命名空间为Autodesk.AutoCAD.DatabaseServices,属于数据库(Database)对象,其派生类包括CAD绘图区域里能看到的所有对象(布局Layout不属于实体类,但布局里的视口属于实体类。)

实体类(Entity)对象的主要信息和派生类

基本信息基本信息内容
类名称:Entity
类全称:Autodesk.AutoCAD.DatabaseServices.Entity
命名空间:Autodesk.AutoCAD.DatabaseServices
所属文件:C:\Program Files\Autodesk\AutoCAD 2019\AcdbMgd.dll
基类:Autodesk.AutoCAD.DatabaseServices.DBObject
派生类:ImpEntity
派生类:BlockReference
派生类:Table
派生类:DBText
派生类:Viewport
派生类:Curve
派生类:ImpCurve
派生类:Ray
派生类:Line
派生类:Circle
派生类:Dimension
派生类:ImpDimension
派生类:RadialDimension
派生类:OrdinateDimension
派生类:RotatedDimension
派生类:Point3AngularDimension
派生类:Polyline3d
派生类:LineAngularDimension2
派生类:Polyline2d
派生类:Vertex
派生类:Vertex2d
派生类:PolylineVertex3d
派生类:Surface
派生类:Solid3d
派生类:AlignedDimension
派生类:Arc
派生类:AttributeReference
派生类:AttributeDefinition
派生类:BlockBegin
派生类:BlockEnd
派生类:MInsertBlock
派生类:Body
派生类:DiametricDimension
派生类:Ellipse
派生类:Face
派生类:FaceRecord
派生类:FeatureControlFrame
派生类:Ole2Frame
派生类:Hatch
派生类:Image
派生类:RasterImage
派生类:DBPoint
派生类:PolyFaceMesh
派生类:PolyFaceMeshVertex
派生类:PolygonMesh
派生类:PolygonMeshVertex
派生类:Leader
派生类:MText
派生类:Mline
派生类:Polyline
派生类:ProxyEntity
派生类:Region
派生类:SequenceEnd
派生类:Shape
派生类:Solid
派生类:Trace
派生类:Xline
派生类:Spline
派生类:RadialDimensionLarge
派生类:ArcDimension
派生类:Section
派生类:UnderlayReference
派生类:DwfReference
派生类:DgnReference
派生类:PdfReference
派生类:Helix
派生类:Light
派生类:LoftedSurface
派生类:SweptSurface
派生类:RevolvedSurface
派生类:PlaneSurface
派生类:ExtrudedSurface
派生类:Wipeout
派生类:MLeader
派生类:SubDMesh
派生类:NurbSurface
派生类:PointCloud
派生类:PointCloudEx
派生类:ViewBorder
派生类:ViewRepBlockReference
派生类:DetailSymbol
派生类:SectionSymbol
派生类:GeomapImage
派生类:GeoPositionMarker

实体类(Entity)对象的通用方法函数

方法名称返回类型是否公共函数是否静态函数
AddContext(ObjectContext context)VoidTrueFalse
AddSubentityPaths(FullSubentityPath[] subPaths)VoidTrueFalse
ApplyPaperOrientationTransform(Viewport viewport)VoidTrueFalse
ApplyPartialUndo(DwgFiler undoFiler,RXClass classObj)VoidTrueFalse
Audit(AuditInfo auditInfo)VoidTrueFalse
BoundingBoxIntersectWith(Entity entityPointer,Intersect intersectType,Point3dCollection points,IntPtr thisGraphicSystemMarker,IntPtr otherGraphicSystemMarker)VoidTrueFalse
BoundingBoxIntersectWith(Entity entityPointer,Intersect intersectType,Plane projectionPlane,Point3dCollection points,IntPtr thisGraphicSystemMarker,IntPtr otherGraphicSystemMarker)VoidTrueFalse
BoundingBoxIntersectWith(Entity entityPointer,Intersect intersectType,Point3dCollection points,Int64 thisGraphicSystemMarker,Int64 otherGraphicSystemMarker)VoidTrueFalse
BoundingBoxIntersectWith(Entity entityPointer,Intersect intersectType,Plane projectionPlane,Point3dCollection points,Int64 thisGraphicSystemMarker,Int64 otherGraphicSystemMarker)VoidTrueFalse
Cancel()VoidTrueFalse
Clone()ObjectTrueFalse
Close()VoidTrueFalse
CloseAndPage(Boolean onlyWhenClean)VoidTrueFalse
CompareTo(Object obj)Int32TrueFalse
CopyFrom(RXObject source)VoidTrueFalse
CreateExtensionDictionary()VoidTrueFalse
CreateObjRef(Type requestedType)ObjRefTrueFalse
DecomposeForSave(DwgVersion version)DecomposeForSaveReplacementRecordTrueFalse
DeepClone(DBObject ownerPointer,IdMapping idMap,Boolean isPrimary)DBObjectTrueFalse
DeleteSubentityPaths(FullSubentityPath[] subPaths)VoidTrueFalse
DisableUndoRecording(Boolean disable)VoidTrueFalse
Dispose()VoidTrueFalse
DowngradeOpen()VoidTrueFalse
DowngradeToNotify(Boolean wasWritable)VoidTrueFalse
Draw()VoidTrueFalse
DwgIn(DwgFiler filer)VoidTrueFalse
DwgOut(DwgFiler filer)VoidTrueFalse
DxfIn(DxfFiler filer)VoidTrueFalse
DxfOut(DxfFiler filer)VoidTrueFalse
Equals(Object obj)BooleanTrueFalse
Erase()VoidTrueFalse
Erase(Boolean erasing)VoidTrueFalse
Explode(DBObjectCollection entitySet)VoidTrueFalse
GetEventExtender(Boolean create)DBObjectEventExtenderTrueFalse
GetField(String propertyName)ObjectIdTrueFalse
GetField()ObjectIdTrueFalse
GetGraphicsMarkersAtSubentityPathIntPtr(FullSubentityPath subPath)IntPtrCollectionTrueFalse
GetGripPoints(GripDataCollection grips,Double curViewUnitSize,Int32 gripSize,Vector3d curViewDir,GetGripPointsFlags bitFlags)BooleanTrueFalse
GetGripPoints(Point3dCollection gripPoints,IntegerCollection snapModes,IntegerCollection geometryIds)VoidTrueFalse
GetGripPointsAtSubentityPath(FullSubentityPath subPath,GripDataCollection grips,Double curViewUnitSize,Int32 gripSize,Vector3d curViewDir,GetGripPointsFlags bitFlags)BooleanTrueFalse
GetHashCode()Int32TrueFalse
GetLifetimeService()ObjectTrueFalse
GetObjectSaveVersion(DxfFiler filer)FullDwgVersionTrueFalse
GetObjectSaveVersion(DwgFiler filer)FullDwgVersionTrueFalse
GetObjectSnapPoints(ObjectSnapModes snapMode,Int32 gsSelectionMark,Point3d pickPoint,Point3d lastPoint,Matrix3d viewTransform,Point3dCollection snapPoints,IntegerCollection geometryIds,Matrix3d insertionMat)VoidTrueFalse
GetObjectSnapPoints(ObjectSnapModes snapMode,Int32 gsSelectionMark,Point3d pickPoint,Point3d lastPoint,Matrix3d viewTransform,Point3dCollection snapPoints,IntegerCollection geometryIds)VoidTrueFalse
GetParameterInterface(String name,Boolean runtimeInterface)IParameterTrueFalse
GetPersistentReactorIds()ObjectIdCollectionTrueFalse
GetPlane()PlaneTrueFalse
GetReactors()List`1TrueFalse
GetRXClass()RXClassTrueFalse
GetStretchPoints(Point3dCollection stretchPoints)VoidTrueFalse
GetSubentity(FullSubentityPath id)EntityTrueFalse
GetSubentityGeometricExtents(FullSubentityPath subPath)Extents3dTrueFalse
GetSubentityPathsAtGraphicsMarker(SubentityType type,IntPtr gsMark,Point3d pickPoint,Matrix3d viewTransform,ObjectId[] entityAndInsertStack)FullSubentityPath[]TrueFalse
GetSubentityPathsAtGraphicsMarker(SubentityType type,Int64 gsMark,Point3d pickPoint,Matrix3d viewTransform,Int32 numInserts,ObjectId[] entityAndInsertStack)FullSubentityPath[]TrueFalse
GetTransformedCopy(Matrix3d transform)EntityTrueFalse
GetTransientReactors()List`1TrueFalse
GetType()TypeTrueFalse
GetXDataForApplication(String applicationName)ResultBufferTrueFalse
HandOverTo(DBObject newPointer,Boolean keepXData,Boolean keepExtensionDictionary)VoidTrueFalse
HasContext(ObjectContext context)BooleanTrueFalse
HasPersistentReactor(ObjectId objId)BooleanTrueFalse
Highlight(FullSubentityPath subId,Boolean highlightAll)VoidTrueFalse
Highlight()VoidTrueFalse
HighlightState(FullSubentityPath subId)HighlightStyleTrueFalse
InitializeLifetimeService()ObjectTrueFalse
IntersectWith(Entity entityPointer,Intersect intersectType,Plane projectionPlane,Point3dCollection points,IntPtr thisGraphicSystemMarker,IntPtr otherGraphicSystemMarker)VoidTrueFalse
IntersectWith(Entity entityPointer,Intersect intersectType,Point3dCollection points,IntPtr thisGraphicSystemMarker,IntPtr otherGraphicSystemMarker)VoidTrueFalse
IntersectWith(Entity entityPointer,Intersect intersectType,Plane projectionPlane,Point3dCollection points,Int64 thisGraphicSystemMarker,Int64 otherGraphicSystemMarker)VoidTrueFalse
IntersectWith(Entity entityPointer,Intersect intersectType,Point3dCollection points,Int64 thisGraphicSystemMarker,Int64 otherGraphicSystemMarker)VoidTrueFalse
IsContentSnappable()BooleanTrueFalse
JoinEntities(Entity[] otherEntities)IntegerCollectionTrueFalse
JoinEntity(Entity secondaryEntity)VoidTrueFalse
List()VoidTrueFalse
MoveGripPointsAt(GripDataCollection grips,Vector3d offset,MoveGripPointsFlags bitFlags)VoidTrueFalse
MoveGripPointsAt(IntegerCollection indices,Vector3d offset)VoidTrueFalse
MoveGripPointsAtSubentityPaths(FullSubentityPath[] subPaths,IntPtr[] appData,Vector3d offset,MoveGripPointsFlags bitFlags)VoidTrueFalse
MoveStretchPointsAt(IntegerCollection indices,Vector3d offset)VoidTrueFalse
PopHighlight(FullSubentityPath subId)VoidTrueFalse
PushHighlight(FullSubentityPath subId,HighlightStyle highlightStyle)VoidTrueFalse
QueryX(RXClass protocolClass)IntPtrTrueFalse
RecordGraphicsModified(Boolean setModified)VoidTrueFalse
ReleaseExtensionDictionary()VoidTrueFalse
RemoveContext(ObjectContext context)VoidTrueFalse
RemoveField(ObjectId id)VoidTrueFalse
RemoveField(String propertyName)ObjectIdTrueFalse
RemoveField()ObjectIdTrueFalse
ResetScaleDependentProperties()VoidTrueFalse
SaveAs(WorldDraw mode,SaveType st)VoidTrueFalse
SetAttributes(DrawableTraits traits)Int32TrueFalse
SetDatabaseDefaults(Database sourceDatabase)VoidTrueFalse
SetDatabaseDefaults()VoidTrueFalse
SetDragStatus(DragStatus status)VoidTrueFalse
SetField(String propertyName,Field field)ObjectIdTrueFalse
SetField(Field field)ObjectIdTrueFalse
SetFromStyle()BooleanTrueFalse
SetGripStatus(GripStatus status)VoidTrueFalse
SetLayerId(ObjectId newValue,Boolean allowHidden)VoidTrueFalse
SetObjectIdsInFlux()VoidTrueFalse
SetPaperOrientation(Boolean bPaperOrientation)VoidTrueFalse
SetPropertiesFrom(Entity entityPointer)VoidTrueFalse
SetSubentityGripStatus(GripStatus status,FullSubentityPath subentity)VoidTrueFalse
SupportsCollection(String collectionName)BooleanTrueFalse
SwapIdWith(ObjectId otherId,Boolean swapExtendedData,Boolean swapExtensionDictionary)VoidTrueFalse
SwapReferences(IdMapping idMap)VoidTrueFalse
ToString()StringTrueFalse
TransformBy(Matrix3d transform)VoidTrueFalse
TransformSubentityPathsBy(FullSubentityPath[] subPaths,Matrix3d transform)VoidTrueFalse
Unhighlight(FullSubentityPath subId,Boolean highlightAll)VoidTrueFalse
Unhighlight()VoidTrueFalse
UpgradeFromNotify()BooleanTrueFalse
UpgradeOpen()VoidTrueFalse
ViewportDraw(ViewportDraw vd)VoidTrueFalse
ViewportDrawLogicalFlags(ViewportDraw vd)Int32TrueFalse
WblockClone(RXObject ownerPointer,IdMapping idMap,Boolean isPrimary)DBObjectTrueFalse
WorldDraw(WorldDraw wd)BooleanTrueFalse
X(RXClass protocolClass)IntPtrTrueFalse
XDataTransformBy(Matrix3d transform)VoidTrueFalse

实体类(Entity)对象的通用属性

属性名称属性类型是否可写
AcadObjectSystem.ObjectFalse
AnnotativeAutodesk.AutoCAD.DatabaseServices.AnnotativeStatesTrue
AutoDeleteSystem.BooleanTrue
BlockIdAutodesk.AutoCAD.DatabaseServices.ObjectIdFalse
BlockNameSystem.StringFalse
BoundsSystem.Nullable`1[Autodesk.AutoCAD.DatabaseServices.Extents3d]False
CastShadowsSystem.BooleanTrue
ClassIDSystem.GuidFalse
CloneMeForDraggingSystem.BooleanFalse
CollisionTypeAutodesk.AutoCAD.DatabaseServices.CollisionTypeFalse
ColorAutodesk.AutoCAD.Colors.ColorTrue
ColorIndexSystem.Int32True
CompoundObjectTransformAutodesk.AutoCAD.Geometry.Matrix3dFalse
DatabaseAutodesk.AutoCAD.DatabaseServices.DatabaseFalse
DrawableAutodesk.AutoCAD.GraphicsInterface.DrawableFalse
DrawableTypeAutodesk.AutoCAD.GraphicsInterface.DrawableTypeFalse
DrawStreamAutodesk.AutoCAD.GraphicsInterface.DrawStreamTrue
EcsAutodesk.AutoCAD.Geometry.Matrix3dFalse
EdgeStyleIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
EntityColorAutodesk.AutoCAD.Colors.EntityColorFalse
ExtensionDictionaryAutodesk.AutoCAD.DatabaseServices.ObjectIdFalse
FaceStyleIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
ForceAnnoAllVisibleSystem.BooleanTrue
GeometricExtentsAutodesk.AutoCAD.DatabaseServices.Extents3dFalse
HandleAutodesk.AutoCAD.DatabaseServices.HandleFalse
HasFieldsSystem.BooleanFalse
HasSaveVersionOverrideSystem.BooleanTrue
HyperlinksAutodesk.AutoCAD.DatabaseServices.HyperLinkCollectionFalse
IdAutodesk.AutoCAD.DatabaseServices.ObjectIdFalse
IsAProxySystem.BooleanFalse
IsCancellingSystem.BooleanFalse
IsDisposedSystem.BooleanFalse
IsErasedSystem.BooleanFalse
IsEraseStatusToggledSystem.BooleanFalse
IsModifiedSystem.BooleanFalse
IsModifiedGraphicsSystem.BooleanFalse
IsModifiedXDataSystem.BooleanFalse
IsNewObjectSystem.BooleanFalse
IsNotifyEnabledSystem.BooleanFalse
IsNotifyingSystem.BooleanFalse
IsObjectIdsInFluxSystem.BooleanFalse
IsPersistentSystem.BooleanFalse
IsPlanarSystem.BooleanFalse
IsReadEnabledSystem.BooleanFalse
IsReallyClosingSystem.BooleanFalse
IsTransactionResidentSystem.BooleanFalse
IsUndoingSystem.BooleanFalse
IsWriteEnabledSystem.BooleanFalse
LayerSystem.StringTrue
LayerIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
LinetypeSystem.StringTrue
LinetypeIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
LinetypeScaleSystem.DoubleTrue
LineWeightAutodesk.AutoCAD.DatabaseServices.LineWeightTrue
MaterialSystem.StringTrue
MaterialIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
MaterialMapperAutodesk.AutoCAD.GraphicsInterface.MapperTrue
MergeStyleAutodesk.AutoCAD.DatabaseServices.DuplicateRecordCloningTrue
ObjectBirthVersionAutodesk.AutoCAD.DatabaseServices.FullDwgVersionFalse
ObjectIdAutodesk.AutoCAD.DatabaseServices.ObjectIdFalse
OwnerIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
PaperOrientationAutodesk.AutoCAD.DatabaseServices.PaperOrientationStatesFalse
PlotStyleNameSystem.StringTrue
PlotStyleNameIdAutodesk.AutoCAD.DatabaseServices.PlotStyleDescriptorTrue
ReceiveShadowsSystem.BooleanTrue
TransparencyAutodesk.AutoCAD.Colors.TransparencyTrue
UndoFilerAutodesk.AutoCAD.DatabaseServices.DwgFilerFalse
UnmanagedObjectSystem.IntPtrFalse
VisibleSystem.BooleanTrue
VisualStyleIdAutodesk.AutoCAD.DatabaseServices.ObjectIdTrue
XDataAutodesk.AutoCAD.DatabaseServices.ResultBufferTrue

实体类对象的简单选择

通过GetEntity()函数,可以在绘图区域内选择单个实体类对象,其返回值为单个ObjectId 。该对象选择方法在实际中不是很实用,仅在此做简单介绍。

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityResult result1 = ed.GetEntity("请选择对象");
if (result1.Status != PromptStatus.OK) return;//如果选择对象不为空
ObjectId objectId = result1.ObjectId;//获得实体类对象的ObjectId
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/114320
推荐阅读
相关标签
  

闽ICP备14008679号