1/30 – 1/31 Lines of code – camilo tirado

import rhinoscriptsyntax as rs
# Author: Camilo Tirado
# Date: Jan 31st, 2016
# Purpose: arrays of honeycombs for lasercut
# Input Parameters: None
# Output Parameters: None

def addWorkArea():
    """
    purpose: to define the area of the material
    input parameters: none
    output parameteres: none
    """
    pass
    plane = rs.WorldXYPlane()
    x = rs.GetInteger("Width", None, 30, None)
    y = rs.GetInteger("Height", None, 30, None)
    rs.AddRectangle(plane, x, y)
    
def addHexagon():
    """
    purpose: to create the basic geometry.
    input parameters: none
    output parameters: none
    """
    rs.AddLine([6,4,0],[6,6,0])
    times = 5
    for j in range(times):
        Line = rs.GetObject("Select Line to rotate")
        if Line:
            point = rs.GetPoint("Center point of rotation")
            if point: rs.RotateObject(Line, point, -60, None, copy=True)
    ends = rs.GetPoints(draw_lines = True, message1 = "pick ends", max_points = 6)
    points = rs.AddPoints(ends)
    rs.AddCurve(rs.GetPoints(),1)
    lines = rs.GetObjects("Select Lines to delete")
    rs.DeleteObjects(lines)
    del_points = rs.GetObjects("Select Points to Delete", 1)
    rs.DeleteObjects(del_points)

def addHoneyComb():
    """
    purpose:add inner layer of honeycomb and hatch.
    input parameters: none
    output parameters: none
    """
    Hexagon = rs.GetObject("Select Hexagon",4)
    rs.OffsetCurve(Hexagon, [6,5,0], 0.30,)
    honeycombs = rs.GetObjects("Select honeycombs",4)
    if honeycombs:
        if rs.IsHatchPattern("Grid60"):
            rs.AddHatches(honeycombs,"Grid60", 1)
        else:
                rs.AddHatches(honeycombs, rs.CurrentHatchPattern())
    rs.AddGroup("HoneyComb")
    HoneyComb = rs.GetObjects("Pick Honeycomb and Hatch")
    rs.AddObjectsToGroup(HoneyComb, HoneyComb)

def addLayout():
    """
    purpose: to create a layout of honeycombs
    input parameters: none
    output parameters: none
    """
    times = 5
    for j in range(times):
        HoneyComb = rs.GetObjects("Select HoneyComb and Hatch")
        point1 = rs.GetPoint("Pick Fist Point of Miror Line")
        point2 = rs.GetPoint("Pick Second Point of Mirror Line")
        rs.MirrorObjects(HoneyComb, point1, point2, True)
        
def addArray1():
    """
    purpose: rotates the layout around the outter edge of selected Honeycomb
    to add another layout rotated to 120 degree
    input parameters: none
    output parameters: none
    """
    Layout = rs.GetObjects("Select Layout to Rotate")
    if Layout:
        point = rs.GetPoint("Select Rotation Point")
        if point:
            rs.RotateObjects(Layout, point, 120, None, True)
    Layout = rs.GetObjects("Select Layout to Rotate")
    if Layout:
        point = rs.GetPoint("Select Rotation Point")
        if point:
            rs.RotateObjects(Layout, point, 120, None, True)
            Cleanup = rs.GetObjects("Select Honeycombs to Delete") 
            rs.DeleteObjects(Cleanup)

def addArray2():
    """
    purpose: mirrors the Array1
    input parameters: none
    output parameters: none
    """
    Layout2 = rs.GetObjects("Select Array")
    if Layout2:
        point1 = rs.GetPoint("Select First Point of Mirror Line")
        point2 = rs.GetPoint("Select Second Point of Mirror Line")
        rs.MirrorObjects(Layout2, point1, point2, True)

def LaserCut1():
    
    addWorkArea()
    addHexagon()
    addHoneyComb()
    addLayout()
    addArray1()
    addArray2()

LaserCut1()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s