Creating group in VB

Discussion in 'AutoCAD' started by peltsu, Oct 10, 2004.

  1. peltsu

    peltsu Guest

    Hi,
    how do I create a group ( or a selectionset) in VB using objects that I just have created in the code. Is it possible?
    It seems that manuals guide you to select "all" objects from the drawing. However, I'm going to have many similar objects and don't want to select them one more time. I need to rotate the objects in a newly created croup according to the inputpoints by the user.
    Thanks in advance
    Seppo Peltomaa
     
    peltsu, Oct 10, 2004
    #1
  2. If you are creating the entities in your code, then save a reference to them
    as they are created. A collection or scripting dictionary would work
    nicely.
    --
    Bobby C. Jones

    just have created in the code. Is it possible?
    However, I'm going to have many similar objects and don't want to select
    them one more time. I need to rotate the objects in a newly created croup
    according to the inputpoints by the user.
     
    Bobby C. Jones, Oct 10, 2004
    #2
  3. peltsu

    peltsu Guest

    Thanks Boppy,
    however I'm not that advanced user that I could understand your advice. I could rotate all newly created object one by one after their creations, but it sounds clumsy and requires me to set the rotation angle beforehand.

    Yours
    Seppo Peltomaa
     
    peltsu, Oct 11, 2004
    #3
  4. I'm not quite sure what you want to do but you could create an empty selection set and as you create items use the Add method of the selection set. Then you could use a for each loop to process the selection set.
    Regards - Nathan
     
    Nathan Taylor, Oct 11, 2004
    #4
  5. Hi Seppo,
    Here is an example of one way to handle it. Note that this does not
    dynamically show the rotation of the entities.

    Option Explicit
    Private newlyCreatedEntities As Collection
    Private rotationBasePoint() As Double
    Private rotationAngle As Double

    Public Sub RotateNewlyCreatedEntities()
    CreateEntities

    If EntitiesWereCreated() Then
    GetRotationBasePoint

    GetRotationAngle

    RotateEntities
    End If
    End Sub

    Private Sub CreateEntities()
    Set newlyCreatedEntities = New Collection

    Const radius As Double = 4

    Dim circle1CenterPoint(0 To 2) As Double
    Dim circle2CenterPoint(0 To 2) As Double

    circle1CenterPoint(0) = 0: circle1CenterPoint(1) = 0:
    circle1CenterPoint(2) = 0
    circle2CenterPoint(0) = 16: circle2CenterPoint(1) = 0:
    circle2CenterPoint(2) = 0

    With newlyCreatedEntities
    .Add ThisDrawing.ModelSpace.AddCircle(circle1CenterPoint, radius)
    .Add ThisDrawing.ModelSpace.AddCircle(circle2CenterPoint, radius)
    .Add ThisDrawing.ModelSpace.AddLine(circle1CenterPoint,
    circle2CenterPoint)
    End With
    End Sub

    Private Sub GetRotationAngle()
    rotationAngle = ThisDrawing.Utility.GetAngle(rotationBasePoint, vbCr &
    "Select rotation angle: ")
    End Sub

    Private Sub GetRotationBasePoint()
    rotationBasePoint = ThisDrawing.Utility.GetPoint(, vbCr & "Select base
    point: ")
    End Sub

    Private Function EntitiesWereCreated() As Boolean
    EntitiesWereCreated = newlyCreatedEntities.Count > 0
    End Function

    Private Sub RotateEntities()
    Dim entityToRotate As AcadEntity
    For Each entityToRotate In newlyCreatedEntities
    entityToRotate.Rotate rotationBasePoint, rotationAngle
    Next entityToRotate
    End Sub
    --
    Bobby C. Jones

    could rotate all newly created object one by one after their creations, but
    it sounds clumsy and requires me to set the rotation angle beforehand.
     
    Bobby C. Jones, Oct 11, 2004
    #5
  6. peltsu

    peltsu Guest

    Thanks Boppy.
    This looks like something I can understand :). I'm going to give it a try next thing in the morning.
    I found a way to rotate the objects by using handles and it seems to work.
    Yours
    Seppo Peltomaa
     
    peltsu, Oct 11, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.