明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2811|回复: 5

[原创]给text加框的程序

[复制链接]
发表于 2009-7-30 19:11:00 | 显示全部楼层 |阅读模式

'文字画框
Sub WZhk()
  On Error Resume Next
 
  Dim mypnt1 As Variant
  Dim mypnt2  As Variant
    mypnt1 = ThisDrawing.Utility.GetPoint(, "请选择左下角点:")
    mypnt2 = ThisDrawing.Utility.GetCorner(mypnt1, "请选择右上角点:")

'crossing 方法选择所有内部对象
    Dim sset1 As AcadSelectionSet
    If Not IsNull(ThisDrawing.SelectionSets.Item("SS1")) Then
        Set sset1 = ThisDrawing.SelectionSets.Item("SS1")
        sset1.Delete
    End If
    Set sset1 = ThisDrawing.SelectionSets.Add("SS1")

'定义过滤规则
    Dim filterType1(0) As Integer
    Dim filterData1(0) As Variant

    filterType1(0) = 0
    filterData1(0) = "TEXT"
    sset1.Select acSelectionSetCrossing, mypnt1, mypnt2, filterType1, filterData1 ' 使用Crossing选择模式,选择内部所有对象(包含边界本身)

    Dim ADTEXT As AcadText
    Dim MINPT As Variant
    Dim MAXPT As Variant
    Dim RECPL As AcadLWPolyline
    For Each ADTEXT In sset1
        ADTEXT.GetBoundingBox MINPT, MAXPT
        Set RECPL = 绘制矩形(MINPT, MAXPT, 0)
    Next
 
End Sub

发表于 2009-7-30 20:14:00 | 显示全部楼层

给text和mtext文字同时加框程序演示如下:

 

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2009-7-31 16:16:00 | 显示全部楼层
绘制矩形的函数呢?
发表于 2009-8-29 14:48:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2011-6-13 13:17:24 | 显示全部楼层
通过对角两点绘制矩形的函数


  函数内容:

Function AddRectangle(varPnt1 As Variant, varPnt2 As Variant) As AcadLWPolyline

  On Error GoTo Err_Control
   
  Dim objSpace As AcadBlock
    If ThisDrawing.ActiveSpace = acModelSpace Then
      Set objSpace = ThisDrawing.ModelSpace
    Else
      Set objSpace = ThisDrawing.PaperSpace
    End If
      
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 7) As Double
     
    points(0) = varPnt1(0): points(1) = varPnt1(1)
    points(2) = varPnt1(0): points(3) = varPnt2(1)
    points(4) = varPnt2(0): points(5) = varPnt2(1)
    points(6) = varPnt2(0): points(7) = varPnt1(1)
     
    Set plineObj = objSpace.AddLightWeightPolyline(points)

      plineObj.Closed = True
    Set AddRectangle = plineObj
            
Exit_Here:
  Exit Function
   
Err_Control:
  Resume Exit_Here

End Function


  
发表于 2012-4-20 17:47:46 | 显示全部楼层
加的方框角度是固定的0度,并不会随文字角度而变化
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 17:33 , Processed in 0.187796 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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