- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Since this is only part of a larger function, and I also don't know what the rest of the main may look like, the simplest thing I can think of it to just put that bit of code within a Try...Catch...End Try block of code, so that it will 'handle' the error the way you choose to. You can put whatever you want in the Catch portion of that block of code, and it will do that when the Try portion fails. I usually include a MsgBox with something specific, and maybe error details, then usually a line to either exit the rule, or exit the Sub/Function it is in, but that's up to you. Here's what it might look like:
Try
Dim smlength = SheetMetal.FlatExtentsLength 'sheet metal flat pattern length
Dim smwidth = SheetMetal.FlatExtentsWidth 'sheet metal flat pattern width
Dim AreaPronest As Double = (smlength + Parameter("Thickness")) * (smwidth + Parameter("Thickness")) / 144
Dim oSMthk As Double = Parameter("Thickness")
If Parameter("Thickness") >= 0.1875 Then
getstock ="Plate, " & Format(oSMthk, "0.000") & " thk x " & Format(AreaPronest, "0.00") & " ft^2"
Else
getstock ="Sheet Metal, " & Format(oSMthk, "0.000") & " thk x " & Format(AreaPronest, "0.00") & " ft^2"
End If
Catch oEx As Exception
MsgBox("Failed to get SheetMetal.FlatExtents size." & vbCrLf & _
oEx.Message & vbCrLf & oEx.StackTrace, vbExclamation, "iLogic")
Exit Function
End Try
...but you could just comment out the stuff in the Catch portion, if that doesn't suit your needs.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)