Boolean error reported on a string concatenate attempt - 2022.2.2

Boolean error reported on a string concatenate attempt - 2022.2.2

llorden4
Collaborator Collaborator
445 Views
3 Replies
Message 1 of 4

Boolean error reported on a string concatenate attempt - 2022.2.2

llorden4
Collaborator
Collaborator

I've not had this issue before, so I believe this is a new issue with this update.  I'm getting a Boolean conversion error while attempting to concatenate a string.  I've broken down the lines into small segments and the occurs with just a simple "Temp = Temp &" once it enters the condition statement shown in my ilogic snippet below.

 

Temp = "EV02:V1-"
If DoubleVang Then Temp = Temp & "D" Else Temp = Temp & "S"						'Double or Single vang
If Vertical Then Temp = Temp & "V" Else Temp = Temp & "H"						'Vertical or Horizontal orientation
If RoundCap Then Temp = Temp & "R" Else Temp = Temp & "F"						'Round or Facetted to match arm
If PointOnTop Then Temp = Temp & "P" Else Temp = Temp & "F"						'Point or Flat on top of arm
Temp = Temp & Right(CStr(NoSides + 100), 2) &									'Number of sides on arm
Right(CStr(Round(oMatThick / 1 in * 16) + 100), 2) &							'Material thickness [in] (value/16) [2 digits]
Right(CStr(Round(CapRad * 2 / 1 in * 8) + 1000), 3) 							'Cap Diameter [in] (value/8) [3 digits] {to facetted point or rounded edge}
If DrainHoles Then
	Temp = Temp &    'this is causing a boolean conversion error
	":DH" &
	Right(CStr(NoSides + 100), 2) &
	CStr(oNoDrainHoles)	& 														'# of drain holes (actual value) [1 digit]
	Temp = Temp & Right(CStr(Round(HoleDia / 1 in * 16) + 100), 2) &			'drain hole diameter (value/16) [2 digits]
	Right(CStr(Round(DistY / 1 in * 16) + 1000), 3) &							'X offset value (value / 16) [3 digits]
	Temp = Temp & Right(CStr(Round(DistX / 1 in * 16) + 1000), 3)				'Y offset value (value / 16) [3 digits]
	If r = 0.5 in Then Temp = Temp & "A" Else Temp = Temp & "B"
	If h = 0.5 in Then Temp = Temp & "A" Else Temp = Temp & "B"
	If VangThick > 0 And Not VertVang Then Temp = Temp & "S" Else Temp = Temp & "X"
End If

llorden4_0-1645523394157.png

 

 

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

JelteDeJong
Mentor
Mentor

I could not reproduce the problem. But creating strings by chaining lots of strings is not the most efficient thing to do. It's slow and not good for readability. In this case I would suggest to use the System.Text.StringBuilder(). Also if you are using if statement on on line I would suggest to use the short-If statement.  Your could would then look like this:

Dim builder As New System.Text.StringBuilder()
builder.Append("EV02:V1-")
builder.Append(If(DoubleVang, "D", "S")) 							'Double or Single vang
builder.Append(If(Vertical, "V", "H"))								'Vertical or Horizontal orientation
builder.Append(If(RoundCap, "R", "F"))								'Round or Facetted to match arm
builder.Append(If(PointOnTop, "P", "F"))							'Point or Flat on top of arm

builder.Append(Right(CStr(NoSides + 100), 2))						'Number of sides on arm
builder.Append(Right(CStr(Round(oMatThick / 1 in  * 16) + 100), 2))	'Material thickness [in] (value/16) [2 digits]
builder.Append(Right(CStr(Round(CapRad * 2 / 1 in * 8) + 1000), 3))	'Cap Diameter [in] (value/8) [3 digits] {to facetted point or rounded edge}
						
If DrainHoles Then
	builder.Append(":DH")
	builder.Append(Right(CStr(NoSides + 100), 2))
	builder.Append(CStr(oNoDrainHoles))								'# of drain holes (actual value) [1 digit]
	builder.Append(Right(CStr(Round(HoleDia / 1 in * 16) + 100), 2))'drain hole diameter (value/16) [2 digits]
	builder.Append(Right(CStr(Round(DistY / 1 in * 16) + 1000), 3))	'X offset value (value / 16) [3 digits]
	builder.Append(Right(CStr(Round(DistX / 1 in * 16) + 1000), 3))	'Y offset value (value / 16) [3 digits]
	builder.Append(If(r = 0.5 in, "A", "B"))
	builder.Append(If(h = 0.5 in, "A", "B"))
	builder.Append(If(VangThick > 0 And Not VertVang,"S", "X"))
End If
Dim Temp = builder.ToString()

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 4

llorden4
Collaborator
Collaborator
Accepted solution

I uninstalled updates back to 2022.1.1 and the issue still didn't clear.

 

Removed the condition statement and just ran the routine and error remained, so that wasn't the problem.

 

Re-installed updates back to 2022.2.2 and had a return of the CDT without an error report pop-up after the crash (just opened the file, no actions yet taken).

 

I created a brand new file, re-created my rather long list of parameters in the new file and copied my iLogic code as-is into the new file and ran without issue.  So some type of garbage is getting collected behind the scenes of my code development that is messing with the files.

 

Wishing for a way to copy the entire Parameter library from one file to another, this is such a PITA.

Autodesk Inventor Certified Professional
0 Likes
Message 4 of 4

llorden4
Collaborator
Collaborator

Thanks for the tip, will give that a go.

Autodesk Inventor Certified Professional
0 Likes