Getting an unexpected dash "-" in String Builder (Inv 2023)

Getting an unexpected dash "-" in String Builder (Inv 2023)

llorden4
Collaborator Collaborator
381 Views
3 Replies
Message 1 of 4

Getting an unexpected dash "-" in String Builder (Inv 2023)

llorden4
Collaborator
Collaborator

I'm starting to get an unexpected dash in my String Builder.

 

'Description generator
Dim oSB as New System.Text.StringBuilder() Dim DescFT As Integer Dim DescIN As Double DescFT = Fix(iProperties.Value("Custom", "Length") * 16) / 16 / 12 DescIN = (Round(iProperties.Value("Custom", "Length") * 16) / 16) - ((DescFT * 12) * 16 / 16) oSB.Clear oSB.Append("PIPE SCH " & PipeSch & " ") oSB.Append(RoundToFraction(PipeSize, 1/8, RoundingMethod.Round) & Chr(34) & " DIA x ") oSB.Append(CStr(DescFT) & "'-") '<---- Extra dash occurs here oSB.Append(If (DescIN < 1 And DescIN > 0, "0 ", "")) oSB.Append(RoundToFraction(DescIN, 1 / 16, RoundingMethod.Round) & Chr(34)) oSB.Append(If (IsThreaded, ", THREADED", "")) If Len(DescOvr) > 3 Then iProperties.Value("Project", "Description") = DescOvr Else iProperties.Value("Project", "Description") = oSB.ToString

 The above code has been working for me well for years, but with 2023 is now adding an extra dash.  If I change the BLUE text above to remove the dash then I get that free extra dash.  While I suppose I can work with this, but if this ever gets fixed later then I have to go back through all my coding to correct for the Inventor fix.  Of course, as it is now, I have to go through all my coding to remove the dash.

 

[Result with above iLogic code]

llorden4_0-1664973945043.png

 

[Result with dash removed from iLogic code]

llorden4_1-1664974036675.png

 

 

Am I overlooking something obvious here?  Is there a new "add a dash after a FT symbol" option I missed that I can turn off?

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
382 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @llorden4.  This is just a wild guess, but is it possible that those two lines of code dealing with the inches portion could be returning a negative number "-5", instead of a positive number "5"?  Maybe a MsgBox, or Logger.Info would be useful between those lines in an attempt to see what's going on there step-by-step.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

llorden4
Collaborator
Collaborator

That was embarrassingly simple, don't know why that didn't even cross my mind.  Yep, this is a 1d-10t error...  thanks!

Autodesk Inventor Certified Professional
0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor

I try to re-write this code to more readable form for me and I gat the same result as @WCrihfield  mentions above.

For given inputs the DescIn is -2

 

Dim PipeSch = "10"
Dim PipeSize = 10
Dim IsThreaded = True
Dim DescOvr = ""
Dim length = 100' iProperties.Value("Custom", "Length")

'Description generator
Dim DescFT As Integer = Fix(length * 16) / 16 / 12
Dim DescIN As Double = (Round(length * 16) / 16) - ((DescFT * 12) * 16 / 16)


Dim description2 = String.Format("PIPE SCH {0} {1}"" DIA x {2}'-{3}{4}""{5}",
     PipeSch,
     RoundToFraction(PipeSize, 1 / 8, RoundingMethod.Round),
     DescFT,
     If(DescIN < 1 And DescIN > 0, "0 ", ""),
     RoundToFraction(DescIN, 1 / 16, RoundingMethod.Round),
     If(IsThreaded, ", THREADED", "")
     )

Logger.Debug(DescIN) ' = -2 for this inputs
Logger.Debug(RoundToFraction(DescIN, 1 / 16, RoundingMethod.Round))
Logger.Debug(description2)
0 Likes