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

selection filter text papersize

6 REPLIES 6
Reply
Message 1 of 7
J.Verhoef2251
586 Views, 6 Replies

selection filter text papersize

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?

 

 

 

 

 

 

6 REPLIES 6
Message 2 of 7
SENL1362
in reply to: J.Verhoef2251

TypedValue[] filter = new TypedValue[3];
filter.SetValue(new TypedValue((int)DxfCode.Start, "CIRCLE"), 0);
filter.SetValue(new TypedValue((int)DxfCode.Operator, ">="), 1);
filter.SetValue(new TypedValue(40, 5), 2);
Message 3 of 7
J.Verhoef2251
in reply to: SENL1362

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" ?

 

 

Message 4 of 7
SENL1362
in reply to: J.Verhoef2251

my C# sample showed you how to apply calculation rules, such as Radius >= 1.
You should change that sample into the rule TexhtHeight >= 2.5
Message 5 of 7
J.Verhoef2251
in reply to: SENL1362

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?

 

 

 

Message 6 of 7
SENL1362
in reply to: J.Verhoef2251

no never used it.
Can't you multiply the required textsizes with the plotscale (dimscale)?
Message 7 of 7
J.Verhoef2251
in reply to: SENL1362

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?

 

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