cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How do you select grouped items in macros?

TimSharp
6-Contributor

How do you select grouped items in macros?

Apologies for posting this in both forums - I have just discovered the macro forum! I'm doing a simple macro to remove a certain linetype within an area selected on the screen. It assumes the area is pre-selected using "Selection and manipulation of items in groups". However, if you enclose a grouped item completely within your selection, it does not process the grouped part. If you enclose only part of the grouped selection, it will process it. Is there a switch or setting when running a command on a selected area that will work through groups as well as non-grouped items?
5 REPLIES 5

I assume that you loop over the selected elements with ".nextSelectedElement". For each selected element you may test if its ".type" is a "'Group'". If it is, you may explore its children with ".firstChild" and ".nextSibling".
TimSharp
6-Contributor
(To:bgraffmann)

Thanks for your answer. I programmed commercial macros for CoCreate's ME10 for years, but this language is completely different and I don't understand how it works. What I need really are tutorials that explain the syntax and have examples of quite simple finished macros - the help files don't go far enough. Thanks again, it's pointing me in the right direction
TimSharp
6-Contributor
(To:TimSharp)

I haven't managed to get this to work yet. I don't know enough about the macro language to utilise what the earlier post said - can someone please give me a bit of code that I can use to select within grouped items?

Macro Step_Through_Groups Define el as Element #Clears selection. Select All #Sets focus to first selected element. el = ActiveDoc.FirstSelectedElement #Loops through all selected objects. While (Exists(el) = True) #Checks if current selection is a group. If (el.Type = "Group") Then Message "This is a group, so do something!" Else Message "This is not a group." End If #Advances to next element. el = el.NextSelectedElement End While End Macro
TimSharp
6-Contributor
(To:thendricks)

Thanks very much.
Top Tags