Пример #1
0
def setGlobals():
    #mm
    global D_TOL, A_TOL
    D_TOL = doc.ActiveDoc.ModelAbsoluteTolerance
    A_TOL = doc.ActiveDoc.ModelAngleToleranceDegrees

    global LCUT_INDICES
    LCUT_INDICES = wla.get_lcut_layers()

    global GAP_SIZE
    GAP_SIZE = 5
Пример #2
0
def RunCommand( is_interactive ):	
	margin = 5
	L, W = 810, 455
	basept = Rhino.Geometry.Point3d(0,0,0)

	L = unit_convert(L)
	W = unit_convert(W)
	margin = unit_convert(margin)
	go = Rhino.Input.Custom.GetPoint()
	opt_L = Rhino.Input.Custom.OptionDouble(L,0.2,10000)
	opt_W = Rhino.Input.Custom.OptionDouble(W,0.2,10000)

	go.SetCommandPrompt("Pick lower left corner of lasercut area or Enter to place at origin. Default sheet size is L=%.2f, W=%.2f" % (L,W))
	go.AddOptionDouble("Length", opt_L)
	go.AddOptionDouble("Width", opt_W)
	go.AcceptNothing(True)

	while True:
		res = go.Get()
		if res == Rhino.Input.GetResult.Option:
			continue
		elif res == Rhino.Input.GetResult.Cancel:
			return
		elif res == Rhino.Input.GetResult.Nothing:
			pass
		elif res == Rhino.Input.GetResult.Point:
			basept = go.Point()
		break
	
	layer_dict = wla.get_lcut_layers()
	plane = rs.WorldXYPlane()
	plane = rs.MovePlane(plane,basept)
	inner_rect = rs.AddRectangle(plane,L-margin*2,W-margin*2)
	plane = rs.MovePlane(plane, rs.PointAdd(basept, [-margin,-margin,0]))
	outer_rect = rs.AddRectangle(plane, L, W)
	rs.ObjectLayer([inner_rect, outer_rect],"XXX_LCUT_00-GUIDES")
	rs.SelectObjects([inner_rect,outer_rect])
	return True
Пример #3
0
def rc_unroll_ortho():

    go = Rhino.Input.Custom.GetObject()
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep

    default_thickness = sticky["thickness"] if sticky.has_key(
        "thickness") else 5.5
    default_lid = sticky["lid"] if sticky.has_key("lid") else False

    opt_thickness = Rhino.Input.Custom.OptionDouble(default_thickness, 0.2,
                                                    1000)
    opt_lid = Rhino.Input.Custom.OptionToggle(default_lid, "No", "Yes")

    go.SetCommandPrompt(
        "Select breps to unroll. Breps must be orthogonal (faces at 90 degree angles)"
    )
    go.AddOptionDouble("Thickness", opt_thickness)
    go.AddOptionToggle("Lids", opt_lid)

    go.GroupSelect = True
    go.SubObjectSelect = False
    go.AcceptEnterWhenDone(True)
    go.AcceptNothing(True)
    go.EnableClearObjectsOnEntry(False)
    go.EnableUnselectObjectsOnExit(False)
    go.GroupSelect = True
    go.SubObjectSelect = False
    go.DeselectAllBeforePostSelect = False

    res = None
    bHavePreselectedObjects = False

    while True:
        res = go.GetMultiple(1, 0)

        #If new option entered, redraw a possible result
        if res == Rhino.Input.GetResult.Option:
            #print res
            go.EnablePreSelect(False, True)
            continue

        #If not correct
        elif res != Rhino.Input.GetResult.Object:
            return Rhino.Commands.Result.Cancel

        if go.ObjectsWerePreselected:
            bHavePreselectedObjects = True
            go.EnablePreSelect(False, True)
            continue

        break

    rs.EnableRedraw(False)

    LID = opt_lid.CurrentValue
    THICKNESS = opt_thickness.CurrentValue
    global LCUT_INDICES
    LCUT_INDICES = wla.get_lcut_layers()

    #Get geometry and object lists
    brep_obj_list = []
    brep_geo_list = []
    brep_ids_list = []
    for i in xrange(go.ObjectCount):
        b_obj = go.Object(i).Object()
        brep_obj_list.append(b_obj)
        #For Debug and reference...
        #brep_geo_list.append(b_obj.Geometry)
        #brep_ids_list.append(b_obj.Id)

    #get information for each piece to be output.
    #future implementation should use bounding dims and curves rather than dimension-based system.
    unrolled_brep_info = []
    lid_info = []

    SELECT_GUIDS = []
    for i, obj in enumerate(brep_obj_list):
        #geometry prep: convert extrusions to breps
        if str(obj.ObjectType) != "Brep":
            new_brep = wru.extrusion_to_brep(obj.Geometry)
        else:
            new_brep = obj.Geometry

        #pull the brep sides info for this solid
        this_brep_side_info = get_brep_sides_info(new_brep, THICKNESS)
        unrolled_brep_info.append(this_brep_side_info)
        num_sides = len(this_brep_side_info.dims)

        #pull the lid info for this solid
        if LID == True:
            this_brep_lid_info = get_brep_lid_info(new_brep, num_sides,
                                                   THICKNESS)
            lid_info.append(this_brep_lid_info)

    #get dims needed to place this solid's outline curves
    brep_output_bounding_heights = []
    for i, brep_side_info in enumerate(unrolled_brep_info):
        if LID == True:
            brep_output_bounding_heights.append(
                max(brep_side_info.boundingDims.y, lid_info[i].dims.y)
            )  #lid info needs to become a named tuple as well.
        else:
            brep_output_bounding_heights.append(brep_side_info.boundingDims.y)

    ybase = 0
    #each solid
    for i, brep_side_info in enumerate(unrolled_brep_info):
        top_label_text = wut.number_to_letter(i)
        prefix = top_label_text + "-"
        xbase = 0
        #each piece
        for j, piecedims in enumerate(brep_side_info.dims):
            face_label = prefix + str(brep_side_info.labelNums[j])
            rect = rs.AddRectangle([xbase, ybase, 0], piecedims.x, piecedims.y)
            dot = rs.AddTextDot(face_label, rs.CurveAreaCentroid(rect)[0])

            rs.ObjectLayer(dot, "XXX_LCUT_00-GUIDES")
            rs.ObjectLayer(rect, "XXX_LCUT_01-CUT")
            SELECT_GUIDS.extend([rect, dot])
            xbase += piecedims[0] + GAP_SIZE

        #add the lids
        if LID == True:

            #transform the lid curve to the basepoint
            lid_curve = lid_info[i].outline
            p1 = rs.WorldXYPlane()
            p2 = rs.PlaneFromNormal([xbase, ybase, 0], [0, 0, 1], [1, 0, 0])
            orient = Rhino.Geometry.Transform.ChangeBasis(
                rs.coerceplane(p2), rs.coerceplane(p1))
            lid_curve.Transform(orient)

            #add the curve to the document
            crv_1 = wru.add_curve_to_layer(lid_curve, LCUT_INDICES[1])
            crv_2 = rs.CopyObject(
                crv_1, [lid_info[i].dims.x + GAP_SIZE, 0, 0
                        ])  #change this to use a transform; it's nasty.

            #add text dot
            face_label_1 = prefix + str(len(brep_side_info.dims))
            face_label_2 = prefix + str(len(brep_side_info.dims) + 1)
            dot_1 = rs.AddTextDot(face_label_1, rs.CurveAreaCentroid(crv_1)[0])
            dot_2 = rs.AddTextDot(face_label_2, rs.CurveAreaCentroid(crv_2)[0])
            rs.ObjectLayer([dot_1, dot_2], "XXX_LCUT_00-GUIDES")

            SELECT_GUIDS.extend([crv_1, crv_2, dot_1, dot_2])

        top_label = rs.AddTextDot(top_label_text, brep_side_info.topLabelPt)
        rs.ObjectLayer(top_label, "XXX_LCUT_00-GUIDES")
        ybase += brep_output_bounding_heights[i] + GAP_SIZE * 4

    sticky["thickness"] = THICKNESS
    sticky["lid"] = LID

    rs.UnselectAllObjects()
    rs.SelectObjects(SELECT_GUIDS)
    rs.Redraw()
    rs.EnableRedraw(True)
Пример #4
0
def rc_get_tags(curves):

    global LCUT_INDICES
    LCUT_INDICES = wla.get_lcut_layers()

    text_buffer = 0
    if PREFIX != None:
        text_buffer = 0.2 * len(PREFIX) * TEXTSIZE

    fi = sc.doc.Fonts.FindOrCreate("MecSoft_Font-1", True, False)
    [wge.make_pcurve_ccw(c) for c in curves]
    offset_curves = [
        offset_pcurve(c, 1.4 * TEXTSIZE + text_buffer) for c in curves
    ]
    centroids = [
        c.GetBoundingBox(rs.WorldXYPlane()).Center for c in offset_curves
    ]

    curve_collection = zip(centroids, offset_curves)
    curve_collection = sorted(curve_collection, sortcompare)
    _, offset_curves = zip(*curve_collection)

    tt_locations = []
    td_locations = []
    for c in offset_curves:
        #j = add_curve_to_layer(c,LCUT_INDICES[1]) #uncomment for preview
        bb = c.GetBoundingBox(rs.WorldXYPlane())
        ll_corner = bb.Corner(True, True, True)
        v = rs.VectorCreate([0, 0, 0], [1, 1, 0])
        extremes = c.ExtremeParameters(v)

        thept = None
        for i, pt in enumerate(extremes):
            pointat = c.PointAt(extremes[i])
            if thept is not None:
                if pointat.Y < thept.Y: thept = pointat
            else:
                thept = pointat
        tt_locations.append(thept)

        td_locations.append(bb.Center)

    text_guids = []
    dot_guids = []

    tt_text = []
    for i in xrange(len(tt_locations)):
        text = PREFIX + str(i) if PREFIX != None else str(i)
        tt_text.append(text)

    if MODE != "TextDots":
        text_guids = wfa.add_fab_tags(
            tt_locations, tt_text, TEXTSIZE,
            Rhino.Geometry.TextJustification.MiddleLeft)
    if MODE != "Curves":
        dot_guids = [
            rs.AddTextDot(tt_text[i], td_locations[i])
            for i in xrange(len(tt_text))
        ]

    for id in text_guids:
        rs.ObjectLayer(id, "XXX_LCUT_03-LSCORE")
    for id in dot_guids:
        rs.ObjectLayer(id, "XXX_LCUT_00-GUIDES")

    if len(text_guids) > 0: [rs.SelectObjects(x) for x in text_guids]
    if len(dot_guids) > 0: [rs.SelectObjects(x) for x in dot_guids]
    sc.doc.Views.Redraw()
Пример #5
0
def rc_plot_volumes(use_epsilon):

    go = Rhino.Input.Custom.GetObject()
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep

    default_inplaceBool = sticky["inplaceBool"] if sticky.has_key(
        "inplaceBool") else False
    default_heightsBool = sticky["heightsBool"] if sticky.has_key(
        "heightsBool") else False

    opt_inplace = Rhino.Input.Custom.OptionToggle(default_inplaceBool, "No",
                                                  "Yes")
    opt_heights = Rhino.Input.Custom.OptionToggle(default_heightsBool, "No",
                                                  "Yes")

    go.SetCommandPrompt("Select breps to extract plan cuts")
    go.AddOptionToggle("InPlace", opt_inplace)
    go.AddOptionToggle("PrintPieceHeights", opt_heights)

    go.GroupSelect = True
    go.SubObjectSelect = False
    go.AcceptEnterWhenDone(True)
    go.AcceptNothing(True)
    go.EnableClearObjectsOnEntry(False)
    go.EnableUnselectObjectsOnExit(False)
    go.GroupSelect = True
    go.SubObjectSelect = False
    go.DeselectAllBeforePostSelect = False

    res = None
    bHavePreselectedObjects = False

    while True:
        res = go.GetMultiple(1, 0)
        #If new option entered, redraw a possible result
        if res == Rhino.Input.GetResult.Option:
            # print res
            go.EnablePreSelect(False, True)
            continue
        #If not correct
        elif res != Rhino.Input.GetResult.Object:
            return Rhino.Commands.Result.Cancel
        if go.ObjectsWerePreselected:
            bHavePreselectedObjects = True
            go.EnablePreSelect(False, True)
            continue
        break

    rs.EnableRedraw(False)

    DIRPT1 = rs.coerce3dpoint([0, 0, 0])
    DIRPT2 = rs.coerce3dpoint([1, 0.001, 0])
    global BOOL_HEIGHTS
    global LCUT_INDICES
    global SORTDIR
    BOOL_HEIGHTS = opt_heights.CurrentValue
    LCUT_INDICES = wla.get_lcut_layers()
    SORTDIR = DIRPT2 - DIRPT1

    #Get boolean for "inplace"
    INPLACE = opt_inplace.CurrentValue

    #Get brep representations of objects
    brep_geo_list = []
    for i in xrange(go.ObjectCount):
        b_obj = go.Object(i).Object()
        brep_geo_list.append(b_obj.Geometry)

    #...brep conversion may be necessary
    new_brep_list = []
    for i, geo in enumerate(brep_geo_list):
        if geo.GetType() != Rhino.Geometry.Brep:
            new_brep_list.append(wru.extrusion_to_brep(geo))
        else:
            new_brep_list.append(geo)

    #set base for output.
    xbase = 0
    ybase = 0
    #set the amount to move up from the bottom of the brep for cutting the lower outline.
    #this should be replaced by a projection of the bottom face of the brep.
    epsilon = D_TOL * 2

    select_items = []

    centroids = [
        c.GetBoundingBox(rs.WorldXYPlane()).Center for c in new_brep_list
    ]
    brep_collection = zip(centroids, new_brep_list)
    brep_collection = sorted(brep_collection, sortcompare)
    _, new_brep_list = zip(*brep_collection)

    for i, brep in enumerate(new_brep_list):
        #get lowest curve info

        #get label prefix and bounding dims for this brep
        bdims = wge.get_bounding_dims(brep)
        baseplane = rs.MovePlane(rs.WorldXYPlane(), [xbase, ybase, 0])
        label_letter = wut.number_to_letter(i)

        #prepare heights and labels for each section cut
        num_sections = 1
        remaining_thickness = 0
        cuts_at = [epsilon] if use_epsilon else [0]
        brep_label = label_letter
        section_labels = [label_letter]

        if BOOL_HEIGHTS == True:
            section_labels = [
                label + "\n" + str(round(bdims.Z, 1))
                for label in section_labels
            ]

        #get section information for each cut
        section_planes = get_brep_section_planes(brep, cuts_at)

        section_curves, section_dims = [[], []]
        for i, plane in enumerate(section_planes):
            curve, dims = [0, 0]
            if (not use_epsilon) and (i == 0):
                curve, dims = get_lowest_curve_info(brep, D_TOL * 2)
            else:
                curve, dims = get_section_curve_info_multi_no_ortho(
                    brep, plane)
            section_curves.append(curve)
            section_dims.append(dims)

        ##DO WORK HERE##
        drawing_planes = get_drawing_planes(section_dims, baseplane, GAP_SIZE)

        #place curves in drawing location
        for sp, dp, sc in zip(section_planes, drawing_planes, section_curves):
            if INPLACE == True:
                t = Rhino.Geometry.Transform.Translation(0, 0, 0)
            else:
                t = Rhino.Geometry.Transform.ChangeBasis(dp, sp)
            for c in sc:
                c.Transform(t)

        #THIS IS STILL A MESS: LABEL ADDING
        #draw curves and add text dots
        top_label_pt = get_brep_label_pt(brep)
        brep_textdot = rs.AddTextDot(brep_label, top_label_pt)
        rs.ObjectLayer(brep_textdot, "XXX_LCUT_00-GUIDES")

        label_pts = []
        for sc, label in zip(section_curves, section_labels):
            for i, c in enumerate(sc):
                crv = wru.add_curve_to_layer(c, LCUT_INDICES[1])
                select_items.append(crv)
                if i == 0:
                    label_pts.append(rs.CurveAreaCentroid(crv)[0])

        fab_tags = wfa.add_fab_tags(label_pts, section_labels, TEXTSIZE)
        for tag in fab_tags:
            rs.ObjectLayer(tag, "XXX_LCUT_02-SCORE")
            group_name = rs.AddGroup()
            rs.AddObjectsToGroup(tag, group_name)
        ybase += max([s.Y for s in section_dims]) + GAP_SIZE * 1

        for tag in fab_tags:
            select_items.extend(tag)

    sticky["inplaceBool"] = INPLACE
    sticky["heightsBool"] = BOOL_HEIGHTS

    rs.UnselectAllObjects()
    rs.SelectObjects(select_items)
    rs.Redraw()
    rs.EnableRedraw(True)
Пример #6
0
def rc_unroll_ortho():
	
	go = Rhino.Input.Custom.GetObject()
	go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep
	
	default_thickness = sticky["thickness"] if sticky.has_key("thickness") else 5.5
	default_lid = sticky["lid"] if sticky.has_key("lid") else False
	
	opt_thickness = Rhino.Input.Custom.OptionDouble(default_thickness,0.2,1000)
	opt_lid = Rhino.Input.Custom.OptionToggle(default_lid,"No","Yes")

	go.SetCommandPrompt("Select breps to unroll. Breps must be orthogonal (faces at 90 degree angles)")
	go.AddOptionDouble("Thickness", opt_thickness)
	go.AddOptionToggle("Lids", opt_lid)

	go.GroupSelect = True
	go.SubObjectSelect = False
	go.AcceptEnterWhenDone(True)
	go.AcceptNothing(True)
	go.EnableClearObjectsOnEntry(False)
	go.EnableUnselectObjectsOnExit(False)
	go.GroupSelect = True
	go.SubObjectSelect = False
	go.DeselectAllBeforePostSelect = False

	res = None
	bHavePreselectedObjects = False

	while True:
		res = go.GetMultiple(1,0)

		#If new option entered, redraw a possible result
		if res == Rhino.Input.GetResult.Option:
			#print res
			go.EnablePreSelect(False, True)
			continue

		#If not correct
		elif res != Rhino.Input.GetResult.Object:
			return Rhino.Commands.Result.Cancel

		if go.ObjectsWerePreselected:
			bHavePreselectedObjects = True
			go.EnablePreSelect(False, True)
			continue

		break

	rs.EnableRedraw(False)

	LID = opt_lid.CurrentValue
	global LCUT_INDICES, THICKNESS
	THICKNESS = opt_thickness.CurrentValue
	LCUT_INDICES = wla.get_lcut_layers()

	#Get geometry and object lists
	brep_obj_list = []
	brep_geo_list = []
	brep_ids_list = []
	for i in xrange(go.ObjectCount):
		b_obj = go.Object(i).Object()
		brep_obj_list.append(b_obj)
	
	#use world cplane
	current_cplane = sc.doc.Views.ActiveView.ActiveViewport.GetConstructionPlane()
	temp_cplane = current_cplane.Plane
	current_cplane.Plane = rs.WorldXYPlane()
	
	#get information for each piece to be output.
	#future implementation should use bounding dims and curves rather than dimension-based system.
	unrolled_brep_info = []
	lid_info = []
	
	SELECT_GUIDS = []
	
	#convert to breps
	input_brep_geo = []
	for i,obj in enumerate(brep_obj_list):
		#geometry prep: convert extrusions to breps
		if str(obj.ObjectType) != "Brep":
			new_brep = wru.extrusion_to_brep(obj.Geometry)
		else:
			new_brep = obj.Geometry
		input_brep_geo.append(new_brep)
	
	for geo in input_brep_geo:
		unroll_brep_with_thickness(geo)
	
	
	sticky["thickness"] = THICKNESS
	sticky["lid"] = LID
	
	current_cplane.Plane = temp_cplane
	rs.UnselectAllObjects()
	rs.SelectObjects(SELECT_GUIDS)
	rs.Redraw()
	rs.EnableRedraw(True)
Пример #7
0
def rc_getinput():

    go = Rhino.Input.Custom.GetObject()
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep

    default_thickness = sticky["Thickness"] if sticky.has_key(
        "Thickness") else 2
    default_borderThickness = sticky["borderThickness"] if sticky.has_key(
        "borderThickness") else 10
    default_borderBool = sticky["borderBool"] if sticky.has_key(
        "borderBool") else False

    opt_thickness = Rhino.Input.Custom.OptionDouble(default_thickness, 0.2,
                                                    1000)
    opt_borderthickness = Rhino.Input.Custom.OptionDouble(
        default_borderThickness, 0.2, 1000)
    opt_border = Rhino.Input.Custom.OptionToggle(default_borderBool, "No",
                                                 "Yes")

    go.SetCommandPrompt(
        "Select terrain surface. (Note: Border Mode is in beta and may fail)")
    go.AddOptionDouble("MaterialThickness", opt_thickness)
    go.AddOptionDouble("BorderThickness", opt_borderthickness)
    go.AddOptionToggle("Border", opt_border)

    go.GroupSelect = True
    go.SubObjectSelect = False
    go.AcceptEnterWhenDone(True)
    go.EnableClearObjectsOnEntry(False)
    go.EnableUnselectObjectsOnExit(False)
    go.GroupSelect = True
    go.SubObjectSelect = False
    go.DeselectAllBeforePostSelect = False

    res = None
    bHavePreselectedObjects = False

    while True:
        res = go.Get()
        #If new option entered, redraw a possible result
        if res == Rhino.Input.GetResult.Option:
            go.EnablePreSelect(False, True)
            continue
        #If not correct
        elif res != Rhino.Input.GetResult.Object:
            return Rhino.Commands.Result.Cancel
        if go.ObjectsWerePreselected:
            bHavePreselectedObjects = True
            go.EnablePreSelect(False, True)
            continue
        break

    #rs.EnableRedraw(False)
    global THICKNESS
    THICKNESS = opt_thickness.CurrentValue
    global BORDER_THICKNESS
    BORDER_THICKNESS = opt_borderthickness.CurrentValue
    global BORDER_BOOL
    BORDER_BOOL = opt_border.CurrentValue
    global LCUT_INDICES
    LCUT_INDICES = wla.get_lcut_layers()

    #set guides
    global SHORT_GUIDE, LONG_GUIDE
    SHORT_GUIDE = rs.AddLine([0, 0, 0], [0, 0, -THICKNESS])
    LONG_GUIDE = rs.AddLine([0, 0, 0], [0, 0, -THICKNESS * 4])
    rs.LockObjects([SHORT_GUIDE, LONG_GUIDE])

    #set layers
    global LCUT_IND
    LCUT_IND = wla.get_lcut_layers()

    #get topography object
    brep_obj = go.Object(0).Object()

    sticky["Thickness"] = THICKNESS
    sticky["borderThickness"] = BORDER_THICKNESS
    sticky["borderBool"] = BORDER_BOOL

    rs.LockObject(brep_obj.Id)
    building_brep_guids = rs.GetObjects("Select breps representing buildings",
                                        filter=16)
    engraving_crv_guids = rs.GetObjects("Select curves to engrave on terrain",
                                        filter=4)
    rs.UnlockObject(brep_obj.Id)

    return brep_obj, building_brep_guids, engraving_crv_guids
Пример #8
0
def rc_plot_volumes(use_epsilon):
    #get sticky
    default_thickness = sticky["defaultThickness"] if sticky.has_key(
        "defaultThickness") else 5.5

    go = Rhino.Input.Custom.GetObject()
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep

    opt_thickness = Rhino.Input.Custom.OptionDouble(default_thickness, 0.2,
                                                    1000)
    opt_sections = Rhino.Input.Custom.OptionToggle(False, "No", "Yes")
    opt_inplace = Rhino.Input.Custom.OptionToggle(False, "No", "Yes")
    opt_heights = Rhino.Input.Custom.OptionToggle(False, "No", "Yes")

    go.SetCommandPrompt("Select breps to extract plan cuts")
    go.AddOptionDouble("Thickness", opt_thickness)

    go.GroupSelect = True
    go.SubObjectSelect = False
    go.AcceptEnterWhenDone(True)
    go.AcceptNothing(True)
    go.EnableClearObjectsOnEntry(False)
    go.EnableUnselectObjectsOnExit(False)
    go.GroupSelect = True
    go.SubObjectSelect = False
    go.DeselectAllBeforePostSelect = False

    res = None
    bHavePreselectedObjects = False

    while True:
        res = go.GetMultiple(1, 0)
        #If new option entered, redraw a possible result
        if res == Rhino.Input.GetResult.Option:
            # print res
            go.EnablePreSelect(False, True)
            continue
        #If not correct
        elif res != Rhino.Input.GetResult.Object:
            return Rhino.Commands.Result.Cancel
        if go.ObjectsWerePreselected:
            bHavePreselectedObjects = True
            go.EnablePreSelect(False, True)
            continue
        break

    rs.EnableRedraw(False)

    global THICKNESS
    THICKNESS = opt_thickness.CurrentValue

    global LCUT_INDICES
    LCUT_INDICES = wla.get_lcut_layers()

    #Get brep representations of objects
    brep_geo_list = []
    for i in xrange(go.ObjectCount):
        b_obj = go.Object(i).Object()
        brep_geo_list.append(b_obj.Geometry)

    #...brep conversion may be necessary
    new_brep_list = []
    for i, geo in enumerate(brep_geo_list):
        if geo.GetType() != Rhino.Geometry.Brep:
            new_brep_list.append(wru.extrusion_to_brep(geo))
        else:
            new_brep_list.append(geo)

    #set base for output.
    xbase = 0
    ybase = 0
    #set the amount to move up from the bottom of the brep for cutting the lower outline.
    #this should be replaced by a projection of the bottom face of the brep.
    epsilon = D_TOL * 2

    select_items = []
    for i, brep in enumerate(new_brep_list):

        #get label prefix and bounding dims for this brep
        bdims = wge.get_bounding_dims(brep)
        baseplane = rs.MovePlane(rs.WorldXYPlane(), [xbase, ybase, 0])
        label_letter = wut.number_to_letter(i)
        label_prefix = label_letter + "-"

        #prepare heights and labels for each section cut
        num_sections = 1
        remaining_thickness = 0
        cuts_at = [epsilon] if use_epsilon else [0]
        brep_label = label_letter
        section_labels = [label_letter]

        num_sections, remaining_thickness, cuts_at = get_section_division(
            bdims.Z, THICKNESS)
        if use_epsilon: cuts_at[0] = epsilon
        brep_label = label_letter + " r: " + str(round(remaining_thickness, 2))
        section_labels = [label_prefix + str(i) for i in xrange(len(cuts_at))]

        #get section information for each cut
        section_planes = get_brep_section_planes(brep, cuts_at)

        #get lowest curve info
        section_curves, section_dims = [[], []]
        for i, plane in enumerate(section_planes):
            curve, dims = [0, 0]
            if (not use_epsilon) and (i == 0):
                curve, dims = get_lowest_curve_info(brep, D_TOL * 2)
            else:
                curve, dims = get_section_curve_info_multi_no_ortho(
                    brep, plane)
            section_curves.append(curve)
            section_dims.append(dims)

        ##DO WORK HERE##
        drawing_planes = get_drawing_planes(section_dims, baseplane, GAP_SIZE)

        #place curves in drawing location
        for sp, dp, sc in zip(section_planes, drawing_planes, section_curves):
            t = Rhino.Geometry.Transform.ChangeBasis(dp, sp)
            for c in sc:
                c.Transform(t)

        #THIS IS STILL A MESS: LABEL ADDING
        #draw curves and add text dots
        top_label_pt = get_brep_label_pt(brep)
        brep_textdot = rs.AddTextDot(brep_label, top_label_pt)
        rs.ObjectLayer(brep_textdot, "XXX_LCUT_00-GUIDES")

        label_pts = []
        for sc, label in zip(section_curves, section_labels):
            temp_area = 0
            for i, c in enumerate(sc):
                crv = wru.add_curve_to_layer(c, LCUT_INDICES[1])
                select_items.append(crv)
                if i == 0:
                    label_pts.append(rs.CurveAreaCentroid(crv)[0])
                    temp_area = rs.CurveArea(crv)
                else:
                    if rs.CurveArea(crv) > temp_area:
                        label_pts[-1] = rs.CurveAreaCentroid(crv)[0]
                        temp_area = rs.CurveArea(crv)

        fab_tags = wfa.add_fab_tags(label_pts, section_labels, TEXTSIZE)
        for tag in fab_tags:
            rs.ObjectLayer(tag, "XXX_LCUT_02-SCORE")
            group_name = rs.AddGroup()
            rs.AddObjectsToGroup(tag, group_name)

        ybase += max([s.Y for s in section_dims]) + GAP_SIZE * 1

        for tag in fab_tags:
            select_items.extend(tag)
        #THIS IS STILL A MESS: LABEL ADDING

    sticky["defaultThickness"] = THICKNESS

    rs.UnselectAllObjects()
    rs.SelectObjects(select_items)
    rs.Redraw()
    rs.EnableRedraw(True)