baker Posted June 3, 2011 Posted June 3, 2011 I am looking for an expression that will only display the 2 places to the left of the decimal. I.E.: turn 5280.22 into 80.22 also, i would need it to be able to keep a leading zero if there is one. I.E.: 5509.22 to 09.22 I do work on sites in several States, so a math expression would not return the results i am seeking. thank you. C3D 2012 Quote
Tyke Posted June 4, 2011 Posted June 4, 2011 Here's a macro that will do what you want: Sub ChangeText() Dim strText As String Dim varPick As Variant Dim objEnt As AcadEntity On Error Resume Next With ThisDrawing.Utility .GetEntity objEnt, varPick, vbCr & "Pick the text: " If objEnt Is Nothing Then .Prompt vbCrLf & "You didn't pick any text" Exit Sub Else If objEnt.ObjectName = "AcDbText" Then strText = objEnt.TextString strText = Format(strText, "00.00") strText = Right(strText, 5) objEnt.TextString = strText objEnt.Update End If End If End With End Sub It will also round off the decimal part of the numbers when there are more than two figures after the decimal point and if there is only one figure after the decimal point it will add a trailing zero. eg 1209.908 -> 09.91 or 1209.9 -> 09.90 Quote
sinc Posted June 4, 2011 Posted June 4, 2011 I created a drawing with a Style that should do what you want, but this forum won't allow me to attach it here (file too big). I created it in C3D 2010, then noticed the link to the Expression was broken when I opened it in C3D 2012. So I fixed the broken link, and saved the file as a 2012 version. I went ahead and uploaded both versions - one from C3D 2010, and one from C3D 2012. They can be retrieved from the following links: http://www.ejsurveying.com/downloads/00SpotEl2010.dwg http://www.ejsurveying.com/downloads/00SpotEl2012.dwg Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.