Message 1 of 12
Error 0x80004005 on first run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am new to iLogic and VB and cannot figure out this error I keep getting
I want to put thread on all holes with a matching diameter (Minor Dia), using the following code:
Sub Main()
Dim oPartCompDef As PartComponentDefinition = ThisDoc.Document.componentdefinition
Dim oThreadFeatures As ThreadFeatures = oPartCompDef.Features.ThreadFeatures
Dim oThreadFeature As ThreadFeature
For Each oThreadFeature In oThreadFeatures
If oThreadFeature.HealthStatus = kCannotComputeHealth Or oThreadFeature.HealthStatus = kDriverLostHealth Then
oThreadFeature.Delete
End If
Next
Dim oSurfaceBodies As SurfaceBodies = oPartCompDef.SurfaceBodies
Dim oSrfBody As SurfaceBody
Dim oFaces As Faces
Dim oFace As Face
Dim oEdges As Edges
Dim oEdge As Edge
Dim oThreadInfo As ThreadInfo
Dim sThreadType As String
For Each oSrfBody In oSurfaceBodies
oFaces = oSrfBody.Faces
For Each oFace In oFaces
If oFace.SurfaceType = kCylinderSurface Then
If oFace.ThreadInfos Is Nothing Then
sThreadType = GetThreadTypeFromRadius(oFace.Geometry.Radius)
If Not sThreadType Is Nothing Then
oEdges = oFace.Edges
oEdge = oEdges.Item(1)
oThreadInfo = oThreadFeatures.CreateStandardThreadInfo(True, True, "ISO Metric Profile", sThreadType, "6H")
oThreadFeature = oThreadFeatures.Add(oFace, oEdge, oThreadInfo, False, True)
End If
End If
End If
Next
Next
End Sub
Function GetThreadTypeFromRadius(dRadius As Double) As String
Dim sThreadType As String
Select Round(dRadius, 3)
Case 0.078
sThreadType = "M2x0.4"
Case 0.123
sThreadType = "M3x0.5"
Case 0.162
sThreadType = "M4x0.7"
Case 0.207
sThreadType = "M5x0.8"
Case 0.246
sThreadType = "M6x1"
Case 0.332
sThreadType = "M8x1.25"
Case 0.419
sThreadType = "M10x1.5"
Case 0.505
sThreadType = "M12x1.75"
Case 0.592
sThreadType = "M14x2"
Case 0.692
sThreadType = "M16x2"
' Case Else
' Nothing
End Select
Return sThreadType
End Function
Easy way to replicate: New part > Sketch > Extrude > make hole(s) with diameter of 6,647 mm (hole feature or extrude-cut a circle) > Run Rule...
This should place "M8x1,25" thread feature(s)
I always get an error on the first run after I open a part, every subsequent run works like expected
(no matter if I remove any or all existing thread features or not)
System.Runtime.InteropServices.COMException (0x80004005): Niet nader omschreven fout (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.Face.get_SurfaceType()
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
So this line would be the place to look:
If oFace.SurfaceType = kCylinderSurface Then
But I cannot figure out what the problem could be
Any help would be much appreciated