那位老大能解释解释着程序中的代码啊
更改标注尺寸值的<>为真实值不少地方看不懂.................
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> <FONT color=#dd2222>If Left(objBlk.Name, 2) = "*D" Then</FONT><BR> For Each objEnt In objBlk<BR> <FONT color=#cc3333>If TypeOf objEnt Is AcadMText Then</FONT><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
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 & "选择标注对象:"<BR> ThisDrawing.Utility.GetEntity objEnt, varPnt, strPrmt<BR> <BR> <FONT color=#d52b2b>Set objDim = objEnt</FONT><BR> SelfOverRide objDim
Exit Sub<BR>Err_Handler:<BR> MsgBox Err.Number & vbCrLf & Err.Description<BR>End Sub <FONT color=#dd2222>If Left(objBlk.Name, 2) = "*D" Then</FONT>
<FONT color=#dd2222>标注实际上是一个无名块,以 "*D" 开头</FONT>
<FONT color=#cc3333>If TypeOf objEnt Is AcadMText Then</FONT>
<FONT color=#cc3333>取得标注中的标注文字</FONT>
<FONT color=#d52b2b>Set objDim = objEnt</FONT>
<BR>将获得的标注对象类型转换为标注,因为SelfOverRide的参数为AcadDimension 谢谢呵呵
这个 <FONT color=#d52b2b>Set objDim = objEnt </FONT>
<FONT color=#d52b2b>我还不太明白</FONT>
Dim objEnt As AcadEntity<BR>Dim objDim As AcadDimension 不一样的东西啊 怎么就=了。
有什么特别的作用是吧?
第一个子程序中还有这个类似的 Set objDimText = objEnt 因为SelfOverRide的入口参数为AcadDimension
如果定义为Public Sub SelfOverRide(objDim As AcadEntity)<BR>可以不要这一句 那这段代码中哪里能体现出:更改标注尺寸值的<>为真实值
真实值?? 这里:
objDim.TextOverride = objDimText.TextString <FONT color=#d52b2b>Set objDim = objEnt <BR>这样做是一种正规的作法,对于编程者可以利用VBA的智能提示来显示标注对象特有的智能提示。对于使用者看程序时也好明白。</FONT> 很久的帖子啊,不过学了很多~
页:
[1]