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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Trying to delete selected items within groups

TimSharp
12-Amethyst

Trying to delete selected items within groups

We use a lot of 3d data from IGES files and they create a "Border" line type for internal surfaces. We keep some of these but most of them want deleting and I'm trying to do a macro that allows you to select an area on a drawing and delete the "Border" linetype within that area. The macro is just this: Subselect if Pen is equal to 'Border' Delete selection Select none You would think that when the selection arrow is set to (+) (i.e. selection within groups), it would delete all the border lines within the selected area. But if a grouped item is wholly within the selected area (you can tell this because the selection shows it as 1 item rather than individual lines), then it does not delete the border lines within that group - it only does it for partially selected groups. How do I make it work globally on the selected area regardless of whether a group is wholly or partially selected?
20 REPLIES 20

If I'm following correctly, it sounds like you want to change the functionality of the selection tool basically. I might recommend a slightly different approach to selection. Use the lasso tool instead. This will grab partially selected items. To use it, have one of the selection tools selected and then hold down Alt when you are clicking and dragging.

Sorry I didn't explain what I'm trying to do very well. I do already use the lasso tool to select. The idea is that we select an area of the drawing, then run the macro to delete all the 'Border' line type within the selection. If just part of a grouped element is selected, all the 'Border' lines in that grouped item that lie within the selection are deleted - which is OK. However, if a whole grouped element is within the selection, the macro won't delete any of the 'Border' line type in that grouped element - which is not OK. I'm just trying to find a way to make it look for and remove the 'Border' line type in a selected area of the drawing, including grouped elements. The ME10 macro language had a global function to make it work through everything selected, but there doesn't seem to be one in Isodraw.

The only way I can think of is to loop through your selection looking for groups. Then looping through those groups. Slow and messy, but I don't see anything else. If you find something, please post as I'd like to see the result.

Attached is an example of part of a drawing we're trying to clean up. The chain is made of of separate gathered links. It has lots of fill in construction lines ('Border' line type). If you lasso any area (with "+" option on the select tool, then use the following macro macro delete_border_lines Subselect if Pen is equal to 'Border' Delete selection Select none end macro It ignores the chain links that are completely within the selection, but removes the blue 'Border' lines from links that are only partly selected.
TimSharp
12-Amethyst
(To:TimSharp)

Sorry our posts crossed. Seems strange that something as simple as this isn't covered by the macro language.

This might seem obvious, but I know I get wrapped iup in a task and sometimes miss things like this. How important is the grouping to you? As an alternative, you could remove the grouping and then run your macro. You could make the ungrouping part of the macro itself. It's not a great approach, but if grouping isn't something that you care too much about, it would take care of your problem.

Unfortunately grouping is central to our drawings. We often modify or re-use drawing components and if everything was ungrouped, they would be very difficult to edit in future, so I can't really use that route. Can't understand why the select + setting doesn't work through parts in a macro - that's what it's for isn't it? Is this a bug or do macros process things differently? Thanks for your help though.

I assumed the grouping was important, it always is. Could you, instead of selecting the graphic in particular you want to remove the border pen from, instead just remove it from the entire page? In the sample file you provided, I simply selected none and then selected if pen equaled border. It selected properly and I was able to delete the pen. I may have another approach if this will not work, but let me know on the above first.

Unfortunately again we don't want all border lines removing. Many of them are important so we have to be selective. The idea is we lassoo an area that we know all border lines want removing, then it's much quicker to just pick off the ones we've missed individually. I did think of looping through all the parts in the selection and changing border pens to a new pen type, then removing the new pen type at the end of the macro but I couldn't make it work.

When you select, do you only want the items selected to be affected, or also the entire group that was partially selected?

We just want everything that is completely within the lasso'd area to be affected, whether it's a completely selected grouped element or a partially selected grouped element or ungrouped.

This is not a perfect answer, but it's about as good as I can get it at this point. The one major flaw is that if you have groups within groups, it does not work. It will only go one level down.
e8f5e80194

Thanks Trevor, sorry only just had time to look at the forums. This is a big step forward as I couldn't think of a way of making it delete items when they were selected. Unfortunately our iges files do come with lots of nested grouped items so this will only get groups in the top level and I'll need to find a way of getting down through an unknown number of grouped levels if that's possible. Being able to alter specific items within a selected area regardless of groupings would open up lots more possibilites for macros. My previous CAD macro language for ME10 had a 'global' parameter that worked on everything selected regardless of grouping or layers. Isn't the Isodraw selection tool with the + option supposed to do that? But thanks again, every time you give an example macro, you show me new ways of achieving things.
TimSharp
12-Amethyst
(To:TimSharp)

This works really well except for one thing. If we make a mistake and delete more lines than we want, we undo it and the lines come back. BUT when we run the macro next time, it will delete the same lines again even if they are not selected, because they have had the 'delete' object info added (and undo does not remove it). Adding delete Object_attribute "Delete" E2 at the start of the macro only removes the "Delete" info from items currently selected. Any other items that have the "Delete" info from a previous run of the macro will be deleted as well. This is where I get frustrated with Isodraw. I thought I'd be able to remove the 'delete' object info from the whole drawing before each run of the macro so that doesn't delete lines that are NOT selected, but I can't find a way of doing this - is it possible?

I haven't tried this, but this is the approach to go for. You'll need to insert the statement in two spots to clear the object info. Once after the, "While (Exists(E2) = True) statement and then again after the base "Else" statement. You may end up having to check for the object info to see if it exists before you can clear it (to avoid an error).

Thanks Trevor I've done this and it works for items that are selected. BUT the main problem is that it's deleting things that are not selected. This is because if you run the macro and it deletes more than you want, you will select a different area when you run it again, but previously selected items will also get deleted because they had the info added last time the macro was run. I wonder if there is a way of globally removing or changing object info at the start of the macro - i.e. not just on items that are selected but all items to make sure it starts with a clean slate.

Try this. Changed the last comment to a subselect. Note that if you want to do a clean up after all is said and done, you could have a separate macro that selects where the Delete attribute equals yes, and then just cycle through and clear them.
568467a0d6

I think I see what you intend to do - make it only change the info on items that are in the current selection, but unfortunately the subselect is put in after "select none", so it doesn't work on just the selected items. Also, a subselect doesn't seem to work through grouped items either (I tried putting it before the "select none" to see). I can't think of a way round this. If there was a simple way to change info on everything at the start of the macro (either to remove the "Delete" info or to change it's valie to "No"), that would work.

I swear I had this working. Just to point out that the select none has been commented out. I meant to delete that line before posting. In any regards, it doesn't work. As a quick fix you could create a clean_up macro that you'd have to run after undoing which would select if delete was yes, then cycle through those objects and either delete the attributes or just reset the value of the delete attribute.[/code]

Yes of course - I didn't notice that you'd commented out the "select none" line - sorry. Logically you'd think the subselect would work, but it doesn't seem to work through grouped items. There isn't an inverse selection function is there? If so I could use that, remove existing infos, then work on the actual selection. The command DELETE OBJECT_INFO deep again only works on the current selection. The 'deep' parameter doesn't work with other commands as well does it? I'll do as you say and make a little macro to change the "Delete" info from "yes" to "no" if undo has been used.
Announcements

Top Tags