select a group on the screen in vba

select a group on the screen in vba

Anonymous
Not applicable
1,252 Views
4 Replies
Message 1 of 5

select a group on the screen in vba

Anonymous
Not applicable
hi,

i made a group and tried to select the group on the screen in vba,

i used getentity method,but it selected the seperate objects instead of the
group.

what should i do.

thank you.
0 Likes
1,253 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
"what should i do."
try cycling thru all the objects in the group..


[code]
Public Sub testgroup()
On Error GoTo myERROR
Dim oGrp As AcadGroup
Dim oEnt As AcadEntity
Dim vEntityOrigin As Variant
Dim dblOrigin(0 To 2) As Double
Dim vOrigin As Variant
Dim vSelectedPoint As Variant
Dim dblTempPT(0 To 2) As Double
Dim dblShift As Double

Set oGrp = ThisDrawing.Groups.Item("circles")

'test value
dblShift = 10

'move each object in the group
For Each oEnt In oGrp
Select Case oEnt.ObjectName
'get center of circle
Case "AcDbCircle"
vOrigin = oEnt.Center
Case "AcDbLine"
vOrigin = oEnt.StartPoint
Case "AcDbBlockReference"
vOrigin = oEnt.InsertionPoint
End Select
vSelectedPoint = vOrigin
vSelectedPoint(0) = vSelectedPoint(0) + dblShift
vSelectedPoint(1) = vSelectedPoint(1) + dblShift

oEnt.Move vOrigin, vSelectedPoint
Debug.Print oEnt.ObjectName
Next

'do your analysis here...

'restore original location
For Each oEnt In oGrp
Select Case oEnt.ObjectName
'get center of circle
Case "AcDbCircle"
vOrigin = oEnt.Center
Case "AcDbLine"
vOrigin = oEnt.StartPoint
Case "AcDbBlockReference"
vOrigin = oEnt.InsertionPoint
End Select
vSelectedPoint = vOrigin
vSelectedPoint(0) = vSelectedPoint(0) - dblShift
vSelectedPoint(1) = vSelectedPoint(1) - dblShift

oEnt.Move vOrigin, vSelectedPoint
Debug.Print oEnt.ObjectName
Next

myExit:
If Not oGrp Is Nothing Then
Set oGrp = Nothing
End If
Exit Sub
myERROR:
MsgBox Err.Number & "~" & Err.Description
Err.Clear
Resume myExit



End Sub
[/code]
0 Likes
Message 3 of 5

Anonymous
Not applicable
Use a selection set....

Dim ss As AcadSelectionSet
Set ss = ThisDrawing.PickfirstSelectionSet
ss.SelectOnScreen
Debug.Print ss.Count


"youngman" wrote in message
news:4846919@discussion.autodesk.com...
hi,

i made a group and tried to select the group on the screen in vba,

i used getentity method,but it selected the seperate objects instead of the
group.

what should i do.

thank you.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Jeff,
If he already has the group created, why have the user recreate it?
0 Likes
Message 5 of 5

Anonymous
Not applicable
I read it that he is wanting to be able to select the group....
Just like in the drawing editor (providing selectable groups is enabled) if
you select an item in the group, the entire group is selected.....but
GetEntity only selects the individual item.


wrote in message news:4847353@discussion.autodesk.com...
Jeff,
If he already has the group created, why have the user recreate it?
0 Likes