I know that Attribute(3) will work but this routine has to work on 15 year's worth of borders of varing sizes and revisions. All have Attribute("Title1") but they won't all have Attribute(3) = "Title1", some will be Attrbute(0), some Attribute(20). I had hoped I could go directly to "Title1" as I thought I had seen it done before but it works stepping through so I'm happy.
For sake of completeness here is my code. Very quick & dirty and could easilly be improved but it works so I expect it will stay.
- Option ExplicitPrivate Sub cmdDown_Click()Dim myString As StringSelect Case Label5.CaptionCase Is = "1"myString = lblTag1.CaptionlblTag1.Caption = lblTag2.CaptionlblTag2.Caption = myStringLabel5.Caption = "2"lblTag2.SpecialEffect = fmSpecialEffectEtchedlblTag1.SpecialEffect = fmSpecialEffectSunkenCase Is = "2"myString = lblTag2.CaptionlblTag2.Caption = lblTag3.CaptionlblTag3.Caption = myStringLabel5.Caption = "3"lblTag3.SpecialEffect = fmSpecialEffectEtchedlblTag2.SpecialEffect = fmSpecialEffectSunkenCase Is = "3"myString = lblTag3.CaptionlblTag3.Caption = lblTag4.CaptionlblTag4.Caption = myStringLabel5.Caption = "4"lblTag4.SpecialEffect = fmSpecialEffectEtchedlblTag3.SpecialEffect = fmSpecialEffectSunkenEnd SelectEnd SubPrivate Sub cmdExit_Click()Unload MeEnd SubPrivate Sub cmdPopulate_Click()Dim myObject As ObjectDim mySelectionSet As AcadSelectionSetDim myAttributes As VariantSet mySelectionSet = ThisDrawing.SelectionSets.Add("Fred")Dim gpCode(0 To 1) As IntegerDim dataValue(0 To 1) As VariantDim groupCode As VariantDim dataCode As VariantgpCode(0) = 2 'namegpCode(1) = 0 'itemgroupCode = gpCodedataValue(0) = "STLA*" 'layer namedataValue(1) = "INSERT" 'item typedataCode = dataValuemySelectionSet.Select acSelectionSetAll, , , groupCode, dataCodeSet myObject = mySelectionSet.Item(0)myAttributes = myObject.GetAttributesIf lblTag1.Caption "" Then myAttributes(Label1).TextString = lblTag1.Caption Else myAttributes(Label1).TextString = "" End IfIf lblTag2.Caption "" Then myAttributes(Label2).TextString = lblTag2.Caption Else myAttributes(Label2).TextString = "" End IfIf lblTag3.Caption "" Then myAttributes(Label3).TextString = lblTag3.Caption Else myAttributes(Label3).TextString = "" End IfIf lblTag4.Caption "" Then myAttributes(Label4).TextString = lblTag4.Caption Else myAttributes(Label4).TextString = "" End IfThisDrawing.SelectionSets.Item("Fred").DeleteUnload MeEnd SubPrivate Sub cmdUp_Click()Dim myString As StringSelect Case Label5.CaptionCase Is = "2"myString = lblTag2.CaptionlblTag2.Caption = lblTag1.CaptionlblTag1.Caption = myStringLabel5.Caption = "1"lblTag1.SpecialEffect = fmSpecialEffectEtchedlblTag2.SpecialEffect = fmSpecialEffectSunkenCase Is = "3"myString = lblTag3.CaptionlblTag3.Caption = lblTag2.CaptionlblTag2.Caption = myStringLabel5.Caption = "2"lblTag2.SpecialEffect = fmSpecialEffectEtchedlblTag3.SpecialEffect = fmSpecialEffectSunkenCase Is = "4"myString = lblTag4.CaptionlblTag4.Caption = lblTag3.CaptionlblTag3.Caption = myStringLabel5.Caption = "3"lblTag3.SpecialEffect = fmSpecialEffectEtchedlblTag4.SpecialEffect = fmSpecialEffectSunkenEnd SelectEnd SubPrivate Sub lblTag1_Click()Label5.Caption = "1"lblTag1.SpecialEffect = fmSpecialEffectEtchedlblTag2.SpecialEffect = fmSpecialEffectSunkenlblTag3.SpecialEffect = fmSpecialEffectSunkenlblTag4.SpecialEffect = fmSpecialEffectSunkenEnd SubPrivate Sub lblTag2_Click()Label5.Caption = "2"lblTag2.SpecialEffect = fmSpecialEffectEtchedlblTag1.SpecialEffect = fmSpecialEffectSunkenlblTag3.SpecialEffect = fmSpecialEffectSunkenlblTag4.SpecialEffect = fmSpecialEffectSunkenEnd SubPrivate Sub lblTag3_Click()Label5.Caption = "3"lblTag3.SpecialEffect = fmSpecialEffectEtchedlblTag1.SpecialEffect = fmSpecialEffectSunkenlblTag2.SpecialEffect = fmSpecialEffectSunkenlblTag4.SpecialEffect = fmSpecialEffectSunkenEnd SubPrivate Sub lblTag4_Click()Label5.Caption = "4"lblTag4.SpecialEffect = fmSpecialEffectEtchedlblTag1.SpecialEffect = fmSpecialEffectSunkenlblTag2.SpecialEffect = fmSpecialEffectSunkenlblTag3.SpecialEffect = fmSpecialEffectSunkenEnd SubPrivate Sub UserForm_Initialize()Dim i As IntegerDim myObject As ObjectDim mySelectionSet As AcadSelectionSetDim myAttributes As VariantSet mySelectionSet = ThisDrawing.SelectionSets.Add("Fred")Dim gpCode(0 To 1) As IntegerDim dataValue(0 To 1) As VariantDim groupCode As VariantDim dataCode As VariantgpCode(0) = 2 'namegpCode(1) = 0 'itemgroupCode = gpCodedataValue(0) = "STLA*" 'layer namedataValue(1) = "INSERT" 'item typedataCode = dataValuemySelectionSet.Select acSelectionSetAll, , , groupCode, dataCodeIf mySelectionSet.Count = 1 Then'a block has been selectedSet myObject = mySelectionSet.Item(0)myAttributes = myObject.GetAttributesFor i = 0 To UBound(myAttributes) - 1If myAttributes(i).TagString = "TITLE1" Then lblTag1 = myAttributes(i).TextString Label1 = i End IfIf myAttributes(i).TagString = "TITLE2" Then lblTag2 = myAttributes(i).TextString Label2 = i End IfIf myAttributes(i).TagString = "TITLE3" Then lblTag3 = myAttributes(i).TextString Label3 = i End IfIf myAttributes(i).TagString = "TITLE4" Then lblTag4 = myAttributes(i).TextString Label4 = i End IfNext iElseMsgBox "This ONLY works with 1 Drawing Border"End IfThisDrawing.SelectionSets.Item("Fred").DeleteEnd Sub
It basically gets the 4 "title" attributes from one of our borders and displays them on a form. You can then shuffle the order of the attributes and write them back to the title block. |