明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1673|回复: 3

请教如何编程(vb)实现对已有DWG图中的部分尺寸修改

[复制链接]
发表于 2007-11-27 16:28:00 | 显示全部楼层 |阅读模式

小女子初学AutoCAD和SolidWorks的二次开发,想用vb实现把AutoCAD中的尺寸数据读出,用于SolidWorks的建模中。诚心希望能得到各位前辈的指点。

发表于 2007-11-28 14:15:00 | 显示全部楼层
本帖最后由 作者 于 2007-11-28 14:43:15 编辑

主要用以下两条语句。

TextOverRide--------指定标注的文字字符串。

Measurement--------获取标注的测量单位。

Sub lls()
  Dim dd As AcadDimension
  Dim ent As AcadEntity
  For Each dd In ThisDrawing.ModelSpace
    Debug.Print dd.ObjectName
    'Debug.Print dd.TextOverride
    Debug.Print dd.Measurement
   
  Next dd
End Sub

发表于 2007-11-28 14:28:00 | 显示全部楼层

更改标注尺寸值的<>为真实值

来自http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=665

Public Sub SelfOverRide(objDim As AcadDimension)
Dim objBlk As AcadBlock
Dim objEnt As AcadEntity
Dim varPos As Variant
Dim varInsPnt As Variant
Dim objDimText As AcadMText
Dim objBlocks As AcadBlocks
Dim blnDone As Boolean
Set objBlocks = ThisDrawing.Blocks
varPos = objDim.TextPosition
For Each objBlk In objBlocks
If Not blnDone Then
If Left(objBlk.Name, 2) = "*D" Then
For Each objEnt In objBlk
If TypeOf objEnt Is AcadMText Then
Set objDimText = objEnt
varInsPnt = objDimText.InsertionPoint
If varInsPnt(0) = varPos(0) Then
If varInsPnt(1) = varPos(1) Then
objDim.TextOverride = objDimText.TextString
blnDone = True
Exit For
End If
End If
End If
Next objEnt
End If
Else
Exit For
End If
Next objBlk
End Sub

Sub TEST_SelfOverRide()
Dim strPrmt As String
Dim objEnt As AcadEntity
Dim varPnt As Variant
Dim IsDimension As Boolean
Dim objDim As AcadDimension

On Error GoTo Err_Handler
strPrmt = vbCr & "选择标注对象:"
ThisDrawing.Utility.GetEntity objEnt, varPnt, strPrmt

Set objDim = objEnt
SelfOverRide objDim

Exit Sub
Err_Handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub

 楼主| 发表于 2007-11-30 12:15:00 | 显示全部楼层

多谢指教

感谢前辈指教   一定好好研究研究
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 12:41 , Processed in 0.177343 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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