1.过滤机制

所谓过滤机制,就是选择集的规则,过滤器列表由成对的参数组成。第一个参数标识过滤器的类型(例如对象),第二个参数指定要过滤的值(例如圆)。过滤器类型是指定使用哪种过滤器的 DXF 组码。

有关 DXF 组码的完整列表,请参见《DXF 参考手册》中的“组码值类型”(https://github.com/JohnYang1210/PycomCAD ,欢迎各位老铁star,pullrequest)

  • 过滤器列表可以是单个条件,也可以是多个条件,过滤器列表中的符号名称和字符串还可以包含通配符模式。

1.1 过滤器参数

滤器参数均为数组,在Pycomcad中需要使用VtInt和VtVariant函数进行转换, 过滤器类型为整数(VtInt转换),过滤器值为变量(VtVariant转换)。每个过滤器类型都必须与过滤器值成对相应出现。

  • 如:

    ft=[0] # 过滤器是对象类型

    ft=VtInt(ft) #对过滤器进行转换

    fd=['Circle'] # 过滤器值为圆

    fd=VtVariant(fd) #过滤器值转换

  • 以上是单个条件,下面是两个条件:

    ft=[0,8]

    ft=VtInt(ft)

    fd=['Circle','0']

    fd=VtVariant(fd)

    这样选择的是位于'0'图层上的圆

1.2增加过滤器的复杂程度

如果指定多个选择条件,AutoCAD 将假设选定对象必须符合所有条件。但用户可以按照其他方式来指定条件。对于数字项,用户可以指定关系运算(例如,圆的半径必须大于或等于 5.0); 对于所有项,用户可以指定逻辑运算(例如 Text 或 Mtext)。

  • (1)使用 -4 DXF 组码来指示过滤器规格中的关系运算符。以字符串的形式来指定运算符。

  • (2)过滤器列表中的逻辑运算符也由 -4 组代码表示,运算符为字符串,但必须组对。运算符以小于号开始 (<),以大于号结束 (>)。下表列出了可以在选择集过滤中使用的逻辑运算符

  • 如:

    ft=[0,-4,40,8]

    ft=VtInt(ft)

    fd=['Circle','>=',5,'0']

    fd=VtVariant(fd)

    这个选择的是位于'0'图层上所有半径大于等于5的圆。


对于逻辑关系:

ft=[-4,0,0,-4]

ft=VtInt(ft)

fd=['<or','TEXT','MTEXT','or>']

fd=VtVariant(fd)

这个选择是选择单行文字或者多行文字

1.3 在选择集过滤器条件中使用通配符模式

  • 如:

    ft=vtInt([0,1]) # 1-->图元的主要文字值

    fd=VtVariant(['MTEXT',' * THE * '])

    选择的是所有文字字符串中出现“The”的多行文字

  • 如:

    ft=VtInt([100,2]) # 100-->子类标记,2-->块名称

    fd=VtVariant['AcDbBlockReference','~'] #子类标记名为AcDbBlockReference,即引用块。是匹配后面之外的所有值,只有一个'',即包含了所有非空名称的引用块

1.4创建选择集并进行选择

在Pycomcad中,用slt=acad.GetSelectionSets(str)来进行创建,这里需要注意的有几点:(1)创建完后,经过使用后,最好最后都对slt进行释放(slt.Delete()),否则当一个dwg文件没有被关掉再打开的情况下,创建之前名字(str)的选择集是不被允许的,要报错。(2)slt有几种选择的方法,slt.Select,slt.SelectAtPoint,slt.SelectByPolygon,slt.SelectOnScreen等,这里不在赘述,源码中可见。

2引用块内对象访问

目前若要访问块内对象,主要将块炸开,然后炸开后返回组成该块的所有对象元组,需要注意的是,在选择集选中的块对象是块引用对象,与块对象是公用了一个Handle,但不是同一个对象。对于块引用对象,没有Explode方法,所以需要调用acad.Handle2Object方法来得到块对象。


下面是上述内容的一个例子:

import sys
sys.path.append(r'G:\PycharmProject\PycomCAD\PycomCAD')
from pycomcad import *
acad=Autocad()
acad.CurrentFilename
'Drawing1.dwg'
acad.IsEarlyBind
True
# acad.TurnOnEarlyBind()
ft=[100,2]
ft=VtInt(ft)
fd=['AcDbBlockReference','~']
fd=VtVariant(fd)
slt=acad.GetSelectionSets('slt11111')
slt.SelectOnScreen(ft,fd)   #屏幕选择,只选择块
slt.Count
7
slt.Item(0).Highlight(True)# 高亮第一个块引用对象
help(slt.Item(0))
Help on IAcadEntity in module win32com.gen_py.4E3F492A-FB57-4439-9BF0-1567ED84A3A9x0x1x0 object:

class IAcadEntity(win32com.client.DispatchBaseClass)
| IAcadEntity(oobj=None)
|
| AutoCAD Entity Interface
|
| Method resolution order:
| IAcadEntity
| win32com.client.DispatchBaseClass
| builtins.object
|
| Methods defined here:
|
| ArrayPolar(self, NumberOfObjects=<PyOleEmpty object at 0x000002B333A49150>, AngleToFill=<PyOleEmpty object at 0x000002B333A49150>, CenterPoint=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an array of selected objects in a polar pattern.
|
| ArrayRectangular(self, NumberOfRows=<PyOleEmpty object at 0x000002B333A49150>, NumberOfColumns=<PyOleEmpty object at 0x000002B333A49150>, NumberOfLevels=<PyOleEmpty object at 0x000002B333A49150>, DistBetweenRows=<PyOleEmpty object at 0x000002B333A49150>, DistBetweenCols=<PyOleEmpty object at 0x000002B333A49150>, DistBetweenLevels=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an array of selected objects in a rectangular pattern.
|
| Copy(self)
| Copies the entity object.
|
| Delete(self)
| Deletes a specified object
|
| Erase(self)
| Erases all the objects in a selection set
|
| GetBoundingBox(self, MinPoint=<PyOleMissing object at 0x000002B333A49390>, MaxPoint=<PyOleMissing object at 0x000002B333A49390>)
| Returns the min and max point of the bounding box of the entity object.
|
| GetExtensionDictionary(self)
| Gets the extension dictionary associated with an object
|
| GetXData(self, AppName=<PyOleEmpty object at 0x000002B333A49150>, XDataType=<PyOleMissing object at 0x000002B333A49390>, XDataValue=<PyOleMissing object at 0x000002B333A49390>)
| Gets the extended data (XData) associated with an object
|
| Highlight(self, HighlightFlag=<PyOleEmpty object at 0x000002B333A49150>)
| Highlights the entity object.
|
| IntersectWith(self, IntersectObject=<PyOleEmpty object at 0x000002B333A49150>, option=<PyOleEmpty object at 0x000002B333A49150>)
| Intersects with the input entity object.
|
| Mirror(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>)
| Mirrors selected objects about a line.
|
| Mirror3D(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>, point3=<PyOleEmpty object at 0x000002B333A49150>)
| Mirrors selected objects about a plane defined by three points.
|
| Move(self, FromPoint=<PyOleEmpty object at 0x000002B333A49150>, ToPoint=<PyOleEmpty object at 0x000002B333A49150>)
| Moves the entity object from source to destination.
|
| Rotate(self, BasePoint=<PyOleEmpty object at 0x000002B333A49150>, RotationAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Rotates the entity object about a point.
|
| Rotate3D(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>, RotationAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Rotates the entity object about a 3D line.
|
| ScaleEntity(self, BasePoint=<PyOleEmpty object at 0x000002B333A49150>, ScaleFactor=<PyOleEmpty object at 0x000002B333A49150>)
| Scale the entity object with respect to the base point and the scale factor.
|
| SetXData(self, XDataType=<PyOleEmpty object at 0x000002B333A49150>, XDataValue=<PyOleEmpty object at 0x000002B333A49150>)
| Sets the extended data (XData) associated with an object
|
| TransformBy(self, TransformationMatrix=<PyOleEmpty object at 0x000002B333A49150>)
| Performs the specified transformation on the entity object.
|
| Update(self)
| Updates the graphics of the entity object.
|
| __iter__(self)
| Return a Python iterator for this object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| CLSID = IID('{B58808B5-37AC-431F-BA80-A8D381BB4C5C}')
|
| coclass_clsid = IID('{571498B7-54A9-409E-9B06-9DD7DBC7E0BD}')
|
| ----------------------------------------------------------------------
| Methods inherited from win32com.client.DispatchBaseClass:
|
| __eq__(self, other)
| Return self==value.
|
| __getattr__(self, attr)
|
| __init__(self, oobj=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ne__(self, other)
| Return self!=value.
|
| __repr__(self)
| Return repr(self).
|
| __setattr__(self, attr, value)
| Implement setattr(self, name, value).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from win32com.client.DispatchBaseClass:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from win32com.client.DispatchBaseClass:
|
| __hash__ = None
slt.Item(0).GetBoundingBox()
((3671.238929877034, -1710.2902729521002, -1e-08),
(5127.713260427801, -850.7467697963812, 1e-08))
slt.Item(0).HasExtensionDictionary
True
blk=acad.acad.ActiveDocument.ActiveLayout.Block
help(blk)
Help on IAcadBlock in module win32com.gen_py.4E3F492A-FB57-4439-9BF0-1567ED84A3A9x0x1x0 object:

class IAcadBlock(win32com.client.DispatchBaseClass)
| IAcadBlock(oobj=None)
|
| A block definition containing a name and a set of objects
|
| Method resolution order:
| IAcadBlock
| win32com.client.DispatchBaseClass
| builtins.object
|
| Methods defined here:
|
| Add3DFace(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>, point3=<PyOleEmpty object at 0x000002B333A49150>, Point4=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3DFace object given four vertices
|
| Add3DMesh(self, M=<PyOleEmpty object at 0x000002B333A49150>, N=<PyOleEmpty object at 0x000002B333A49150>, PointsMatrix=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a free-form 3D mesh, given the number of points in the M and N directions and the coordinates of the points in the M and N directions
|
| Add3DPoly(self, PointsArray=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3D polyline from the given array of coordinates
|
| AddArc(self, Center=<PyOleEmpty object at 0x000002B333A49150>, Radius=<PyOleEmpty object at 0x000002B333A49150>, StartAngle=<PyOleEmpty object at 0x000002B333A49150>, EndAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an arc given the center, radius, start angle, and end angle of the arc
|
| AddAttribute(self, Height=<PyOleEmpty object at 0x000002B333A49150>, Mode=<PyOleEmpty object at 0x000002B333A49150>, Prompt=<PyOleEmpty object at 0x000002B333A49150>, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Tag=<PyOleEmpty object at 0x000002B333A49150>, Value=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an attribute definition at the given location with the specified properties
|
| AddBox(self, Origin=<PyOleEmpty object at 0x000002B333A49150>, Length=<PyOleEmpty object at 0x000002B333A49150>, Width=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3D solid box with edges parallel to the axes of the WCS
|
| AddCircle(self, Center=<PyOleEmpty object at 0x000002B333A49150>, Radius=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a circle given a center point and radius
|
| AddCone(self, Center=<PyOleEmpty object at 0x000002B333A49150>, BaseRadius=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3D solid cone with the base on the XY plane of the WCS
|
| AddCustomObject(self, ClassName=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a Custom object
|
| AddCylinder(self, Center=<PyOleEmpty object at 0x000002B333A49150>, Radius=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3D solid cylinder whose base is on the XY plane of the WCS
|
| AddDim3PointAngular(self, AngleVertex=<PyOleEmpty object at 0x000002B333A49150>, FirstEndPoint=<PyOleEmpty object at 0x000002B333A49150>, SecondEndPoint=<PyOleEmpty object at 0x000002B333A49150>, TextPoint=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an angular dimension for an arc, two lines, or a circle
|
| AddDimAligned(self, ExtLine1Point=<PyOleEmpty object at 0x000002B333A49150>, ExtLine2Point=<PyOleEmpty object at 0x000002B333A49150>, TextPosition=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an aligned dimension object
|
| AddDimAngular(self, AngleVertex=<PyOleEmpty object at 0x000002B333A49150>, FirstEndPoint=<PyOleEmpty object at 0x000002B333A49150>, SecondEndPoint=<PyOleEmpty object at 0x000002B333A49150>, TextPoint=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an angular dimension for an arc, two lines, or a circle
|
| AddDimArc(self, ArcCenter=<PyOleEmpty object at 0x000002B333A49150>, FirstEndPoint=<PyOleEmpty object at 0x000002B333A49150>, SecondEndPoint=<PyOleEmpty object at 0x000002B333A49150>, ArcPoint=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an arc length dimension for an arc
|
| AddDimDiametric(self, ChordPoint=<PyOleEmpty object at 0x000002B333A49150>, FarChordPoint=<PyOleEmpty object at 0x000002B333A49150>, LeaderLength=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a diametric dimension for a circle or arc given the two points on the diameter and the length of the leader line
|
| AddDimOrdinate(self, DefinitionPoint=<PyOleEmpty object at 0x000002B333A49150>, LeaderEndPoint=<PyOleEmpty object at 0x000002B333A49150>, UseXAxis=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an ordinate dimension given the definition point, and leader endpoint
|
| AddDimRadial(self, Center=<PyOleEmpty object at 0x000002B333A49150>, ChordPoint=<PyOleEmpty object at 0x000002B333A49150>, LeaderLength=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a radial dimension for the selected object at the given location
|
| AddDimRadialLarge(self, Center=<PyOleEmpty object at 0x000002B333A49150>, ChordPoint=<PyOleEmpty object at 0x000002B333A49150>, OverrideCenter=<PyOleEmpty object at 0x000002B333A49150>, JogPoint=<PyOleEmpty object at 0x000002B333A49150>, JogAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a jogged radial dimension for an arc, circle, or polyline arc segment
|
| AddDimRotated(self, ExtLine1Point=<PyOleEmpty object at 0x000002B333A49150>, ExtLine2Point=<PyOleEmpty object at 0x000002B333A49150>, DimLineLocation=<PyOleEmpty object at 0x000002B333A49150>, RotationAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a rotated linear dimension
|
| AddEllipse(self, Center=<PyOleEmpty object at 0x000002B333A49150>, MajorAxis=<PyOleEmpty object at 0x000002B333A49150>, RadiusRatio=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an ellipse in the XY plane of the WCS given the center point, a point on the major axis, and the radius ratio
|
| AddEllipticalCone(self, Center=<PyOleEmpty object at 0x000002B333A49150>, MajorRadius=<PyOleEmpty object at 0x000002B333A49150>, MinorRadius=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3D solid elliptical cone on the XY plane of the WCS given the Center, MajorRadius, MinorRadius, and Height
|
| AddEllipticalCylinder(self, Center=<PyOleEmpty object at 0x000002B333A49150>, MajorRadius=<PyOleEmpty object at 0x000002B333A49150>, MinorRadius=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 3D solid elliptical cylinder whose base is on the XY plane of the WCS, given the Center, MajorRadius, MinorRadius, and Height
|
| AddExtrudedSolid(self, Profile=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>, TaperAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an extruded solid given the Profile, Height, and TaperAngle
|
| AddExtrudedSolidAlongPath(self, Profile=<PyOleEmpty object at 0x000002B333A49150>, Path=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an extruded solid given the profile and an extrusion path
|
| AddHatch(self, PatternType=<PyOleEmpty object at 0x000002B333A49150>, PatternName=<PyOleEmpty object at 0x000002B333A49150>, Associativity=<PyOleEmpty object at 0x000002B333A49150>, HatchObjectType=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a Hatch object
|
| AddLeader(self, PointsArray=<PyOleEmpty object at 0x000002B333A49150>, Annotation=<PyOleEmpty object at 0x000002B333A49150>, Type=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a leader line, given the coordinates of the points
|
| AddLightWeightPolyline(self, VerticesList=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a lightweight polyline from a list of vertices
|
| AddLine(self, StartPoint=<PyOleEmpty object at 0x000002B333A49150>, EndPoint=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a line passing through two points
|
| AddMInsertBlock(self, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Name=<PyOleEmpty object at 0x000002B333A49150>, Xscale=<PyOleEmpty object at 0x000002B333A49150>, Yscale=<PyOleEmpty object at 0x000002B333A49150>, Zscale=<PyOleEmpty object at 0x000002B333A49150>, Rotation=<PyOleEmpty object at 0x000002B333A49150>, NumRows=<PyOleEmpty object at 0x000002B333A49150>, NumColumns=<PyOleEmpty object at 0x000002B333A49150>, RowSpacing=<PyOleEmpty object at 0x000002B333A49150>, ColumnSpacing=<PyOleEmpty object at 0x000002B333A49150>, Password=<PyOleEmpty object at 0x000002B333A49150>)
| Inserts an array of blocks
|
| AddMLeader(self, PointsArray=<PyOleEmpty object at 0x000002B333A49150>, leaderLineIndex=<PyOleMissing object at 0x000002B333A49390>)
| Creates a multileader
|
| AddMLine(self, VertexList=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a polyface mesh from a list of vertices
|
| AddMText(self, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Width=<PyOleEmpty object at 0x000002B333A49150>, Text=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an MText entity in a rectangle defined by the insertion point and width of the bounding box
|
| AddPoint(self, Point=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a Point object at a given location
|
| AddPolyfaceMesh(self, VertexList=<PyOleEmpty object at 0x000002B333A49150>, FaceList=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a polyface mesh from a list of vertices
|
| AddPolyline(self, VerticesList=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a polyline from a list of vertices
|
| AddRaster(self, imageFileName=<PyOleEmpty object at 0x000002B333A49150>, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, ScaleFactor=<PyOleEmpty object at 0x000002B333A49150>, RotationAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a new raster image based on an existing image file
|
| AddRay(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a ray passing through two unique points
|
| AddRegion(self, ObjectList=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a region from a set of entities. The given entities must form a closed coplanar region
|
| AddRevolvedSolid(self, Profile=<PyOleEmpty object at 0x000002B333A49150>, AxisPoint=<PyOleEmpty object at 0x000002B333A49150>, AxisDir=<PyOleEmpty object at 0x000002B333A49150>, Angle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a revolved solid, given the region around an axis
|
| AddSection(self, FromPoint=<PyOleEmpty object at 0x000002B333A49150>, ToPoint=<PyOleEmpty object at 0x000002B333A49150>, planeVector=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a section plane
|
| AddShape(self, Name=<PyOleEmpty object at 0x000002B333A49150>, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, ScaleFactor=<PyOleEmpty object at 0x000002B333A49150>, RotationAngle=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a Shape object based on a template identified by name, at the given insertion point, scale factor, and rotation
|
| AddSolid(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>, point3=<PyOleEmpty object at 0x000002B333A49150>, Point4=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a 2D solid polygon
|
| AddSphere(self, Center=<PyOleEmpty object at 0x000002B333A49150>, Radius=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a sphere given the center and radius
|
| AddSpline(self, PointsArray=<PyOleEmpty object at 0x000002B333A49150>, StartTangent=<PyOleEmpty object at 0x000002B333A49150>, EndTangent=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a quadratic or cubic NURBS (nonuniform rational B-spline) curve
|
| AddTable(self, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, NumRows=<PyOleEmpty object at 0x000002B333A49150>, NumColumns=<PyOleEmpty object at 0x000002B333A49150>, RowHeight=<PyOleEmpty object at 0x000002B333A49150>, ColWidth=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a table at the given insertion point, given the number of rows, number of columns, row height and column width
|
| AddText(self, TextString=<PyOleEmpty object at 0x000002B333A49150>, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a single line of text
|
| AddTolerance(self, Text=<PyOleEmpty object at 0x000002B333A49150>, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Direction=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a tolerance entity
|
| AddTorus(self, Center=<PyOleEmpty object at 0x000002B333A49150>, TorusRadius=<PyOleEmpty object at 0x000002B333A49150>, TubeRadius=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a torus at the given location
|
| AddTrace(self, PointsArray=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a Trace object from an array of points
|
| AddWedge(self, Center=<PyOleEmpty object at 0x000002B333A49150>, Length=<PyOleEmpty object at 0x000002B333A49150>, Width=<PyOleEmpty object at 0x000002B333A49150>, Height=<PyOleEmpty object at 0x000002B333A49150>)
| Creates a wedge with edges parallel to the axes given the length, width, and height
|
| AddXline(self, Point1=<PyOleEmpty object at 0x000002B333A49150>, Point2=<PyOleEmpty object at 0x000002B333A49150>)
| Creates an xline (an infinite line) passing through two specified points
|
| AttachExternalReference(self, PathName=<PyOleEmpty object at 0x000002B333A49150>, Name=<PyOleEmpty object at 0x000002B333A49150>, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Xscale=<PyOleEmpty object at 0x000002B333A49150>, Yscale=<PyOleEmpty object at 0x000002B333A49150>, Zscale=<PyOleEmpty object at 0x000002B333A49150>, Rotation=<PyOleEmpty object at 0x000002B333A49150>, bOverlay=<PyOleEmpty object at 0x000002B333A49150>, Password=<PyOleEmpty object at 0x000002B333A49150>)
| Attaches an external reference (xref) to the drawing
|
| Bind(self, bPrefixName=<PyOleEmpty object at 0x000002B333A49150>)
| Binds an external reference (xref) to a drawing
|
| Delete(self)
| Deletes a specified object
|
| Detach(self)
| Detachs an external reference (xref) from a drawing
|
| Erase(self)
| Erases all the objects in a selection set
|
| GetExtensionDictionary(self)
| Gets the extension dictionary associated with an object
|
| GetXData(self, AppName=<PyOleEmpty object at 0x000002B333A49150>, XDataType=<PyOleMissing object at 0x000002B333A49390>, XDataValue=<PyOleMissing object at 0x000002B333A49390>)
| Gets the extended data (XData) associated with an object
|
| InsertBlock(self, InsertionPoint=<PyOleEmpty object at 0x000002B333A49150>, Name=<PyOleEmpty object at 0x000002B333A49150>, Xscale=<PyOleEmpty object at 0x000002B333A49150>, Yscale=<PyOleEmpty object at 0x000002B333A49150>, Zscale=<PyOleEmpty object at 0x000002B333A49150>, Rotation=<PyOleEmpty object at 0x000002B333A49150>, Password=<PyOleEmpty object at 0x000002B333A49150>)
| Inserts a drawing file or a named block that has been defined in the current drawing
|
| Item(self, Index=<PyOleEmpty object at 0x000002B333A49150>)
| Gets the member object at a given index in a collection, group, or selection set
|
| Reload(self)
| Reloads the external reference (xref)
|
| SetXData(self, XDataType=<PyOleEmpty object at 0x000002B333A49150>, XDataValue=<PyOleEmpty object at 0x000002B333A49150>)
| Sets the extended data (XData) associated with an object
|
| Unload(self)
| Unloads the menu group or external reference
|
| __call__(self, Index=<PyOleEmpty object at 0x000002B333A49150>)
| Gets the member object at a given index in a collection, group, or selection set
|
| __int__(self, *args)
|
| __iter__(self)
| Return a Python iterator for this object
|
| __len__(self)
| #This class has Count() property - allow len(ob) to provide this
|
| __nonzero__(self)
| #This class has a __len__ - this is needed so 'if object:' always returns TRUE.
|
| __str__(self, *args)
| Return str(self).
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| CLSID = IID('{D113FB37-DE17-4644-8540-B2D35F1272FB}')
|
| coclass_clsid = IID('{9519F17C-24D4-40BE-8A6F-639B0EF82DA0}')
|
| ----------------------------------------------------------------------
| Methods inherited from win32com.client.DispatchBaseClass:
|
| __eq__(self, other)
| Return self==value.
|
| __getattr__(self, attr)
|
| __init__(self, oobj=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ne__(self, other)
| Return self!=value.
|
| __repr__(self)
| Return repr(self).
|
| __setattr__(self, attr, value)
| Implement setattr(self, name, value).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from win32com.client.DispatchBaseClass:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from win32com.client.DispatchBaseClass:
|
| __hash__ = None
blk.Count
21
blk.IsXRef
False
blk.Name
'*Model_Space'
blk.GetXData
<bound method IAcadBlock.GetXData of <win32com.gen_py.AutoCAD 2016 Type Library.IAcadBlock instance at 0x2968727170744>>
slt.Item(0).Handle
'288'
explode=acad.Handle2Object(slt.Item(1).Handle).Explode()
explode
(<win32com.gen_py.AutoCAD 2016 Type Library.IAcadLWPolyline instance at 0x2968734182648>,
<win32com.gen_py.AutoCAD 2016 Type Library.IAcadCircle instance at 0x2968734182704>,
<win32com.gen_py.AutoCAD 2016 Type Library.IAcadText instance at 0x2968734182760>)
explode[2].TextString
'demo2'
slt.Item(2).ObjectID
140696309747552
acad.ObjectID2Object(slt.Item(2).ObjectID)
---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-30-c229de50f3fb> in <module>()
----> 1 acad.ObjectID2Object(slt.Item(2).ObjectID) G:\PycharmProject\PycomCAD\PycomCAD\pycomcad.py in ObjectID2Object(self, ID)
497 return the object of specified ID
498 """
--> 499 return self.acad.ActiveDocument.ObjectIDToObject(ID)
500
501 def GetEntityByItem(self,i): D:\Anaconda\lib\site-packages\win32com\client\__init__.py in __getattr__(self, attr)
471 args=self._prop_map_get_.get(attr)
472 if args is None:
--> 473 raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
474 return self._ApplyTypes_(*args)
475 AttributeError: '<win32com.gen_py.AutoCAD 2016 Type Library.IAcadDocument instance at 0x2968734181360>' object has no attribute 'ObjectIDToObject'
import win32com.client
win32com.client.constants.acSelectionSetAll
5
ss=acad.GetSelectionSets('ss')
ss.Select(5,ft,fd)
ss.Count
24
acad.Handle2Object(slt.Item(3).Handle)==slt.Item(3)
True
acad.Handle2Object(slt.Item(3).Handle) is slt.Item(3)
False

窗口选对象实例

#选择四个点
pnt=acad.GetPoint()
pnt1=acad.GetPoint()
pnt2=acad.GetPoint()
pnt3=acad.GetPoint()
c=list(pnt)+list(pnt1)+list(pnt2)+list(pnt3)
slt=acad.GetSelectionSets('test2')
slt.SelectByPolygon(Mode=win32com.client.constants.acSelectionSetWindowPolygon,PointsList=VtVertex(*c)) #窗口选择,注意PointsList
for i in range(slt.Count):
ent=acad.Handle2Object(slt.Item(i).Handle)
print(ent.TextString)
CW Discharge Culvert before Aeration Tank
Plan & Pile Layout For

需要注意的是 使用SelectByPolygon方法时候,需保证PointsList所围成的矩形区域在CAD窗口内可见范围,否则,该方法将失效。

Pycomcad中的过滤机制及访问引用块内对象简述的更多相关文章

  1. EL的隐含对象(三)【访问环境信息的隐含对象】

    EL中提供了6个访问环境信息的隐含对象.分别是: (1)param对象 param对象用于获取请求参数的值,应用在参数值只有一个的情况.在应用param对象时,返回的结果为字符串. 例:在JSP页面中 ...

  2. Excel 中单元格和范围的引用(即访问的表示方法)

    计算机中,无非是数据和数据的处理这两件事.Excel的工作表能存储大量数据,除了这些原始数据,我们还要用函数来处理这些数据,比如求和求积,求平均值,排序等等,并把处理结果也存在单元格里.在Excel中 ...

  3. C# 中利用反射机制拷贝类的字段和属性(拷贝一个类对象的所有东西付给另一个类对象,而不是付给引用地址)

    from:https://blog.csdn.net/poxiaohai2011/article/details/27555951 //C# 中利用反射机制拷贝类的字段和属性(拷贝一个类对象的所有东西 ...

  4. JVM中垃圾回收机制如何判断是否死亡?详解引用计数法和可达性分析 !

    因为热爱,所以坚持. 文章下方有本文参考电子书和视频的下载地址哦~ 这节我们主要讲垃圾收集的一些基本概念,先了解垃圾收集是什么.然后触发条件是什么.最后虚拟机如何判断对象是否死亡. 一.前言   我们 ...

  5. 深入理解 PHP7 中全新的 zval 容器和引用计数机制

    深入理解 PHP7 中全新的 zval 容器和引用计数机制 最近在查阅 PHP7 垃圾回收的资料的时候,网上的一些代码示例在本地环境下运行时出现了不同的结果,使我一度非常迷惑. 仔细一想不难发现问题所 ...

  6. java-多态中成员访问特点-父类引用指向子类对象

    多态前提: - 要有继承关系. - 要有方法重写. - 要有父类引用指向子类对象. 1.成员变量:编译看左边(父类),运行看左边(父类) 2.成员方法:编译看左边(父类),运行看右边(子类),动态绑定 ...

  7. 深入理解SQL注入绕过WAF和过滤机制

    知己知彼,百战不殆 --孙子兵法 [目录] 0x0 前言 0x1 WAF的常见特征 0x2 绕过WAF的方法 0x3 SQLi Filter的实现及Evasion 0x4 延伸及测试向量示例 0x5 ...

  8. SQL Server 内存中OLTP内部机制概述(三)

    ----------------------------我是分割线------------------------------- 本文翻译自微软白皮书<SQL Server In-Memory ...

  9. SQL Server 内存中OLTP内部机制概述(二)

    ----------------------------我是分割线------------------------------- 本文翻译自微软白皮书<SQL Server In-Memory ...

  10. 深入理解SQL注入绕过WAF与过滤机制

    知己知彼,百战不殆 --孙子兵法 [目录] 0x0 前言 0x1 WAF的常见特征 0x2 绕过WAF的方法 0x3 SQLi Filter的实现及Evasion 0x4 延伸及测试向量示例 0x5 ...

随机推荐

  1. docker - [14] redis集群部署

    本章节是在一个服务器上进行演示 一.准备工作 (1)创建redis集群使用的网络:redis-net docker network create redis-net --subnet 172.38.0 ...

  2. hbase - [02] 分布式安装部署

    一.角色规划 主机名 node01 node02 node03 node04 Zookeeper ○ ○ ○   NameNode ○ ○     JournalNode ○ ○ ○   DataNo ...

  3. Shell - shell中的运算符

    基本语法 使用案例 基本语法 $((运算式)) $[ 运算式 ] 使用案例 # 第一种写法 a=10 b=20 c=`expr ${a} + ${b}` echo "$c" # 第 ...

  4. BUGKU_PWN_OVERFLOW2_WP

    WP_OVERFLOW2 拿到程序,首先放到我们的kali里面看看是多少位的程序,然后在看看有没有什么安全属性 64位程序,并且开启了RELRO,NX 也就是说,这道题我们需要使用ROP绕过 使用id ...

  5. k8s Error: failed to prepare subPath for volumeMount "custom-logo" of container "grafana"

    前言 使用 k8s 挂载卷文件时,使用了 hostPath,type: File volumeMounts: - mountPath: /usr/share/grafana/public/img/gr ...

  6. ant-design-pro 自定义表单 rules规则

    表单输入 <ProFormText name="id" label={intl.formatMessage({ id: 'pages.secret.form.id' })} ...

  7. Django项目如何配置日志文件信息

    1.以dict的方式配置在settings.py中 # 日志文件简单配置 ''' LOGGING = { "version": 1, "disable_existing_ ...

  8. linux查看分区命令和根分区扩容方法

    df 查看文件系统磁盘空间的使用情况df [选项].[FILE]...当我们指定文件参数FILE时,将会显示该文件所在系统的信息-a 显示出所有的文件系统,包括大小只有0 blocks的文件系统:-h ...

  9. 查询Oracle正在执行的sql语句及执行该语句的用户

    SELECT b.sid oracleID, b.username 登录Oracle用户名, b.serial#, spid 操作系统ID, paddr, sql_text 正在执行的SQL, b.m ...

  10. MySQL-排序相关原理分析

    全字段排序和rowId排序 建表语句如下: CREATE TABLE `t` ( `id` int(11) NOT NULL, `city` varchar(16) NOT NULL, `name` ...