# CPython 3, Apply loads to Load cases

**URL:** <https://forum.dynamobim.com/t/cpython-3-apply-loads-to-load-cases/79996>\
**Category:** Robot Structural Analysis\
**Tags:** python, dynamo, cpython3, c\
**Created:** [August 17, 2022, 3:41pm UTC](https://forum.dynamobim.com/t/cpython-3-apply-loads-to-load-cases/79996 "2022-08-17T15:41:50Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![sanzoghenzo](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sanzoghenzo](https://forum.dynamobim.com/u/sanzoghenzo)\
**Post date:** [August 23, 2022, 7:59am UTC](https://forum.dynamobim.com/t/cpython-3-apply-loads-to-load-cases/79996/5 "2022-08-23T07:59:00Z")

</div>

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](https://gist.github.com/denfromufa/ec559b5af41060c5ac318f7f59d8b415#file-excel_interop_vsto-ipynb) to wrap each com object you encounter:

```python
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:

```nohighlight
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](https://forum.dynamobim.com/t/quickstart-guide-for-dynamo-in-rsa-2023/77837#dynamo-forum-5) and [another code I refactored](https://forum.dynamobim.com/t/loads-are-duplicated-in-second-run-and-keeps-adding-in-n-times-run-api-dynamo/43457/13) - with comments - to clean it up.

---

_[View the full topic](https://forum.dynamobim.com/t/cpython-3-apply-loads-to-load-cases/79996)._
