text formatting

text formatting

mehdi-guida
Advocate Advocate
723 Views
9 Replies
Message 1 of 10

text formatting

mehdi-guida
Advocate
Advocate

Hi

I used below code to put line bearing in a cell of table.

lines_table.SetTextString(i + 2, 1, "%<\\AcObjProp Object(%<\\_ObjId " + line_table_items[i].Split('|')[5].Trim(new char[] { '(', ')' }) + ">%).Angle \\f \"%au5\">%");

the result is :

mehdiguida_0-1689866916480.png

 

What changes in my code can remove spaces and replace  ° instead of d in bearing value ? (like  image below , probably some changes needed in green codes)

 

mehdiguida_1-1689866916481.png

Thank You

0 Likes
724 Views
9 Replies
Replies (9)
Message 2 of 10

daniel_cadext
Advisor
Advisor

Field tags are %%, may be confusing the %%d used for the degree symbol. It might be worth a try to open the Field itself, after you’ve added it to the table, and use the  “Format” property

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 10

Ed__Jobe
Mentor
Mentor

It looks like you are getting the bearing from the Angle property of a line. I would first set a string variable to that value and the do a Replace, substituting U+0021 for the "d". Then build the field string with the edited variable value instead of the Angle property.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 4 of 10

mehdi-guida
Advocate
Advocate

You are right, I pulled out bearing of line and put it in a table cell.

 I don't know how to do your idea :((

0 Likes
Message 5 of 10

Ed__Jobe
Mentor
Mentor

Something like this:

string fieldVal = "%<\\AcObjProp Object(%<\\_ObjId " + line_table_items[i].Split('|')[5].Trim(new char[] { '(', ')' }) + ">%).Angle \\f \"%au5\">%";
fieldVal.Replace("d", "\u0021");

lines_table.SetTextString(i + 2, 1, fieldVal);

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 6 of 10

mehdi-guida
Advocate
Advocate

Thank you for reply

When I use  your code , it works but I lose dynamic property. (by dragging end of lines bearing in table doesn't change anymore). It seems some thing should be added to codes in green in my first message.

0 Likes
Message 7 of 10

Jeff_M
Consultant
Consultant

Using Surveyor angle units is the issue. Their display is hard coded into AutoCAD so I don't believe what you want is possible using those units.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 8 of 10

Ed__Jobe
Mentor
Mentor

@mehdi-guida wrote:

Thank you for reply

When I use  your code , it works but I lose dynamic property. (by dragging end of lines bearing in table doesn't change anymore). It seems some thing should be added to codes in green in my first message.


I didn't realize that you needed that feature. As @Jeff_M mentioned, the "d" is not configurable. I gave you the only option for doing what you asked. You have to choose if you want associativity or the degree symbol. You also won't be able to get rid of the spaces. The bearing format is fixed by the surveyor's units.

 

Your only option would be to submit feedback to get a new option for the surveyor's angle format.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 9 of 10

mehdi-guida
Advocate
Advocate

Thank you for respond.

What is below green codes language ? is it Diesel? if yes do you know if there is any command for manipulating string?

 

lines_table.SetTextString(i + 2, 1, "%<\\AcObjProp Object(%<\\_ObjId " + line_table_items[i].Split('|')[5].Trim(new char[] { '(', ')' }) + ">%).Angle \\f \"%au5\">%");

 

Thank you

0 Likes
Message 10 of 10

Ed__Jobe
Mentor
Mentor

Its just the format codes to create mtext and fields. To see the codes that are used for a field, start the FIELD command and note the field expression at the bottom of the dialog. See below.

acad field dlg.png

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes