Hi,
I need some help on an error situation in Ilogic. I will explain how to reproduce the error. Any thoughts how to solve?
I defined an external Ilogic Rule only containing this code:
Dim doc as Document Dim oMyParameter as UserParameters doc = ThisApplication.ActiveDocument oMyParameter = doc.ComponentDefinition.Parameters.UserParameters
When running the Rule after creating a new ipt all runs fine
Then creating new iam, Run Rule, immidiately This error pops up:
Error in rule: MyPropertymanager, in document: ED150091.ipt
Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
System.Runtime.InteropServices.COMException (0x80020003): Member not found. (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 LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Erorr is raised on the last line,
Thanks for any advise
best regards, martijn
Solved! Go to Solution.
Solved by LukeDavenport. Go to Solution.
Hi Martijn,
I think you need to treat assemblydocument and partdocument a little differently as shown below - that works fine for me.
Does that work?
Luke
Dim oDoc As Document = ThisApplication.ActiveEditDocument Dim oPartDoc As PartDocument Dim oAsmDoc As AssemblyDocument Dim oMyParameter as UserParameters If oDoc.DocumentType = kPartDocumentObject Then MsgBox("Its a part",,"") oPartDoc = ThisApplication.ActiveEditDocument oMyParameter = oPartDoc.ComponentDefinition.Parameters.UserParameters Else If oDoc.DocumentType = kAssemblyDocumentObject MsgBox("Its an assembly",,"") oAsmDoc = ThisApplication.ActiveEditDocument oMyParameter = oAsmDoc.ComponentDefinition.Parameters.UserParameters End If MsgBox("User parameter count is " & oMyParameter.Count,,"")
Hi @LukeDavenport, I was hoping you could shed some light on why treating parts and assemblies differently is necessary? I have some code that's doing the exact same thing for a mix of parts and assemblies, and I don't want to have to double up my code just to handle parts and assemblies individually.
If you could take a look at the new thread I opened up here and answer there, I would appreciate it.
Hi DRoam,
Its not necessary to treat parts and assemblies differently in this case, just my inexperience. I wish I could go back to my coding self 4 years ago and tell him that, but alas 🙂
Posted a suggestion on your thread.
Luke