CPython 3, Apply loads to Load cases

Sorry @1234eddie, you’re right… it can be done. what I should have written is that you can’t do it easily

the friendlier way is to use this class to wrap each com object you encounter:

class ComObj:
    def __init__(self, obj):
        self.obj = obj
        self.typ = obj.GetType()

    def __getattr__(self, name):       
        def newm(*args):
            args = args or (None,)
            return self.typ.InvokeMember(
                name, 
                BindingFlags.InvokeMethod | BindingFlags.GetProperty, 
                None,
                self.obj,
                *args,
            )
        return newm

then @stefanyC6JZ7 can do:

case = loads.Get(LoadCaseID)
simplecase = ComObj(case)
records = ComObj(simplecase.Records)  # not sure if it's necessary, didn't try it

and use records in place of all the simplecase.Records calls.

@stefanyC6JZ7 : I see that you copy-pasted some low-quality code from this forum, I suggest you to read my quickstart guide and another code I refactored - with comments - to clean it up.

1 Like