Run macro on selected components

Hello

I have a macro that allows you to save all the parts in an assembly, and I'd like to change it to save only the selected components.

I tried a few things, like replacing all the "Get_Depends" with "Getselection" but it's not that simple ... :s

Can you advise me?

The macro being too long to enter a post, I slip it into an attachment


rebuildnsaveallparts.swp

Hello
And no, it's not that simple, especially since "Get_Depends" is an internal function of your macro!!
To save only the selected parts and assemblies, you need to be able to do something like:
- Count the selected items with the "GetSelectedObjectCount2" function.
- Create a loop on this quantity to:
    - Retrieve the selected objects with the "GetSelectedObject6" function.
    - Retrieve the object type for each selected item with the "GetSelectedObjectType3" function.
    - If the selected object is a part or assembly, retrieve the "ModelDoc2" from it with the "GetModelDoc2" function.
    - Open this "ModelDoc2" with the "OpenDoc6" function.
    - Rebuild this "ModelDoc2" with the "ForceRebuild3" function.
    - Save this "ModelDoc2" with the "Save3" function.
    - Close this "ModelDoc2" with the "CloseDoc" function.
- Get out of the loop.
- Display a message of completion of processing.
Kind regards

Well I'm ready to get there!

I'll compare it with my existing macro to try to find my way around

Thank you in any case

Yes, you are... Or you try with the attached macro, be careful, it is completely redone to serve as an example so you won't necessarily find all your features.

Kind regards


macrosaveallselectedobject.swp

Awesome! it works as I want!

it will save me a lot of time

THANK YOU Doctor!