# Error in python script running Edge modules - Instance property must be accessed through a class instance

**URL:** <https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361>\
**Category:** Developers\
**Tags:** python, geometry, dynamo\
**Created:** [October 6, 2023, 3:53pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361 "2023-10-06T15:53:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yannick.Coret](https://avatars.discourse-cdn.com/v4/letter/y/3bc359/32.png) [@Yannick.Coret](https://forum.dynamobim.com/u/Yannick.Coret)\
**Post date:** [October 6, 2023, 3:53pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361/1 "2023-10-06T15:53:12Z")

</div>

Hi, I am trying to using a python script to manipulate a surface extracted from a linked model.

I managed to get my output on a single surface from a list of surface using Dynamo nodes which I then converted to code.

But when I try to replicate the same code in Python it will give be the error below:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/e/be7e679151000372101ea838b8b61576f4a35dcb.png)

The error occurs on line 98 from the screenshot:

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d6f2338d1f472ef7e42d69d7acebaa6220cd05fb.png)

Since I have to iterate on a number of surface, my goal is to get the various surface in the script a run the loop there.

I would appreciate some support in getting the following code to run in the python script as per below:

Also, I cannot find documentation regarding the attributes of the various objects. Where can I find this information.

Thanks!

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 6, 2023, 4:44pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361/2 "2023-10-06T16:44:18Z")

</div>

try this bit of list comprehension instead: [s.CurveGeometry for s in surfaces]

---

<div class="post-metadata">

**Author:** ![Yannick.Coret](https://avatars.discourse-cdn.com/v4/letter/y/3bc359/32.png) [@Yannick.Coret](https://forum.dynamobim.com/u/Yannick.Coret)\
**Post date:** [October 9, 2023, 2:50pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361/3 "2023-10-09T14:50:51Z")

</div>

When I try to get the CurveGeometry from a surface, I get an error saying Surface has no attributes “CurveGeometry”.

I have taken a step backwards and my problem is as follows:  
I have a surface and I need to compute the length of each edge to find the longest one. See attached screenshot, a neater one than the previous one I sent.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/0/d042fbc34c3d6d15b0db560445b0817b928911cd.jpeg)

It could be worth mentioning that the surface is from a linked model, although I managed to do the same operation using standards modules in Dynamo.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 9, 2023, 3:16pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361/4 "2023-10-09T15:16:12Z")

</div>

If you have a surface, you need to get the curves first. Assuming you have your standard Dynamo geometry library imports:

```auto
srf = IN[0]
crvs = srf.PerimeterCurves()
lengths = [c.Length for c in crvs]

```

That should get you started. To sort by length I would just use a standard Python method; nothing unique to Dynamo or the engine about it.  
`sortedByLength = sorted(list(zip(lengths,crvs)))`  
That zips the list of lengths and curves, converts the zip object to a list, sorts the list by the natural sort method (first item in the list) and returns the resulting list of pairs.

`OUT = sortedByLength[-1][1]` and that will pull the first item (curve) from the last list of sorted pairs (so the pair with the longest length).

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 9, 2023, 3:28pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361/5 "2023-10-09T15:28:15Z")

</div>

> [@Yannick.Coret](#):
>
> Also, I cannot find documentation regarding the attributes of the various objects.

The Dynamo library has this.

Constructors have a green + sign.  
Methods have a red lighting bolt.  
Properties have a blue ?.

So if you have a Point, you can go into the Dynamo library, find the point section, and expand that section to find something like this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/5428ef1b0471486214803d784a708be44c2ed33a.png)

- A constructor requires declaring the class first (so `Point` with a capitol P) followed by a dot and the constructor you want to use, with the overrides in parenthesis.
- A method is called on an existing object (so `point` or `pnt` with a lowercase p - this has to already exist), followed by a dot, the method you want to call, and then parenthesis and the inputs you want to use.
- A property is pulled from an existing object (so `point` or `pnt` with a loweracse p again), followed by a dot and the name of the property you want to pull.

So:

```auto
vct = Vector.ByCoordindates(0,1,0) # A constrctor to generate a vector which didn't exist before. note that we need to set this to a variable to call it again.
pnt = Point.ByCoordiantes(0,0,1) # A constructor, to generate a point which didn't exist before. Note that we need to set this to a variable to call it again.
pnt.Add(vct) #a method acting on the point. Note that no variable need be called as it already exists in memory as pnt - we are just modifying it. 
xVal = pnt.X #a property to pull the X value of the point. Note that we need to set this to a variable to call it again.
OUT = xVal #return the xVal variable to the Dynamo environment.

```

---

<div class="post-metadata">

**Author:** ![Yannick.Coret](https://avatars.discourse-cdn.com/v4/letter/y/3bc359/32.png) [@Yannick.Coret](https://forum.dynamobim.com/u/Yannick.Coret)\
**Post date:** [October 9, 2023, 3:32pm UTC](https://forum.dynamobim.com/t/error-in-python-script-running-edge-modules-instance-property-must-be-accessed-through-a-class-instance/94361/6 "2023-10-09T15:32:37Z")

</div>

Oh great stuff! Thanks for the help and the explanation. My code is running perfectly fine now too!
