sanderson Posted October 31, 2012 Share Posted October 31, 2012 In the code below, I am doing a regen after deletion and reinserting some text. The program is reading the extmin variable before the text is deleted or before a regen (at the end of the code prior to the next run), which means the text is being inserted one text height lower than the previous. The goal is to always insert it at the same y-dimension below extmin. If I do a delete and regen manually in the drawing and run the code, it works as I would like. Doing these functions in code seem to be ineffective. Thanks in advance Partial code listing below... Dim minext As Variant minext = ThisDrawing.GetVariable("EXTMIN") Dim min(0 To 2) As Double min(0) = minext(0) min(1) = minext(1) min(2) = minext(2) Dim ip(0 To 2) As Double ip(0) = min(0) ip(1) = min(1) + negret(h * 1.3) ip(2) = 0 ' Check for Text String at coordinates and delete - Option 2 Dim objDataBase As AcadDatabase Dim objBlock As AcadBlock Dim Ent As AcadEntity Dim c As Integer Dim i As Integer Dim entCollection As Collection Dim varHandle As Variant Set entCollection = New Collection For Each objBlock In ThisDrawing.Blocks c = objBlock.Count For i = 0 To c - 1 If TypeOf objBlock.Item(i) Is AcadEntity Then If objBlock.Item(i).Layer = "FILEPATHTEXT" Then entCollection.Add (objBlock.Item(i).Handle) End If End If Next On Error Resume Next For Each varHandle In entCollection Set Ent = ThisDrawing.HandleToObject(CStr(varHandle)) Ent.Delete Next On Error GoTo 0 Next ' Regen after deletion ThisDrawing.SendCommand "ZOOM" & vbCr & "EXTENTS" ThisDrawing.Regen acActiveViewport ' Add Text String Dim dir As String dir = ThisDrawing.GetVariable("DWGPREFIX") Dim fil As String fil = ThisDrawing.GetVariable("DWGNAME") Dim objText2 As AcadText Dim textString As String textString = dir & fil Set objText2 = ThisDrawing.ModelSpace.AddText(textString, ip, h) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.