I'm writing a code to change the color of all text in a drawing depending on text size.
Thickness has te be 1/10 of the textheight.
Text with a papersize of 2.5 should get a color that has a thickness of 0.25 mm in the pentable.
At the moment this is the only code that works but i have to link the selectionfilter to a textstyle.
My code:
' Start a transaction
Using acTrans As Transaction = db.TransactionManager.StartTransaction()
Dim mytextstyle(0) As TypedValue
'' Create a TypedValue array to define the filter criteria
mytextstyle.SetValue(New TypedValue(DxfCode.TextStyleName, "text2.5"), 0)
Dim selectiefilter As New SelectionFilter(WFO)
'' Request for objects to be selected in the drawing area
Dim acSSPrompt As PromptSelectionResult = ed.SelectAll(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
acEnt.ColorIndex = 7
End If
End If
Next
End If
'' Save the new object to the database
acTrans.Commit()
'' Dispose of the transaction
End Using
(repeated with different text styles text5, text3.5, text1.5)
The textstyle text2.5 has a papersize of 2.5 but when i scale the text to 5 for example it will not change its color to the right of course.
I know i can use dxfCode.txtPsize but how can i use an selectionfilter that filters textsize between two values?
It doesnt accept TypedValue[] so i chaged it to TypedValue().
But it also doesnt accept the (int) part
Why do i need Dxfcode.Start, "circle" ?
Thanks, this helped me a lot further.
This code now works now.
WFO.SetValue(New TypedValue(DxfCode.Start, "text"), 0)
WFO.SetValue(New TypedValue(DxfCode.Operator, ">="), 1)
WFO.SetValue(New TypedValue(DxfCode.TxtSize, 200), 2)
WFO.SetValue(New TypedValue(DxfCode.Operator, "<"), 3)
WFO.SetValue(New TypedValue(DxfCode.TxtSize, 300), 4)
Unfortunately Dxfcode.txtPsize doesn't work when i debug it (error at acSSPrompt).
I also triend using 42 instead of dxfcode.txtPsize.
TxtSize takes the value of model space height so it goes wrong when i print in different scales than 1:100.
Have you ever used DxfCode.TxtPSize?
Yes i thought about it.
I dont use paperspace so i have to take the scale from the specific text.
WFO.SetValue(New TypedValue(DxfCode.Start, "text"), 0)
WFO.SetValue(New TypedValue(DxfCode.Operator, ">="), 1)
WFO.SetValue(New TypedValue((DxfCode.TxtSize) / (DxfCode.TxtStyleXScale), 2), 2)
WFO.SetValue(New TypedValue(DxfCode.Operator, "<"), 3)
WFO.SetValue(New TypedValue((DxfCode.TxtSize) / (DxfCode.TxtStyleXScale), 3), 4)
The questions are now:
Do i need to multiply or devide? Depending if a scale of 1:100 has a value of 0.01 or 100.
Do i need to use dxfcode.TxtStyleXScale, dxfcode.shapescale or pixelscale?