livingice 发表于 2007-11-27 16:28:00

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

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

兰州人 发表于 2007-11-28 14:15:00

本帖最后由 作者 于 2007-11-28 14:43:15 编辑 <br /><br /> <p>主要用以下两条语句。</p><p>TextOverRide--------指定标注的文字字符串。</p><p>Measurement--------获取标注的测量单位。</p><p>Sub lls()<br/>&nbsp; Dim dd As AcadDimension<br/>&nbsp; Dim ent As AcadEntity<br/>&nbsp; For Each dd In ThisDrawing.ModelSpace<br/>&nbsp;&nbsp;&nbsp; Debug.Print dd.ObjectName<br/>&nbsp;&nbsp;&nbsp; 'Debug.Print dd.TextOverride<br/>&nbsp;&nbsp;&nbsp; Debug.Print dd.Measurement<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp; Next dd<br/>End Sub</p><p></p>

兰州人 发表于 2007-11-28 14:28:00

<p>更改标注尺寸值的&lt;&gt;为真实值</p><p>来自<a href="http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=665">http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=665</a></p><p>Public Sub SelfOverRide(objDim As AcadDimension)<br/>Dim objBlk As AcadBlock<br/>Dim objEnt As AcadEntity<br/>Dim varPos As Variant<br/>Dim varInsPnt As Variant<br/>Dim objDimText As AcadMText<br/>Dim objBlocks As AcadBlocks<br/>Dim blnDone As Boolean<br/>Set objBlocks = ThisDrawing.Blocks<br/>varPos = objDim.TextPosition<br/>For Each objBlk In objBlocks<br/>If Not blnDone Then<br/>If Left(objBlk.Name, 2) = "*D" Then<br/>For Each objEnt In objBlk<br/>If TypeOf objEnt Is AcadMText Then<br/>Set objDimText = objEnt<br/>varInsPnt = objDimText.InsertionPoint<br/>If varInsPnt(0) = varPos(0) Then<br/>If varInsPnt(1) = varPos(1) Then<br/>objDim.TextOverride = objDimText.TextString<br/>blnDone = True<br/>Exit For<br/>End If<br/>End If<br/>End If<br/>Next objEnt<br/>End If<br/>Else<br/>Exit For<br/>End If<br/>Next objBlk<br/>End Sub<br/><br/>Sub TEST_SelfOverRide()<br/>Dim strPrmt As String<br/>Dim objEnt As AcadEntity<br/>Dim varPnt As Variant<br/>Dim IsDimension As Boolean<br/>Dim objDim As AcadDimension<br/><br/>On Error GoTo Err_Handler<br/>strPrmt = vbCr &amp; "选择标注对象:"<br/>ThisDrawing.Utility.GetEntity objEnt, varPnt, strPrmt<br/><br/>Set objDim = objEnt<br/>SelfOverRide objDim<br/><br/>Exit Sub<br/>Err_Handler:<br/>MsgBox Err.Number &amp; vbCrLf &amp; Err.Description<br/>End Sub</p>

livingice 发表于 2007-11-30 12:15:00

多谢指教

感谢前辈指教   一定好好研究研究
页: [1]
查看完整版本: 请教如何编程(vb)实现对已有DWG图中的部分尺寸修改