CorelDRAW vba cdr插件 对象标注尺寸

Private Sub Cmdb6_Click()
Dim X As Double, Y As Double, Sx As Double, Sy As Double
Dim pt1 As SnapPoint, pt2 As SnapPoint
Dim s As Shape, SL As Shape, sr As ShapeRange
If ActiveShape Is Nothing Then Exit Sub
Set sr = ActiveSelection.Shapes.All

ActiveDocument.Unit = cdrMillimeter
    For Each s In sr
        s.GetBoundingBox X, Y, Sx, Sy
        Set pt1 = CreateSnapPoint(X, Y - 1)
        Set pt2 = CreateSnapPoint(X + Sx, Y - 1)
        Set SL = ActiveLayer.CreateLinearDimension(cdrDimensionHorizontal, pt1, pt2, True, Precision:=0, ShowUnits:=False, Placement:=cdrDimensionBelowLine, textsize:=IIf(Sx > Sy, Sy / 10, Sx / 10))
        SL.Dimension.TextShape.SetPosition s.CenterX, Y - IIf(Sx > Sy, Sy / 10, Sx / 10)
        With SL.Style.GetProperty("dimension")
'            .SetProperty "precision", 2 '       小数位数
'            .SetProperty "showUnits", 0 '       是否显示单位 0/1
            .SetProperty "textPlacement", 1 '   0、上方,1、下方,2、中间
'            .SetProperty "dynamicText", 0 '    是否可以编辑尺寸0/1
'            .SetProperty "overhang", 500000 '  0、上方,1、下方,2、中间
        End With
        Set pt1 = CreateSnapPoint(X + Sx + 1, Y)
        Set pt2 = CreateSnapPoint(X + Sx + 1, Y + Sy)
        Set SL = ActiveLayer.CreateLinearDimension(cdrDimensionVertical, pt1, pt2, True, Precision:=0, ShowUnits:=False, Placement:=cdrDimensionBelowLine, textsize:=IIf(Sx > Sy, Sy / 10, Sx / 10))
        SL.Dimension.TextShape.SetPosition s.RightX + IIf(Sx > Sy, Sy / 10, Sx / 10), s.CenterY
        With SL.Style.GetProperty("dimension")
'            .SetProperty "precision", 2 '       小数位数
'            .SetProperty "showUnits", 0 '       是否显示单位 0/1
            .SetProperty "textPlacement", 1 '   0、上方,1、下方,2、中间
'            .SetProperty "dynamicText", 0 '    是否可以编辑尺寸0/1
'            .SetProperty "overhang", 500000 '  0、上方,1、下方,2、中间
        End With
    Next s


End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值