Author Topic: incrementing group names  (Read 3148 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
incrementing group names
« on: August 25, 2005, 05:20:58 PM »
i don't have that much knowledge of using groups but a coworker of mine is looking for a way to be able to incrementally name his groups. he wants to be able to open a drawing and it would read the last group suffix example: group 5. if he were to create a new group it would be named group 6. it would behave the same way if he were to copy that group or if he were to paste in a group from another drawing. i'm just wondering how one might acheive this via lisp or perhaps vba?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
incrementing group names
« Reply #1 on: August 25, 2005, 05:58:58 PM »
You could just use anonymous group names and have a reactor rename them behind the scenes to suit, but it wouldn't be a trivial little exercise.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Bob Wahr

  • Guest
incrementing group names
« Reply #2 on: August 25, 2005, 06:40:24 PM »
really limited testing but this should get you well on your way
Code: [Select]
Sub Fishies()
Dim objGroup As AcadGroup
Dim objGroups As AcadGroups
Dim intGroup As Integer
Dim intTemp As Integer
Dim objSelSet As AcadSelectionSet
Dim objSelSets As AcadSelectionSets
Dim entGrouped() As AcadEntity

On Error GoTo ErrorControl
 
  Set objSelSets = ThisDrawing.SelectionSets
  Set objGroups = ThisDrawing.Groups
  KillSet "Grouper"
 
  Set objSelSet = objSelSets.Add("Grouper")
    objSelSet.SelectOnScreen
 
  For Each objGroup In objGroups
    intTemp = Right(objGroup.Name, 1)
    If intTemp > intGroup Then
      intGroup = intTemp
    End If
  Next objGroup
  ReDim entGrouped(0 To objSelSet.Count - 1)
  For intTemp = 0 To UBound(entGrouped)
    Set entGrouped(intTemp) = objSelSet.Item(intTemp)
  Next intTemp
 
  Set objGroup = objGroups.Add(intGroup + 1)
  objGroup.AppendItems entGrouped

ExitHere:
Exit Sub

ErrorControl:
  Select Case Err.Number
    Case Else
      MsgBox "''" & Err.Description & "'' error has occured in Fishies" & vbCrLf
      GoTo ExitHere
  End Select
 
End Sub


Function KillSet(strSet As String)
  Dim objSelSet As AcadSelectionSet
  Dim objSelSets As AcadSelectionSets
 
  Set objSelSets = ThisDrawing.SelectionSets
     
  For Each objSelSet In objSelSets
    If objSelSet.Name = strSet Then
      ThisDrawing.SelectionSets.Item(strSet).Delete
    Exit For
    End If
  Next

End Function

ELOQUINTET

  • Guest
incrementing group names
« Reply #3 on: August 26, 2005, 09:00:37 AM »
yeah didn't sound like a very simple matter to me either. i was just wondering what your thoughts on it would be.

Bob Wahr

  • Guest
incrementing group names
« Reply #4 on: August 26, 2005, 11:17:08 AM »
Damn, I feel a bit like the invisible man here.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
incrementing group names
« Reply #5 on: August 26, 2005, 11:22:36 AM »
Sorry Bob. Didn't run it but it looks like it would work to me, tho the group name would only be a number (maybe I'm wrong), whereas I think he wanted "name" + number. Nonetheless, certainly a good starting point.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Bob Wahr

  • Guest
incrementing group names
« Reply #6 on: August 26, 2005, 11:29:52 AM »
No need to say sorry MP, it wasn't you who completely ignored my post.
All he would have to do for name +# is strip the right X places off of the name and replace with the number.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
incrementing group names
« Reply #7 on: August 26, 2005, 11:54:14 AM »
Nodding. It happens but it's rarely malicious. Dan's a good egg, maybe he's still processing it.

/guess
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Bob Wahr

  • Guest
incrementing group names
« Reply #8 on: August 26, 2005, 12:24:44 PM »
I'm sure it's not malicious.  I appologize for the tone of my post.  It's been a pretty messed up week which has thinned my skin considerably.  I'll do my best to stick to the "If you can't say anything nice..." rule.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
incrementing group names
« Reply #9 on: August 26, 2005, 12:41:29 PM »
No worries Bob, no harm, no foul. Hope the worst is behind you.

PS: My skin has been thinned so many times I can see my internals; ackkk.

:P
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
incrementing group names
« Reply #10 on: August 26, 2005, 12:47:10 PM »
Bob, would it help if i insult you a bit?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Bob Wahr

  • Guest
incrementing group names
« Reply #11 on: August 26, 2005, 12:55:37 PM »
Probably not today.  You never did that snow thing for me anyway so I don't like you.

ELOQUINTET

  • Guest
incrementing group names
« Reply #12 on: August 26, 2005, 01:50:17 PM »
o i'm sorry bob didn't mean to snub you i've just been very busy and just kind of threw the question out there to see what the responcses would be. it's not my project so it's not really on my mind. i appreciate everyones time and effort. o yeah and mp likes me he reallllly likes me. it's friday man almost over virtual beer for everone ahhhh yum

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
incrementing group names
« Reply #13 on: August 26, 2005, 01:57:36 PM »
I was just sayin' to Mark that we don't get enough Sally Field impressions 'round here.

/technicolor yawn
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
incrementing group names
« Reply #14 on: August 26, 2005, 02:02:43 PM »
What snow thing?! *blink* Oh.... CRAP!? I forgot all about that!  *snicker!*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org