乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 110|回复: 0

[编程交流] VBA, Using Objdimsension to ma

[复制链接]

170

主题

347

帖子

174

银币

中流砥柱

Rank: 25

铜币
870
发表于 2022-7-6 15:22:40 | 显示全部楼层 |阅读模式
AutoCAD 2009 VBA
 
I have been using the following code to pick a
dimension variable in Objdimsension. Then I set my
specific autoCAD variable.
Is it possable to modify this code to pick my
dimension then create & save a dimstyle using all the
variables in objdimension object. Maybe I could loop
thru objdimension then set variables in my
dimstyle object. Does anyone have a sample of this?
 
Code:
Private Sub CommandButton2_Click()
Dim objDimension As AcadDimension
Dim varPickedPoint As Variant
Dim objDimStyle As AcadDimStyle
Dim strDimStyles As String
Dim strChosenDimStyle As String
Dim stg As String
 
On Error Resume Next
   Me.hide
    ThisDrawing.Utility.GetEntity objDimension, varPickedPoint, _
        "Picked a dimension whose style you wish to set"
    If objDimension Is Nothing Then
    MsgBox "You failed to pick a dimension object"
    Exit Sub
    End If
    stg = "Textheight"
 
    'MsgBox objDimension.TextRotation
    'ThisDrawing.SetVariable "CLAYER",
 
objDimension.DimensionLinelayer
 
    MsgBox objDimension.ExtensionLineExtend
    ThisDrawing.SetVariable "dimexe",
 
objDimension.ExtensionLineExtend
    MsgBox objDimension.ExtensionLineOffset
    ThisDrawing.SetVariable "dimexo",
 
objDimension.ExtensionLineOffset
 
    MsgBox objDimension.Layer
    ThisDrawing.SetVariable "CLAYER",
 
objDimension.DimensionLinelayer
 
    MsgBox objDimension.DimensionLineColor
    ThisDrawing.SetVariable "DIMCLRD",
 
objDimension.DimensionLineColor
 
    MsgBox objDimension.ExtensionLineColor
    ThisDrawing.SetVariable "DIMCLRE",
 
objDimension.ExtensionLineColor
    MsgBox objDimension.color
    'Dim text color
    ThisDrawing.SetVariable "DIMCLRT", objDimension.color
 
    MsgBox objDimension.ScaleFactor
    ThisDrawing.SetVariable "Dimscale", objDimension.ScaleFactor
    ThisDrawing.SendCommand "Dimscale" & vbCr
    ThisDrawing.SendCommand objDimension.ScaleFactor & vbCr
 
    MsgBox objDimension.VerticalTextPosition
    ThisDrawing.SetVariable "DIMTAD",
 
objDimension.VerticalTextPosition
 
    MsgBox objDimension.TextHeight
    ThisDrawing.SetVariable "DIMTXT", objDimension.TextHeight
 
 
    '****Text Style
    MsgBox objDimension.TextStyle
    'ThisDrawing.SetVariable "DIMTXT", objDimension.TextHeight
    ThisDrawing.DimStyles.StyleName , objDimension.TextStyle
 
    MsgBox objDimension.TextGap
    ThisDrawing.SetVariable "DIMJUST", objDimension.TextGap
 
    MsgBox objDimension.ArrowheadSize
    ThisDrawing.SetVariable "DIMASZ", objDimension.ArrowheadSize
 
     Set objDimStyle = ThisDrawing.DimStyles.Add("YourNamedStyle")
    objDimStyle.CopyFrom ThisDrawing
    ThisDrawing.ActiveDimStyle = objDimStyle
'Make your changes here....................
      objDimStyle.CopyFrom ThisDrawing
'"YourNameStyle"
objDimStyle.Name = "YourNamedStyle"
End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 18:25 , Processed in 0.346421 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表