I’ve been working on a drawing template update tool and have found almost everything I need to get things working. The remaining, albeit small, portion that I’d like to add is leaders to Revision Balloons, if they had them previously.
I’m using IAnnotation.SetLeader in order to create a leader that I can modify. From there, I’m using IAnnotation.SetPosition and IAnnotation.SetLeaderAttachmentPointAtIndex and it appears to work well. I’m just not sure why it’s moving when it’s rebuilt.
Does anyone have experience with this?
GIFs:
This is the macro running without any rebuilds of any type
This is after the macro has run and the drawing is rebuilt. The revision balloon moves
I saw the post and didn’t really have an idea yet can you at least post the code so we’re not just guessing?
The note needs to be attached to geometry. Maybe you’re breaking that link? I’ve seen notes show up at the origin before, but I don’t remember when or why.
Here’s the code pertaining to the revision bubble addition and leader modification.
You got me thinking that I might need to call some method of attachment to place the end of the leader on the entity that held it before. I’ll have to look into this as well, but if you have any other suggestions in the meantime, I’d appreciate it.
Set iNote = swDraw.InsertRevisionSymbol(symbolPosition(0), symbolPosition(1))
Set iAnno = iNote.GetAnnotation
If bwasAttached Then
Dim g As Integer
Dim ileaderIndex As Integer
For g = 0 To UBound(leaderInfoIndex)
Dim tempArray As Variant
tempArray = leaderInfoIndex(g)
If Not IsEmpty(tempArray) Then
If CStr(tempArray(0)) = iNote.GetText Then
ileaderIndex = g
Exit For
End If
End If
Next g
Dim leaderInformationArray() As Variant
Dim leaderInformation() As Double
leaderInformationArray = leaderInfo(ileaderIndex)
leaderInformation = leaderInformationArray(arrayIndex)
Dim bRet As Boolean
Dim iRet As Long
iRet = iAnno.SetLeader3(swLeaderStyle_e.swBENT, swLeaderSide_e.swLS_SMART, True, True, False, False)
swModel.Rebuild swRebuildOptions_e.swRebuildAll
Dim sPos() As Double
sPos = iAnno.GetPosition
iAnno.SetPosition2 symbolPosition(0), symbolPosition(1), sPos(2)
swModel.Rebuild swRebuildOptions_e.swRebuildAll
iAnno.Select3 False, Nothing
bRet = iAnno.SetLeaderAttachmentPointAtIndex(0, leaderInformation(0), leaderInformation(1), leaderInformation(2))
bRet = iAnno.SetLeaderAttachmentPointAtIndex(1, leaderInformation(3), leaderInformation(4), leaderInformation(5))
If bExtraLeader Then
bRet = iAnno.SetLeaderAttachmentPointAtIndex(2, leaderInformation(6), leaderInformation(7), leaderInformation(8))
End If
End If
@PeterBrinkhuis You were on the right track with this. Unfortunately I can’t share the full source code, as I’m sure you understand. Setting the attached entities worked to get the notes to stay in their place. They do move a tiny bit, however they point to the correct spot which is what I was initially trying to accomplish.