Create Group and Access by Name - Invalid Group Name Error

Discussion in 'AutoCAD' started by Pat Cichanski, Feb 16, 2004.

  1. I have a problem creating a group. I manage to create the group, using code
    similar to this:

    ThisDrawing.Groups.Add("NewGroup")

    I even can add items to the group from a selection set.

    I go to AutoCad, I can see the group by name in the Group Dialog Box. I can
    even manipulate the group.

    Now the tricky part - I am trying to explode the items in the group. So I
    issue the command:
    Explode Group NewGroup.

    I get the following message: Invalid Group Name

    I know this can be done- if I manually create the group and add items to it,
    this works. However, for some reason, the
    group I create programmatically can not be accessed by name in the explode
    command.

    Does anyone have an idea?
    Thanks
     
    Pat Cichanski, Feb 16, 2004
    #1
  2. Pat Cichanski

    SpeedCAD Guest

    Hi...

    I see that you no put "" in the name of group "NewGroup".

    Also you can use SendCommand:

    ThisDrawing.SendCommand "_explode" & vbCr & "_g" & vbCr & "A" & vbCrLf

    Un Saludo de SpeedCAD... :)
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Feb 17, 2004
    #2
  3. Not sure what you mean.

    To clarify:

    I create a group using code similar to:

    ThisDrawing.Groups.Add("NewGroup")

    I add items to the group, again using code. I then
    try to explode, using the SendCommand just like you
    show here. It didn't work.

    I put a break point in my code to test and review directly in the DWG:
    - the group shows up in the Group dialog box
    - the items I added are included in the group; I can highlight, etc.
    - however, when I issue the command to explode: Explode - Group - NewGroup
    I get the Invalid Group Name error.

    Another wrinkle in the problem - my code is actually in .NET using C# and
    the AutoCAD
    COM interface. Is there a bug in the object model such that the Group being
    created has
    a bad Name?

    Any help would be appreciated. I realize that my best solution is to turn
    to ObjectArx and
    write a routine there that would allow me to explode the items I want,
    however I am looking for
    an interim solution.

    thanks
     
    Pat Cichanski, Feb 17, 2004
    #3
  4. Pat,

    Look at the object model for a Group object. You don't use explode...

    Sub SampleMake()
    Dim grp As AcadGroup
    Set grp = ThisDrawing.Groups.Add("Sample")
    Dim pt0(0 To 2) As Double
    Dim objs(0 To 1) As AcadEntity
    Set objs(0) = ThisDrawing.ModelSpace.AddCircle(pt0, 1#)
    Set objs(1) = ThisDrawing.ModelSpace.AddCircle(pt0, 2#)
    grp.AppendItems objs
    End Sub

    Sub SampleGone()
    ThisDrawing.Groups.Item("Sample").Delete
    End Sub


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    Not sure what you mean.

    To clarify:

    I create a group using code similar to:

    ThisDrawing.Groups.Add("NewGroup")

    I add items to the group, again using code. I then
    try to explode, using the SendCommand just like you
    show here. It didn't work.

    I put a break point in my code to test and review directly in the DWG:
    - the group shows up in the Group dialog box
    - the items I added are included in the group; I can highlight, etc.
    - however, when I issue the command to explode: Explode - Group - NewGroup
    I get the Invalid Group Name error.

    Another wrinkle in the problem - my code is actually in .NET using C# and
    the AutoCAD
    COM interface. Is there a bug in the object model such that the Group being
    created has
    a bad Name?

    Any help would be appreciated. I realize that my best solution is to turn
    to ObjectArx and
    write a routine there that would allow me to explode the items I want,
    however I am looking for
    an interim solution.

    thanks
     
    R. Robert Bell, Feb 17, 2004
    #4
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.