# OffsetCrvOnSrf inconsistent even on simple geometry

**URL:** <https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502>\
**Category:** Rhino for Windows\
**Tags:** rhino\
**Created:** [June 30, 2019, 6:02pm UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502 "2019-06-30T18:02:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asterisk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/asterisk/32/480872_2.png) [@Asterisk](https://discourse.mcneel.com/u/Asterisk)\
**Post date:** [June 30, 2019, 6:02pm UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502/1 "2019-06-30T18:02:55Z")

</div>

Offset by 84 fails, but by 55 works…  
[OffsetCrvOnSrfby84.3dm](https://discourse.mcneel.com/uploads/short-url/tt5zFyNImGD32qHB09X0JGwVRpu.3dm) (24.2 KB)

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [June 30, 2019, 9:24pm UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502/2 "2019-06-30T21:24:19Z")

</div>

Hello - as far as I can see an offset of 84 falls completely off the surface.

-Pascal

---

<div class="post-metadata">

**Author:** ![Asterisk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/asterisk/32/480872_2.png) [@Asterisk](https://discourse.mcneel.com/u/Asterisk)\
**Post date:** [June 30, 2019, 11:14pm UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502/3 "2019-06-30T23:14:04Z")

</div>

I see. But that’s not how it works if at least 1 nanometer of an offset curve falls onto surface. It magically appears to fill surface border to border. Which is another thing that doesn’t make sense. Albeit it’s a good thing in my case.

Any idea how to alleviate it?

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/c/1/c187f1205f87e0b54b0dab6842d8e0d6460c116e.png)

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [July 1, 2019, 2:05am UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502/4 "2019-07-01T02:05:58Z")

</div>

> [@Asterisk](#):
>
> not how it works if at least 1 nanometer of an offset curve falls onto surface

Correct - the curve is extended - but I would not count on the extended part of curve to always be an offset. The result is always explodable into offsets and extensions.

In this case, since your curve is a line, and the surface planar, the solution is to set a CPlane to the surface, offset the line and extend it. Or, make a Cylinder at 84 radius, using the line endpoints as guides, tall enough to intersect the surface.

-Pascal

---

<div class="post-metadata">

**Author:** ![Asterisk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/asterisk/32/480872_2.png) [@Asterisk](https://discourse.mcneel.com/u/Asterisk)\
**Post date:** [July 1, 2019, 2:33am UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502/5 "2019-07-01T02:33:03Z")

</div>

Yeah, that’s very clunky. Nothing that can’t be scripted, but I was hoping for some improvement in OffsetCrvonSrf from R4 to R6.

I think the command isn’t “smart” enough as if it “thinks” the offset curve falls over the opposite edge of the surface while in this case it’s simply off to the side.

Just dawned on me - another solution would be to offset in 2 or 3 steps… Probably less screwery would be involved to get to the result too. And it’d work for non-planar surfaces. Thanks for insight!

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [July 1, 2019, 4:40pm UTC](https://discourse.mcneel.com/t/offsetcrvonsrf-inconsistent-even-on-simple-geometry/85502/6 "2019-07-01T16:40:25Z")

</div>

Here’s a thing that may help if the inputs are simple like your example

```auto
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

def test():
    rad = 1
    if sc.sticky.has_key('CYL_BREP_RADIUS'):
        rad = sc.sticky['CYL_BREP_RADIUS']
        
    crvId = rs.GetObject("Select the line", filter=4, preselect=True)
    if not crvId:return
    
    srfId = rs.GetObject("Select the surface", filter=8)
    if not srfId: return
    
    rad = rs.GetReal("Radius", rad)
    if not rad: return
    sc.sticky['CYL_BREP_RADIUS'] = rad

    crv= sc.doc.Objects.Find(crvId).Geometry
    length = crv.GetLength()
    plane = Rhino.Geometry.Plane(crv.PointAtStart, crv.PointAtEnd- crv.PointAtStart)
    circle = Rhino.Geometry.Circle(plane, rad)
    line = Rhino.Geometry.Line(crv.PointAtStart, crv.PointAtEnd)
    
    brep = sc.doc.Objects.Find(srfId).Geometry.Faces[0].DuplicateFace(False)
    
    cyl = Rhino.Geometry.Cylinder(circle, length)
    
    bb = Rhino.Geometry.BoundingBox()
    bb.Union(brep.GetBoundingBox(False))
    bb.Union(cyl.ToBrep(False, False).GetBoundingBox(False))
    line.ExtendThroughBox(bb)
    
    plane.Origin= line.From
    circle = Rhino.Geometry.Circle(plane, rad)
    cyl = Rhino.Geometry.Cylinder(circle, line.Length)
    
    x = Rhino.Geometry.Intersect.Intersection.BrepSurface(brep, cyl.ToNurbsSurface(), .001)
    if x[0]:
        ids = [sc.doc.Objects.AddCurve(item)for item in x[1]]
        if ids: rs.SelectObjects(ids)
            
    sc.doc.Views.Redraw

test()

```

-Pascal
