rvetrano
08-25-2004, 06:00 AM
Hi
What I would like to do is place 2 or more items in my drawing and group them. when I use this code it groups everything. Haven't been able to figure out how to create a selection set of the objects that are placed in the drawing and then get them into the group.
Thanks
Bob v
Sub CircleGroup()
Dim GroupObj As AcadGroup
Dim ObjForGroup() As AcadEntity
Dim CircleObj As AcadCircle
Dim LineObj As AcadLine
Dim Nameobj As String
Dim Center As Variant, Radius As Double
Dim StartPt(0 To 2) As Double, EndPt(0 To 2) As Double
Dim count As Integer
Dim x As Integer
Randomize ' Initialize random-number generator.
x = Int((100 * Rnd) + 1)
Center = ThisDrawing.Utility.GetPoint(, "Get circle Center")
Radius = 1.5
Set CircleObj = ThisDrawing.ModelSpace.AddCircle(Center, Radius)
CircleObj.Layer = "circle"
StartPt(0) = Center(0): StartPt(1) = Center(1): StartPt(2) = Center(2)
EndPt(0) = Center(0) + Radius + 0.5: EndPt(1) = Center(1): EndPt(2) = Center(2)
Set LineObj = ThisDrawing.ModelSpace.AddLine(StartPt, EndPt)
LineObj.Layer = "line"
ReDim ObjForGroup(0 To ThisDrawing.ModelSpace.count - 1) As AcadEntity
For count = 0 To ThisDrawing.ModelSpace.count - 1
Set ObjForGroup(count) = ThisDrawing.ModelSpace.Item(count)
Next
Nameobj = "groupobj" & x
Set GroupObj = ThisDrawing.Groups.Add(Nameobj)
MsgBox "... " & GroupObj.Name
GroupObj.AppendItems ObjForGroup
GroupObj.Highlight True
ThisDrawing.Regen acActiveViewport
ZoomAll
End Sub
What I would like to do is place 2 or more items in my drawing and group them. when I use this code it groups everything. Haven't been able to figure out how to create a selection set of the objects that are placed in the drawing and then get them into the group.
Thanks
Bob v
Sub CircleGroup()
Dim GroupObj As AcadGroup
Dim ObjForGroup() As AcadEntity
Dim CircleObj As AcadCircle
Dim LineObj As AcadLine
Dim Nameobj As String
Dim Center As Variant, Radius As Double
Dim StartPt(0 To 2) As Double, EndPt(0 To 2) As Double
Dim count As Integer
Dim x As Integer
Randomize ' Initialize random-number generator.
x = Int((100 * Rnd) + 1)
Center = ThisDrawing.Utility.GetPoint(, "Get circle Center")
Radius = 1.5
Set CircleObj = ThisDrawing.ModelSpace.AddCircle(Center, Radius)
CircleObj.Layer = "circle"
StartPt(0) = Center(0): StartPt(1) = Center(1): StartPt(2) = Center(2)
EndPt(0) = Center(0) + Radius + 0.5: EndPt(1) = Center(1): EndPt(2) = Center(2)
Set LineObj = ThisDrawing.ModelSpace.AddLine(StartPt, EndPt)
LineObj.Layer = "line"
ReDim ObjForGroup(0 To ThisDrawing.ModelSpace.count - 1) As AcadEntity
For count = 0 To ThisDrawing.ModelSpace.count - 1
Set ObjForGroup(count) = ThisDrawing.ModelSpace.Item(count)
Next
Nameobj = "groupobj" & x
Set GroupObj = ThisDrawing.Groups.Add(Nameobj)
MsgBox "... " & GroupObj.Name
GroupObj.AppendItems ObjForGroup
GroupObj.Highlight True
ThisDrawing.Regen acActiveViewport
ZoomAll
End Sub