用VBA怎样选择一个图层的所有内容??
用VBA怎样选择一个图层的所有内容??请高手给个具体例子!! 我也正想解决这个问题呢。。。<div><br/></div> <p>'****************创建带过滤器的选择集Start******************"</p><p>'创建过滤集<br/>Public Sub BuildFilter(ByRef TypeArray, ByRef DataArray, ByRef gCodes() As Variant)<br/> Dim fType() As Integer, fData()<br/> Dim index As Long, i As Long<br/> <br/> index = LBound(gCodes) - 1<br/> For i = LBound(gCodes) To UBound(gCodes) Step 2<br/> index = index + 1<br/> ReDim Preserve fType(0 To index)<br/> ReDim Preserve fData(0 To index)<br/> fType(index) = CInt(gCodes(i))<br/> fData(index) = gCodes(i + 1)<br/> Next<br/> TypeArray = fType: DataArray = fData<br/> <br/>End Sub</p><p>'功能:创建选择集<br/>Public Function CreateSelectionSet(Optional ByVal ssName As String = "ss") As AcadSelectionSet</p><p> Dim ss As AcadSelectionSet<br/> On Error Resume Next<br/> Set ss = ThisDrawing.SelectionSets(ssName)<br/> If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)<br/> ss.Clear<br/> Set CreateSelectionSet = ss</p><p>End Function<br/> <br/> 'ParamArray定义的的数组在SUB内不能再做为实参传递<br/>Public Sub BuildFilterAndCteSset(sset, ssName, ParamArray gCodes())<br/> '定义过滤器<br/> Dim pType, pData<br/> Dim codes() As Variant<br/> <br/> codes = gCodes<br/> BuildFilter pType, pData, codes<br/> <br/> '定义选择集<br/> Set sset = CreateSelectionSet(ssName)<br/> <br/> '根据以上指定的过滤器建立选择集<br/> sset.Clear<br/> sset.Select acSelectionSetAll, , , pType, pData<br/> '这里可以通过Select、SelectAtPoint、SelectByPolygon、SelectOnScreen等方法<br/> '配合Mode和Point1、Point2建立更加用户化的选择集<br/> <br/>End Sub<br/>'********************创建带过滤集的选择集end********************"</p><p>'应用实例</p><p>'通过在CAD命令行输入:(entget(car(entsel)))获取的对象基本特性</p><p>Public Sub LayerSS()<br/> Dim sset As AcadSelectionSet<br/> BuildFilterAndCteSset sset, "ss", 8, "层名" <br/>End Sub</p>
页:
[1]