how to turn of error notification - Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

how to turn of error notification - Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

srinivasanyl
Contributor Contributor
903 Views
4 Replies
Message 1 of 5

how to turn of error notification - Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

srinivasanyl
Contributor
Contributor

Steps to reproduce
Hi,
Im using one ilogic rule for extend length of the flat patten objects.
i added the rule in event trigger - part - before save.
some of the parts does not the flat pattern type parts like rods, angles etc..
eventhough the rule runs for that type of parts and its not an issue. but error notification is coming. how to avoid/or turn off this error message?
ilogic Code was
extents_length = SheetMetal.FlatExtentsLength
extents_width = SheetMetal.FlatExtentsWidth
iProperties.Value("Custom", "LENGTH") = extents_length
iProperties.Value("Custom", "WIDTH") = extents_width
iProperties.Value("Custom", "THK") = Parameter("Thickness")


Expected results
A modified Code


Actual results
image attached


URL where issue occurs
-


Browser
Microsoft Edge


OS
Windows


Attachment



0 Likes
Accepted solutions (1)
904 Views
4 Replies
Replies (4)
Message 2 of 5

FINET_Laurent
Advisor
Advisor
Accepted solution

Hi @srinivasanyl,

 

You could simply put this code in a try /catch statement like so :

Try
	extents_length = SheetMetal.FlatExtentsLength
	extents_width = SheetMetal.FlatExtentsWidth
	iProperties.Value("Custom", "LENGTH") = extents_length
	iProperties.Value("Custom", "WIDTH") = extents_width
	iProperties.Value("Custom", "THK") = Parameter("Thickness")
	
Catch
	
End Try

Here is some info : Visual Basic Try Catch Statement - Tutlane

 

Kind regards,
FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 5

Michael.Navara
Advisor
Advisor

Another option without exception handling is to check the DocumentSubType and exit rule when the document is not sheet metal part

 

Dim isShetmetal As Boolean = ThisDoc.Document.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" 
If Not isShetmetal Then Return
0 Likes
Message 4 of 5

Michael.Navara
Advisor
Advisor

Both of this methods works, but if you are interested about performance, my method is approximately

  • 8-times faster for another rule call
  • 400-times faster when you stay in the same rule

You can check the benchmark in attached document.

 

 

Sub main

	Dim start0 = DateTime.Now
	For i = 0 To 1000
		DocumentSubTypeCheck()
	Next
	Dim duration0 = DateTime.Now - start0


	Dim start1 = DateTime.Now
	For i = 0 To 1000
		TryCatchException()
	Next
	Dim duration1 = DateTime.Now - start1


	Logger.Debug("{0:N0} - DocumentSubTypeCheck", duration0.TotalMilliseconds)
	Logger.Debug("{0:N0} - TryCatchException", duration1.TotalMilliseconds)
End Sub


Sub DocumentSubTypeCheck()
	Dim isShetmetal As Boolean = ThisDoc.Document.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
	If Not isShetmetal Then Return

	extents_length = SheetMetal.FlatExtentsLength
	extents_width = SheetMetal.FlatExtentsWidth
	iProperties.Value("Custom", "LENGTH") = extents_length
	iProperties.Value("Custom", "WIDTH") = extents_width
	iProperties.Value("Custom", "THK") = Parameter("Thickness")

End Sub


Sub TryCatchException()
	Try
		extents_length = SheetMetal.FlatExtentsLength
		extents_width = SheetMetal.FlatExtentsWidth
		iProperties.Value("Custom", "LENGTH") = extents_length
		iProperties.Value("Custom", "WIDTH") = extents_width
		iProperties.Value("Custom", "THK") = Parameter("Thickness")
	Catch
	End Try

End Sub

 

 

 

0 Likes
Message 5 of 5

FINET_Laurent
Advisor
Advisor

FINET_Laurent_0-1690526116640.png

 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill