iLogic error in rule

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have used the below rule in a number of assemblies and it seems to work fine:
SyntaxEditor Code Snippet
Sub Main auto = iLogicVb.Automation ' Set Rule name Dim ruleName As String ruleName = "Flat_Pattern_Assy" ' Get the active assembly. Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument ' Get all of the referenced documents. Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments ' Iterate through the list of documents. Dim oRefDoc As Document For Each oRefDoc In oRefDocs If oRefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Dim rule As Object rule = auto.GetRule(oRefDoc, ruleName) 'If (rule Is Nothing) Then'Call MsgBox("No rule named " & ruleName & " was found in the document.")'Else'MessageBox.Show(rule.Name, oRefdoc.displayname) Dim i As Integer i = auto.RunRuleDirect(rule) End If Next End Sub
However, I have just derived a part and created a multi-body model and then used 'Make Components' to create a new assembly. My rule above is set to run on save but the below error occurs regardless of when I am running the rule:
Error in rule: Flat_Pattern_Parts, in document: 04864_001.iam
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateGet(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)
I would appreciate any help.
Thanks