# Problem With PolyCurve.Offset in C#, Can't Cast to Curve

**URL:** <https://forum.dynamobim.com/t/problem-with-polycurve-offset-in-c-cant-cast-to-curve/8531>\
**Category:** Developers\
**Tags:** revit\
**Created:** [December 30, 2016, 6:08pm UTC](https://forum.dynamobim.com/t/problem-with-polycurve-offset-in-c-cant-cast-to-curve/8531 "2016-12-30T18:08:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zltrattner](https://avatars.discourse-cdn.com/v4/letter/z/977dab/32.png) [@zltrattner](https://forum.dynamobim.com/u/zltrattner)\
**Post date:** [December 30, 2016, 6:08pm UTC](https://forum.dynamobim.com/t/problem-with-polycurve-offset-in-c-cant-cast-to-curve/8531/1 "2016-12-30T18:08:41Z")

</div>

For the Zero-Touch node that I’m developing I need to offset some simple PolyCurves. However when I use the PolyCurve.Offset method the compiler apparently believes that I’m offsetting regular curves so I can’t pass a PolyCurve to a variable. It also won’t let me cast the offset output to a PolyCurve.

```
public static PolyCurve Offset ()
    {
        List<Point> ptList = new List<Point>();
        ptList.Add(Point.ByCoordinates(5, -5));
        ptList.Add(Point.ByCoordinates(0, -5));
        ptList.Add(Point.ByCoordinates(-5, 0));
        PolyCurve pc = PolyCurve.ByPoints(ptList);
        //not only should this cast to polycurve be unnecessary,
        //but it doesn't even work
        PolyCurve pcOffset = (PolyCurve)pc.Offset(-1, false);
        return pcOffset;
    }

```

The error message I receive in Dynamo reads: “Warning: Class1.Offset operation failed.  
Unable to cast object of type ‘Autodesk.DesignScript.Geometry.Curve’ to type ‘Autodesk.DesignScript.Geometry.PolyCurve’.”

---

<div class="post-metadata">

**Author:** ![zltrattner](https://avatars.discourse-cdn.com/v4/letter/z/977dab/32.png) [@zltrattner](https://forum.dynamobim.com/u/zltrattner)\
**Post date:** [December 30, 2016, 6:43pm UTC](https://forum.dynamobim.com/t/problem-with-polycurve-offset-in-c-cant-cast-to-curve/8531/2 "2016-12-30T18:43:58Z")

</div>

Ok I resolved this with an ugly workaround as follows:

```
List<Curve> temp = new List<Curve>();
temp.Add(pc.Offset(-1, false));
pc = PolyCurve.ByJoinedCurves(temp);
```
