Stuck in iLogic with IsiAssemblyMember

Stuck in iLogic with IsiAssemblyMember

Rob67ert
Collaborator Collaborator
1,439 Views
5 Replies
Message 1 of 6

Stuck in iLogic with IsiAssemblyMember

Rob67ert
Collaborator
Collaborator

I need some help form you 🙂

I have some iLogic that helps te determine what sort of file I have, I will use it do let it run some other iLogic.

The whole routine runs good, but it gives an error when I save an iAssembly member.

Hope someone can help me get the error out and make a good working routine.

 

The error: 

Error in rule: 00_Start, in document: ilogic Test iAssembly File-01.iam

Kan lid niet vinden. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

 

More Info:

System.Runtime.InteropServices.COMException (0x80020003): Kan lid niet vinden. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Here the part of the routine that gives an error:

SyntaxEditor Code Snippet

Dim oDoc As Document = ThisDoc.Document
'Assembly file
If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
    If oDoc.ComponentDefinition.IsiAssemblyFactory Then
        MessageBox.Show("This is an iAssemblyFactory", "I will stop")
        Return
    Else If oDoc.ComponentDefinition.IsiAssemblyMember Then
        MessageBox.Show("This is an iAssemblyMember", "I will stop")            'Here it gives an error when I save the iAssembly Members
        Return
    End If
MessageBox.Show("This is an Assembly", "I will Return")
End If

 

 

The whole code:

SyntaxEditor Code Snippet

Dim oDoc As Document = ThisDoc.Document
'Presentation file
If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPresentationDocumentObject Then
    MessageBox.Show("This is a Presentation", "I will stop")
    Return
'Part file
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject And oDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
    If oDoc.ComponentDefinition.IsiPartFactory Then
        MessageBox.Show("This is an iPartFactory", "I will stop")
        Return
    Else If oDoc.ComponentDefinition.IsiPartMember Then
        MessageBox.Show("This is an iPartMember", "I will stop")
        Return
    End If
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        MessageBox.Show("You have a sketch active in a part file.", "Stop the Sketch")
    Else
        MessageBox.Show("This is a Part", "I will Return")
    End If
'SheetMetal file
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject And oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        MessageBox.Show("You have a sketch active in a part file.", "Stop the Sketch")
    Else
        MessageBox.Show("This is a Sheetmetal Part", "I will Return")
    End If
'Assembly file
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
    If oDoc.ComponentDefinition.IsiAssemblyFactory Then
        MessageBox.Show("This is an iAssemblyFactory", "I will stop")
        Return
    Else If oDoc.ComponentDefinition.IsiAssemblyMember Then
        MessageBox.Show("This is an iAssemblyMember", "I will stop")            'Here it gives an error when I save the iAssembly Members
        Return
    End If
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        MessageBox.Show("You have a sketch active in an assembly file.", "Stop the Sketch")
    Else
        MessageBox.Show("This is an Assembly", "I will Return")
    End If
'Drawing file
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        MessageBox.Show("You have a sketch active in a drawing file.", "Stop the Sketch")
    Else
        MessageBox.Show("This is a Drawing", "I will Return")
    End If
MessageBox.Show("How did I get here?", "???")
End If
MessageBox.Show("I have Returend", "Yeah")

 

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Accepted solutions (1)
1,440 Views
5 Replies
Replies (5)
Message 2 of 6

Rob67ert
Collaborator
Collaborator

Anyone have any ideas?

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Message 3 of 6

t_hascj
Autodesk
Autodesk

Hi Robert,

I was not able to reproduced your issue on my dataset. Could you provide a dataset?

Thanks,
Jaroslav

0 Likes
Message 4 of 6

Rob67ert
Collaborator
Collaborator

Hi,

 

Here the test files.

What is have noticed is that is sometimes happen with the iPart and the other time with the iAssembly.

After you restart Inventor is will work for some time.

 

My test methode:

save the file and for the iPart en iAssembly, first a Rebuild all and then Generate files.

 

Error message: 

Error in rule: What File is it, in document: ilogic Test iAssembly File.iam

Kan lid niet vinden. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Message 5 of 6

t_hascj
Autodesk
Autodesk
Accepted solution

Hi Robert,

Could you try to update your code:

Before:

Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
    If oDoc.ComponentDefinition.IsiAssemblyFactory Then
        MessageBox.Show("This is an iAssemblyFactory", "I will stop")
        Return
    Else If oDoc.ComponentDefinition.IsiAssemblyMember Then
        MessageBox.Show("This is an iAssemblyMember", "I will stop")            'Here it gives an error when I save the iAssembly Members
        Return
    End If
...


After:

Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
    Dim oAssyDoc As Inventor.AssemblyDocument = oDoc
    If oAssyDoc.ComponentDefinition.IsiAssemblyFactory Then
        MessageBox.Show("This is an iAssemblyFactory", "I will stop")
        Return
    Else If oAssyDoc.ComponentDefinition.IsiAssemblyMember Then
        MessageBox.Show("This is an iAssemblyMember", "I will stop")            'Here it gives an error when I save the iAssembly Members
        Return
    End If
...

Jaroslav


0 Likes
Message 6 of 6

Rob67ert
Collaborator
Collaborator

Thank you Jaroslav,

 

To make it bulletproof I changed this to:

SyntaxEditor Code Snippet

Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject And oDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
    Dim oPartDoc As Inventor.PartDocument = oDoc
    If oPartDoc.ComponentDefinition.IsiPartFactory Then
        'MessageBox.Show("This is an iPartFactory", "I will stop")
        Return
    Else If oPartDoc.ComponentDefinition.IsiPartMember Then
        'MessageBox.Show("This is an iPartMember", "I will stop")
        Return
    End If

 It works great now.

Thanks.

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes