Skip to content

Commit

Permalink
Fixes RH-58306 adds ribbon offset python example
Browse files Browse the repository at this point in the history
  • Loading branch information
travisserio committed May 4, 2020
1 parent 64564b6 commit 4e3c9b6
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions rhinopython/SampleRibbonOffsetCurve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
################################################################################
# SampleRibbonOffsetCurve.py
# Copyright (c) 2020 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import clr
import Rhino
import scriptcontext
import System.Drawing.Color
import System.Collections.Generic.IEnumerable as IEnumerable

def SampleCreateRibbon():

go = Rhino.Input.Custom.GetObject()
go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
go.GeometryAttributeFilter = Rhino.Input.Custom.GeometryAttributeFilter.ClosedCurve
go.SetCommandPrompt("Select closed curve to offset")
go.Get()
if(go.CommandResult() != Rhino.Commands.Result.Success):
return go.CommandResult()

gp = Rhino.Input.Custom.GetPoint()
gp.SetCommandPrompt("Select curve side to offset")
gp.Get()
if(gp.CommandResult() != Rhino.Commands.Result.Success):
return gp.CommandResult()

crv = go.Object(0).Curve()
pt = gp.Point()
plane = scriptcontext.doc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane()
direction = plane.Normal
tol = scriptcontext.doc.ModelAbsoluteTolerance

rib = crv.RibbonOffset(2.0,1.0,pt,direction,tol)
scriptcontext.doc.ActiveDoc.Objects.Add(rib)

return Rhino.Commands.Result.Success

# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if( __name__ == '__main__' ):
SampleCreateRibbon()

0 comments on commit 4e3c9b6

Please sign in to comment.