- 积分
- 1872
- 明经币
- 个
- 注册时间
- 2006-6-18
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2008-3-18 16:07:00
|
显示全部楼层
本帖最后由 作者 于 2008-3-18 16:13:27 编辑
呵呵,像lisp一样弹出返回值,也可以
不过要写代码才行,举例说明:- public sub VBList()
- ThisDrawing.Utility.GetEntity pickobj, pickpnt, "選擇圖元對象:"
- nameobj = pickobj.ObjectName
- lty = UCase(pickobj.Linetype)
- lay = pickobj.Layer
- color = pickobj.color
- '當為Bylayer or Byblock線型時,找出相應的層的線型
- If lty = "BYLAYER" Or lty = "BYBLOCK" Then
- Set layobj = ThisDrawing.Layers.Item(lay)
- lty = lty & "(" & layobj.Linetype & ")"
- End If
- Select Case nameobj
- Case "AcDbLine"
-
- Case "AcDbCircle"
- get_circle pickobj, lay, lty, color, appname
- Case "AcDbText", "AcDbMText"
- Case "AcDbArc"
- Case "AcDbBlockReference"
- Case "AcDbPolyline"
- .......
- Case Else
- ThisDrawing.SendCommand "_.LIST" & vbCr & "(handent """ & pickobj.Handle & """)" & vbCr & vbCr
- Exit Sub
- End Select
- errordeal:
- If Err.Number <> 0 Then
- Err.Clear
- Exit Sub
- End If
- end Sub
- Private Function get_circle(ByVal pickobj As AcadEntity, ByVal lay As String, ByVal lty As String, ByVal color As String, ByVal appname As String)
- Dim cenpnt As Variant, cirdia As Double
- cenpnt = pickobj.Center
- cenpnt = ThisDrawing.Utility.TranslateCoordinates(cenpnt, acWorld, acUCS, False)
- cirdia = pickobj.Diameter
- cenpnt(0) = Format(cenpnt(0), "0.0000")
- cenpnt(1) = Format(cenpnt(1), "0.0000")
- cenpnt(2) = Format(cenpnt(2), "0.0000")
- cirdia = Format(cirdia, "0.000")
- MsgBox "圖元名: Circle (圓)" & Chr(13) & Chr(13) & "圖層名: " & lay & Chr(13) & Chr(13) & "顏色號: " & color & _
- Chr(13) & Chr(13) & "線型名: " & lty & Chr(13) & Chr(13) & "直徑值: " & cirdia & Chr(13) & Chr(13) & _
- "圓心坐標點: " & "X= " & cenpnt(0) & ",Y= " & cenpnt(1) & ",Z= " & cenpnt(2) & Chr(13) & Chr(13)
- End Function
当然,你可以写更多function处理不同类型的图素。然后根据你所选择的图素类型再调用相应的function处理即可.
|
|