Ah! I did some research and decided to go a different route! the GetBox method seemed unreliable.
This works!
One stylistic question though:
I would love for the dynamic draw to be more representative. But when I tried to draw line based off of the cursor but with transformations, everything hung. Is it possible to dynamically draw the object as I’m creating it?
import Rhino
import System
import rhinoscriptsyntax as rs
import scriptcontext as sc
clr = System.Drawing.Color.Gray
def pickPoint1(pt0):
def dynamicDrawFunc( sender, args):
pt = args.CurrentPoint
args.Display.DrawLine(pt0, pt, clr, 1)
gp = Rhino.Input.Custom.GetPoint()
gp.DynamicDraw += dynamicDrawFunc
gp.Get()
if( gp.CommandResult() == Rhino.Commands.Result.Success ):
pt1 = gp.Point()
return (pt1)
def pickPoint2(pt1):
def dynamicDrawFunc( sender, args):
pt = args.CurrentPoint
args.Display.DrawLine(pt0, pt1, clr, 1)
args.Display.DrawLine(pt1, pt, clr, 1)
gp = Rhino.Input.Custom.GetPoint()
gp.SetCommandPrompt("Offset point")
gp.DrawLineFromPoint(pt1, True)
plane = rs.PlaneFromPoints(pt0, pt1, [pt0.X, pt0.Y, pt0.Z+1])
line = Rhino.Geometry.Line(pt1, pt1 + plane.Normal)
gp.Constrain(line)
gp.DynamicDraw += dynamicDrawFunc
gp.Get()
if( gp.CommandResult() == Rhino.Commands.Result.Success ):
pt2 = gp.Point()
return (pt2)
def pickPoint3(pt2):
def dynamicDrawFunc( sender, args):
pt = args.CurrentPoint
args.Display.DrawLine(pt0, pt1, clr, 1)
args.Display.DrawLine(pt1, pt2, clr, 1)
args.Display.DrawLine(pt2, pt, clr, 1)
gp = Rhino.Input.Custom.GetPoint()
gp.SetCommandPrompt("Offset point")
gp.DrawLineFromPoint(pt2, True)
plane = sc.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
line = Rhino.Geometry.Line(pt2, pt2 + plane.Normal)
gp.Constrain(line)
gp.DynamicDraw += dynamicDrawFunc
gp.Get()
if( gp.CommandResult() == Rhino.Commands.Result.Success ):
pt3 = gp.Point()
return (pt3)
pt0 =rs.GetPoint("Base Point")
if pt0:
pt1 = pickPoint1(pt0)
if pt1:
line = ([0,0,0], [30,2,0])
pt2 = pickPoint2(pt1)
if pt2:
pt3 = pickPoint3(pt2)
if pt3:
vertex = [(pt1.X+pt2.X)/2, (pt1.Y+pt2.Y)/2, pt3.Z]
triPts=[pt1, pt2, vertex, pt1]
triangle = rs.AddPolyline(triPts)
brep = rs.ExtrudeCurveStraight( triangle, pt1, pt0 )
rs.CapPlanarHoles( brep )
rs.DeleteObject(triangle)