VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA tri le TXT in bloc dans listbox idem bloc écran

3 REPLIES 3
Reply
Message 1 of 4
acad386
491 Views, 3 Replies

VBA tri le TXT in bloc dans listbox idem bloc écran

hello
in autocad block 4 line TXT
TXT1 (handle # 3)
TXT2 (handle # 2)
TXT3 (handle No. 4)
TXT4 (handle # 1)

When I recuper the string in a combobox it puts me in the order of handle
TXT4,2,1,3
I then I want in the order of the line screen TXT1,2,3,4

Thank you for your help
********
Bonjour
Dans le bloc autocad 4 lignes de TXT
TXT1 (handle N°3)
TXT2 (handle N°2)
TXT3 (handle N°4)
TXT4 (handle N°1)

Quand je recupere le string dans une combobox il me le met dans l'ordre du handle =>Ligne 4,2,1,3
alors que je je veux dans l'ordre de l'écran ligne 1,2,3,4

Merci pour votre aide

Public Sub LireTxt()
Dim objBloc As AcadBlock
Dim objEnt As AcadEntity
Dim objEntTxT As as AcadText
   
ThisDrawing.Utility.GetEntity objBlocRef, Pt1, "Sélectionnez le bloc à modifier :"
Set objBloc = ThisDrawing.Blocks(objBlocRef.Name)
   
    For Each objEnt In objBloc
        If objEnt.ObjectName = "AcDbText" Then
            ListBoxTxt.AddItem objEntTxT.textString
        Endif
    Next

End Sub

 

3 REPLIES 3
Message 2 of 4
RICVBA
in reply to: acad386

you have to:

1) store LineTexts text in a temporary array

2) order the array

3) fill listbox with sorted array content

 

see the attached example

 

bye

Message 3 of 4
acad386
in reply to: acad386

No good code

view fichier dwg for solution

Message 4 of 4
RICVBA
in reply to: acad386

I got it that you wanted texts sorted by their text value

you'll find the revised code for sorting by text insertion point "Y" coordinate in

http://www.cadtutor.net/forum/showthread.php?84926-VB-Sorts-text-screen-ditto-text-block-in&p=583827...

bye

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost