Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic error member not found when access userparameters

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
mvgiels
3417 Views, 5 Replies

Ilogic error member not found when access userparameters

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

5 REPLIES 5
Message 2 of 6
LukeDavenport
in reply to: mvgiels

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,,"")
Message 3 of 6
mvgiels
in reply to: LukeDavenport

Hi Luke,

Thank you very much for your quick response. This is the solution that works fine.
regards martijn
Message 4 of 6
LukeDavenport
in reply to: mvgiels

You're welcome Martijn.

Message 5 of 6
DRoam
in reply to: LukeDavenport

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.

Message 6 of 6
LukeDavenport
in reply to: DRoam

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

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

Post to forums  

Autodesk Design & Make Report