Python: Select objects made by script and group?

First try in really trying to write a script and I’m stuck on something that is probably obvious.

How can I group the created objects at the end of the script? any tips would also be appreciated. :wink: thanks in advance.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def AddBalloon():

    # some constants
    radius = 0.25
    fontSize = 0.125
    fontOffsetDist = 0.1
    printWidth = 0.60

    # draw leader line
    LeaderPoints = rs.GetPoints(
        True, False, "Select leader LeaderPoints")
    rs.AddLeader(LeaderPoints)
    point = LeaderPoints[-1]

    rs.EnableRedraw(False)

    # draw circle
    circle_id = rs.AddCircle(point, radius)
    rs.ObjectPrintWidth(circle_id, printWidth)

    # hatch circle
    newHatch = rs.AddHatch(circle_id)
    rs.ObjectPrintColor(newHatch, (255, 255, 255))

    # find number
    findNumber = rs.GetString("Enter part find number:")


    # quantity text
    partQuantity = rs.GetInteger("Enter part quantity:")

    if partQuantity > 1:
        # add part quantity and midline
        circleEndPt = rs.CurveEndPoint(circle_id)  # get circle end point
        circlePerpPt = rs.Polar(point, 180, radius) # create perpendicular point
        midLine = rs.AddLine(circleEndPt, circlePerpPt)  # create line
        rs.ObjectPrintWidth(midLine, printWidth)
        rs.SelectObject(midLine)
        rs.Command("_BringToFront _SelNone")
        upperTextPoint = rs.Polar(point, 90, fontOffsetDist)
        rs.AddText(findNumber, upperTextPoint, fontSize, justification=2 + 131072)
        lowerTextPoint = rs.Polar(point, 270, fontOffsetDist)
        rs.AddText(str(partQuantity) + "X", lowerTextPoint, fontSize, justification=2 + 131072)
        rs.EnableRedraw(True)
    else:
        rs.AddText(findNumber, point, fontSize, justification=2 + 131072) # only add find number
        rs.EnableRedraw(True)

AddBalloon()

@kleerkoat,

just assign your created text objects to some variables eg:

myText = rs.AddText(findNumber, .....)

then put your objects like circle, hatch, line etc into a list and add it to a new empty group:

my_group = rs.AddGroup(group_name=None)
objs = [circle_id, newHatch, midLine]
rs.AddObjectsToGroup(objs, my_group)

c.

thank you!