예제 #1
0
def insert_new_uo(uo, component, doc):
    """Insert a new user object next to an existing one in the Grasshopper doc.

    Args:
        uo: The user object component instance
        component: The outdated component where the userobject will be inserted
            next to.
        cod: The Grasshopper document object.
    """
    # use component to find the location
    x = component.Attributes.Pivot.X + 30
    y = component.Attributes.Pivot.Y - 20

    # insert the new one
    uo.Attributes.Pivot = sd.PointF(x, y)
    doc.AddObject(uo, False, 0)
def make_new(aBitmap, x_spacing, y_spacing, resolution):
    try:
        for x in range(aBitmap.Width // resolution):
            for y in range(aBitmap.Height // resolution):
                aColour = aBitmap.GetPixel(x * resolution, y * resolution)
                if (aColour.A >
                        128):  #  Make a panel for non-transparent pixels only
                    aPanel = gh.Kernel.Special.GH_Panel()
                    aPanel.NickName = NICKNAME
                    aPanel.UserText = ""
                    aPanel.Properties.Colour = aColour
                    aPanel.Properties.Font = sd.Font("Trebuchet MS", 4)
                    aPanel.Properties.Multiline = False
                    theDoc.AddObject(aPanel, False, theDoc.ObjectCount + 1)
                    aPanel.Attributes.Pivot = sd.PointF(
                        x * x_spacing, y * y_spacing)
                    aPanel.Attributes.Bounds = sd.RectangleF(
                        0, 0, x_spacing, y_spacing)
    except Exception, ex:
        ghenv.Component.AddRuntimeMessage(
            Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning, str(ex))
예제 #3
0
    name = 1
if not ABCD:
    ABCD = 0
if not Numb:
    Numb = 0
nameMode = name + ABCD * 2 + Numb * 4
print("nameMode: " + str(nameMode))

if Run and Count > 0:
    for i in range(Count):

        #create the node
        node = gh.Kernel.Parameters.Param_GenericObject()
        ghdoc.AddObject(node, False, ghdoc.ObjectCount + 1)
        thisPivot = targetInput.Attributes.Pivot
        node.Attributes.Pivot = sd.PointF(thisPivot.X + 100,
                                          thisPivot.Y + (i * 22))
        num = ("{:0>2d}".format(i))
        #1 + 0 + 0
        if nameMode == 1:
            node.NickName = Name
        # 0 + 2 + 0
        if nameMode == 2:
            node.NickName = (alpha[i])
        # 1 + 2 + 0
        if nameMode == 3:
            node.NickName = Name + "_" + alpha[i]
        # 0 + 0 + 4
        if nameMode == 4:
            node.NickName = num
        # 1 + 0 + 4
        if nameMode == 5: