• AutoCAD VBA文字自动对齐操作


    AutoCAD VBA文字自动对齐,代码如下。

    Public Type TextWithPnt
    Index As Long
    TextObj As AcadText
    PntIntX As Double
    PntIntY As Double
    PntLeftX As Double
    PntMidX As Double
    PntRigX As Double
    End Type
    Public OrgTexts() As TextWithPnt
    Public Function CreateSSet(Optional SS As String = "mjtd") As AcadSelectionSet
    On Error Resume Next
    ThisDrawing.SelectionSets(SS).Delete
    Set CreateSSet = ThisDrawing.SelectionSets.Add(SS)
    End Function
    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
    End Sub
    Public Function ssExtents(SS As AcadSelectionSet) As Variant
    Dim Points(), C As Long
    Dim Min As Variant, Max As Variant
    Dim i As Long, j As Long
    C = 0
    For i = 0 To SS.count - 1
    SS.Item(i).GetBoundingBox Min, Max
    ReDim Preserve Points(0 To C + 1)
    Points(C) = Min: Points(C + 1) = Max
    C = C + 2
    Next
    ssExtents = Extents(Points)
    End Function
    Public Function Extents(Points)
    Dim Min As Variant, Max As Variant
    Dim i As Long, j As Long, Pt, RetVal(0 To 1)
    Min = Points(LBound(Points))
    Max = Points(LBound(Points))
    For i = LBound(Points) To UBound(Points)
    Pt = Points(i)
    For j = LBound(Pt) To UBound(Pt)
    If Pt(j) < Min(j) Then Min(j) = Pt(j)
    If Pt(j) > Max(j) Then Max(j) = Pt(j)
    Next
    Next
    RetVal(0) = Min: RetVal(1) = Max
    Extents = RetVal
    End Function

    代码完。

    作者:codee
    文章千古事,得失寸心知。


  • 相关阅读:
    c++ 内存管理
    socket粘包现象加解决办法
    TCP与UDP比较 以及并发编程基础知识
    进程之 Process join方法其他属性与进程Queue
    socket通讯实例与TCP/UDP的区别
    socket介绍
    python中的异常处理机制
    面向对象之多态,多态性,反射,以及基于反射的可拔插设计
    面向对象之元类介绍
    面向对象基础
  • 原文地址:https://www.cnblogs.com/bimgoo/p/2502900.html
Copyright © 2020-2023  润新知