forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleRibbonOffsetCurve.py
41 lines (33 loc) · 1.51 KB
/
SampleRibbonOffsetCurve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
################################################################################
# SampleRibbonOffsetCurve.py
# Copyright (c) 2020 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import Rhino
import scriptcontext
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()