明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2361|回复: 10

请帮忙吧,如何得到过滤选择集中的对象的属性呀!

[复制链接]
发表于 2002-9-28 18:54:00 | 显示全部楼层 |阅读模式
如题。我做了一个直线的过滤的选择集,我需要了解直线的开始点以及终端点的坐标。我该如和做了。我首先定义了一个
   Dim sset As AcadSelectionSet
   dim Lline as acadline
  set lline=sset.item(i)
可是就是不行呀我该如何?!
发表于 2002-9-28 20:29:00 | 显示全部楼层

一点问题都没有,请看以下提供的整个过程的例程

Sub GetLinePnt()
    Dim ss As AcadSelectionSet
    Set ss = CreateSelectionSet()
    Dim fType As Variant
    Dim fData As Variant
    BuildFilter fType, fData, 0, "Line"
    ss.SelectOnScreen fType, fData
    Dim Lline As AcadLine
    Dim I As Integer
   
    Dim StarPnt As Variant
    Dim EndPnt As Variant
    Dim DispInfo As String
    For I = 0 To ss.Count - 1
        Set Lline = ss.Item(I)
        StarPnt = Lline.StartPoint
        EndPnt = Lline.EndPoint
        DispInfo = DispInfo & "第" & I + 1 & "根线的起点坐标:" & PTos(StarPnt) & " 终点坐标:" & PTos(EndPnt) & vbCrLf
    Next
        MsgBox DispInfo, , "明经通道制作例程 http://www.mjtd.com "
  End Sub

Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
    Dim fType() As Integer, fData()
    Dim index As Long, I As Long
   
    index = LBound(gCodes) - 1
        
    For I = LBound(gCodes) To UBound(gCodes) Step 2
        index = index + 1
        ReDim Preserve fType(0 To index)
        ReDim Preserve fData(0 To index)
        fType(index) = CInt(gCodes(I))
        fData(index) = gCodes(I + 1)
    Next
    typeArray = fType: dataArray = fData
End Sub

Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet



    Dim ss As AcadSelectionSet
   
    On Error Resume Next
    Set ss = ThisDrawing.SelectionSets(ssName)
    If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
    ss.Clear
    Set CreateSelectionSet = ss


End Function

Private Function PTos(P As Variant) As String
    Dim S As String
    Dim pp(2) As Double
    pp(0) = P(0)
    pp(1) = P(1)
    S = RTOS(pp(0)) & ", " & RTOS(pp(1))
    If UBound(P) > 1 Then
       pp(2) = P(2)
        S = S & ", " & RTOS(pp(2))
    End If
    PTos = S
End Function

Private Function RTOS(Real As Double) As String
  RTOS = ThisDrawing.Utility.RealToString(Real, acDefaultUnits, LuPrec)
End Function
 楼主| 发表于 2002-9-30 10:08:00 | 显示全部楼层

谢谢老大!

真太感谢老大了。呵呵
发表于 2003-3-22 16:27:00 | 显示全部楼层

版主,能帮忙将以上代码转到vb中吗?

版主,能帮忙将以上代码转到vb中吗?

点评

VB代码与VBA代码仅仅是acadapp.activedocument与ThisDrawing不同,这也要麻烦老大吗?  发表于 2018-5-7 08:58
发表于 2015-10-12 15:20:09 | 显示全部楼层
mccad 发表于 2002-9-28 20:29
Sub GetLinePnt()
    Dim ss As AcadSelectionSet
    Set ss = CreateSelectionSet()

我也试试,谢谢您
发表于 2015-11-4 12:11:00 | 显示全部楼层
求vb代码,谢谢大神啊啊·····················
发表于 2015-11-4 12:11:31 | 显示全部楼层
求vb代码,谢谢大神啊啊·····················
发表于 2018-5-6 21:57:18 | 显示全部楼层
如何过滤AcadBlockReference块中的属性(如用Block 命令手工定义的块的属性)
发表于 2018-5-6 22:03:10 | 显示全部楼层
mccad 发表于 2002-9-28 20:29
Sub GetLinePnt()
    Dim ss As AcadSelectionSet
    Set ss = CreateSelectionSet()

(entget(car(entsel)))
选择对象: ((-1 . <图元名: -14ed80>) (0 . "INSERT") (330 . <图元名: -151308>) (5 . "160")
(100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
"AcDbBlockReference") (66 . 1) (2 . "属性块1") (10 167.816 113.892 0.0) (41 . 1.0)
(42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210
0.0 0.0 1.0))
可是我想要通过"属性块"内的“厚度”值过滤参数该怎么办?

点评

也许是我水平有限吧,我觉得属性恐怕不能直接用组码进行过滤,扩展数据应该可以。  发表于 2018-5-7 09:03
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 06:55 , Processed in 0.189424 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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