.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

selectionfilter to promptselectionresult

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
J.Verhoef2251
720 Views, 2 Replies

selectionfilter to promptselectionresult

I am trying to write a command to autoselect all text with a specific textstylename and change the color of it.

 

This is my code at this moment:

 

<CommandMethod("TK")> _
Public Sub Tekstkleur()


'' Get the current document and database
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = DocumentManager.MdiActiveDocument.Editor

 

'' Start a transaction
Using acTrans As Transaction = db.TransactionManager.StartTransaction()

Dim WFO1(0) As TypedValue

 

'' Create a TypedValue array to define the filter criteria

WFO1.SetValue(New TypedValue(DxfCode.TextStyleName, "WFO 1.5"), 0)

 

'' Assign the filter criteria to a SelectionFilter object
Dim selectiefilter As New SelectionFilter(WFO1)


'' Request for objects to be selected in the drawing area
Dim acSSPrompt As PromptSelectionResult = ed.GetSelection(selectiefilter)

 

'' If the prompt status is OK, objects were selected
If acSSPrompt.Status = PromptStatus.OK Then
Dim acSSet As SelectionSet = acSSPrompt.Value

 

'' Step through the objects in the selection set
For Each acSSObj As SelectedObject In acSSet


'' Check to make sure a valid SelectedObject object was returned
If Not IsDBNull(acSSObj) Then


'' Open the selected object for write
Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId, _
OpenMode.ForWrite)

If Not IsDBNull(acEnt) Then


'' Change the object's color to Green
acEnt.ColorIndex = 3
End If
End If
Next

 

'' Save the new object to the database
acTrans.Commit()
End If

 


'' Dispose of the transaction
End Using

End Sub

 

 

When i debug the command i can change the color but it doesn't work automatically because when i'm at "Dim acSSPrompt As PromptSelectionResult = ed.GetSelection(selectiefilter)" It asks me to select objects in Autocad. When i select several objects, it only selects text with stylename: "WFO 1.5" so that works. But i want autocad to automatically select all text with stylename: "WFO 1.5".

 

Can someone help me out with this?

2 REPLIES 2
Message 2 of 3
gsktry
in reply to: J.Verhoef2251

Hi,

 

If I properly understand your question, replace 

 

ed.GetSelection(selectiefilter)

 

into 

 

ed.SelectAll(selectiefilter)

 

Regards,

gsktry

 

 

 

Message 3 of 3
J.Verhoef2251
in reply to: gsktry

i knew it was simple but didn't know what haha

Thanks it worked:)

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost