Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About the HRESULT:0x80020003 (DISP_E_MEMBERNOTFOUND))??

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Stakin
3013 Views, 1 Reply

About the HRESULT:0x80020003 (DISP_E_MEMBERNOTFOUND))??

this is my code to count all the Parts of an assembly,and sort out all the normal Parts from it (store in an arraylist)?

but some times it can work perfectly,sometimes it lead to an error of HRESULT:0x80020003.

 

 

System.Runtime.InteropServices.COMException (0x80020003): Can not find Member。 (Error From HRESULT:0x80020003 (DISP_E_MEMBERNOTFOUND))
   In Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
   In LmiRuleScript.SaveToCSVFile(Document asmDoc, String FileDir, ArrayList oFNL, ArrayList oFNLL)
   In LmiRuleScript.Main()
   In Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   In iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 By repeatedly running the code,I found:

 

If I manually open the component files and parts, and then run the code, are generally not wrong, otherwise, an error will occur HRESULT:0x80020003.

 

 

how to solve this problem?

 

Imports System.IO 
Public Sub Main()
	Dim SelectFile_DlgName	As String	=	"Please Select File"
	Dim my_File 			As String 	= GetDataFileName( SelectFile_DlgName)			
	If my_File="Cancel"	 Then
		Exit Sub
	End If
	Dim oTDoc As Inventor.Document	
    Dim oDoc As Inventor.AssemblyDocument
	oTDoc=ThisApplication.Documents.Open(my_File,False)
	If oTDoc.DocumentType<>Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
		MsgBox("Not Assembly(*.iam)!",16,"FileSelect Error")
		oTDoc.Close
		Exit Sub
	Else
		oTDoc.Close
		oDoc=ThisApplication.Documents.Open(my_File,False)		
    End If	
    
	Call ChangePhMain(oDoc)
'	oCompDef = oDoc.ComponentDefinition
	Dim oFNL As ArrayList =New ArrayList()
	Dim oFNLL As ArrayList =New ArrayList()

	Call SaveToCSVFile(oDoc,IPJ_Folder_Location,oFNL,oFNLL)
	Call CreateIDW(oFNLL,oDoc)
	oDoc.Close
End Sub
Private Sub ChangePhMain(ByVal oDoc As Inventor.Document)
    Dim sMsg As String
	Dim oCompDef As Inventor.ComponentDefinition 
    Dim iLeafNodes As Long
    Dim iSubAssemblies As Long
    Dim oCompOcc As ComponentOccurrence
	oCompDef = oDoc.ComponentDefinition
    For Each oCompOcc In oCompDef.Occurrences
        If oCompOcc.SubOccurrences.Count = 0 Then
			Call ChangeBOMStructureToPhan(oCompOcc)
            iLeafNodes = iLeafNodes + 1
        Else
            iSubAssemblies = iSubAssemblies + 1
            Call processAllSubOcc(oCompOcc,iLeafNodes,iSubAssemblies) 
        End If
    Next
End Sub	


Private Sub WriteStructure(ByVal oFNL As ArrayList,ByVal Occurrences As ComponentOccurrences, ByVal Level As Integer, ByVal SWT0 As System.IO.StreamWriter)
	Dim occ As ComponentOccurrence
	Dim Output_count As Double
	For Each occ In Occurrences
			oFNL.Add(occ.Definition.Document.FullFileName)
			SWT0.WriteLine(occ.Definition.Document.FullFileName )
		If occ.DefinitionDocumentType = kAssemblyDocumentObject Then
			Call WriteStructure(oFNL,occ.SubOccurrences, Level + 1, SWT0)
		End If
	Next

End Sub
Private Sub processAllSubOcc(ByVal oCompOcc As ComponentOccurrence, ByRef iLeafNodes As Long, ByRef iSubAssemblies As Long)    
    Dim oSubCompOcc As ComponentOccurrence
    For Each oSubCompOcc In oCompOcc.SubOccurrences
        If oSubCompOcc.SubOccurrences.Count = 0 Then
 			Call ChangeBOMStructureToPhan(oSubCompOcc)
            iLeafNodes = iLeafNodes + 1
        Else
			iSubAssemblies = iSubAssemblies + 1
            Call processAllSubOcc(oSubCompOcc, iLeafNodes, iSubAssemblies)
        End If
    Next
End Sub
Private Sub ChangeBOMStructureToPhan(ByVal oCompOcc As ComponentOccurrence)
'Inventor.BOMStructureEnum.kPhantomBOMStructure=51971
	If Left(oCompOcc.Name,8)="ISO 33.7" Then
		oCompOcc.Definition.BOMStructure=Inventor.BOMStructureEnum.kPhantomBOMStructure
	ElseIf oCompOcc.DefinitionDocumentType()=Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
		If oCompOcc.SubOccurrences.Count=0 Then
			oCompOcc.Definition.BOMStructure()=Inventor.BOMStructureEnum.kPhantomBOMStructure
		End If
	ElseIf oCompOcc.DefinitionDocumentType()=Inventor.DocumentTypeEnum.kPartDocumentObject Then
		If oCompOcc.Definition.SurfaceBodies.Count=0 Then
			oCompOcc.Definition.BOMStructure()=Inventor.BOMStructureEnum.kPhantomBOMStructure
		End If
	End If
End Sub
Private Sub SaveToCSVFile(ByVal asmDoc As Inventor.Document,ByVal FileDir As String,ByVal oFNL As ArrayList,ByVal oFNLL As ArrayList)
	Dim csvFilename As String=Left(asmDoc.FullDocumentName(),Len(asmDoc.FullDocumentName())-3)&"txt"
	Dim saveDialog As Inventor.FileDialog
	Dim oProperty As Inventor.Property
	Dim j As Integer
	Dim i As Integer =0
	Dim SWT0 As System.IO.StreamWriter = New StreamWriter(csvFilename)
	Using(SWT0)
		Call WriteStructure( oFNL, asmDoc.ComponentDefinition.Occurrences, 1, SWT0)
	End Using
	Dim SWT1 As System.IO.StreamWriter = New StreamWriter(csvFilename & "-Count.Txt")
	Using(SWT1)
	oFNLL.Add(asmDoc.FullFileName() )
	i=0
	While(i<>oFNL.Count())
		Dim FNN As Integer=0
		Dim oFNNL As ArrayList =New ArrayList()
		For j= 0 To oFNL.Count()-1
			If oFNL(i)=oFNL(j) Then
				FNN=FNN+1
				oFNNL.Add(j)
			End If
		Next
		For Each oTTDOC In  asmDoc.AllReferencedDocuments
			If oTTDOC.FullDocumentName=oFNL(i) Then
				SWT1.WriteLine("{0}:{1}:{2}",oFNL(i),FNN,CStr(oTTDOC.ComponentDefinition.BOMStructure))
				If oTTDOC.ComponentDefinition.BOMStructure=Inventor.BOMStructureEnum.kNormalBOMStructure Then
					Try 
						oProperty=oTTDOC.PropertySets.Item("D5CDD505-2E9C-101B-9397-08002B2CF9AE").Item("User-Count")
						oProperty.Value=Str(FNN)
					Catch
						oProperty=oTTDOC.PropertySets.Item("D5CDD505-2E9C-101B-9397-08002B2CF9AE").Add(Str(FNN),"User-Count")
					End Try
					oFNLL.Add(oFNL(i))					
				End If
			End If
		Next
		If oFNNL.Count()>1 Then
			For j=1 To oFNNL.Count()-1
				oFNL.RemoveAt(oFNNL(j)-j+1)
			Next
		End If
		i=i+1
	End While		
	End Using

End Sub
Private Function GetDataFileName(oDialgTitle As String	)    As String
	Dim oFileDlg As Inventor.FileDialog
	Call ThisApplication.CreateFileDialog(oFileDlg)
	oFileDlg.Filter = "AutoDesk Inventor File (*.ipt;*.iam;*.ipn)|*.ipt;*.iam;*.ipn|All Files (*.*)|*.*"
	oFileDlg.FilterIndex = 1
	oFileDlg.DialogTitle = oDialgTitle
	oFileDlg.CancelError = True
	Try
		oFileDlg.ShowOpen
		GetDataFileName = oFileDlg.FileName
	Catch
		GetDataFileName = "Cancel"	
	End Try	
End Function

 

 

 1.png

 

 

 

1 REPLY 1
Message 2 of 2
Stakin
in reply to: Stakin

The same code, but also led to another mistake  HRESULT:0x80004001

 

System.NotImplementedException: 尚未实现 (异常来自 HRESULT:0x80004001 (E_NOTIMPL))
   在 System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   在 Inventor.ComponentDefinition.set_BOMStructure(BOMStructureEnum )
   在 LmiRuleScript.ChangeBOMStructureToPhan(ComponentOccurrence oCompOcc)
   在 LmiRuleScript.ChangePhMain(Document oDoc)
   在 LmiRuleScript.Main()
   在 Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   在 iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

3.png

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report