通过过滤器选择对象

来源:互联网 发布:ipad翻墙软件 编辑:程序博客网 时间:2024/06/07 07:49
Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.Geometry
Imports ZWCAD
Imports ZwSoft.ZwCAD.EditorInput




Public Class Class1
    <CommandMethod("AutoMerge")> _
    Public Sub AutoMerge()


        Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ZcDB As Database = ZcDoc.Database
        Dim ZcEd As Editor = ZcDoc.Editor


        Dim tvs As TypedValue() = New TypedValue(0) {New TypedValue(CInt(DxfCode.Start), "ACAD_TABLE")}
        Dim sf As New SelectionFilter(tvs)
        Dim psr As PromptSelectionResult = ZcEd.SelectAll(sf)


        If psr.Status = PromptStatus.OK AndAlso psr.Value.Count > 0 Then
            Using ZcTrans As Transaction = ZcDB.TransactionManager.StartTransaction()
               
                For Each obj As SelectedObject In psr.Value
                    Dim dbObj As DBObject = ZcTrans.GetObject(obj.ObjectId, OpenMode.ForWrite)
                    Dim tbl As Table = TryCast(dbObj, Table)
                    Dim columns As Int16 = tbl.NumColumns
                    tbl.MergeCells(New TableRegion(0, 0, 0, columns - 1))
                Next


                ZcTrans.Commit()
            End Using
        End If
    End Sub


End Class


‘多个过滤条件

 'Dim tvs As TypedValue() = New TypedValue() {New TypedValue(CInt(DxfCode.[Operator]), "<or"), New TypedValue(CInt(DxfCode.[Operator]), "<and"), New TypedValue(CInt(DxfCode.LayerName), "0"), New TypedValue(CInt(DxfCode.Start), "LINE"), New TypedValue(CInt(DxfCode.[Operator]), "and>"), New TypedValue(CInt(DxfCode.[Operator]), "<and"), _
        ' New TypedValue(CInt(DxfCode.Start), "CIRCLE"), New TypedValue(CInt(DxfCode.[Operator]), ">="), New TypedValue(CInt(DxfCode.Real), 10.0), New TypedValue(CInt(DxfCode.[Operator]), "and>"), New TypedValue(CInt(DxfCode.[Operator]), "or>")}


        'Dim sf As New SelectionFilter(tvs)
        'Dim psr As PromptSelectionResult = ed.SelectAll(sf)

0 0