Macro - Move a file

Hello

 

I'm looking for a way to move parts and assemblies files with updating the position of the parts in the assembly files via a macro.

The ideal for me would be to be able to use solidworks explorer through a macro.

The goal is to be able to archive my parts and assemblies automatically.

Do you have any ideas for carrying out such a task?

 

Thank you.

 

Hello, we need a little more detail.

Do you have any knowledge of VBA programming?

SolidWorks Explorer cannot launch macros, you will have to go through SolidWorks.

To start, you can make a macro by learning a "save as" part in SolidWorks to see the code. If the assembly is open, the part is replaced in the assembly if it is registered.

Do all the parts of a given assembly have to be moved to the same folder?

Thank you for the answer.

So yes I have some notions of VBA, I know how to write solidworks macros that work and I actually use the recording technique to learn new commands.

Not all parts of an assembly and the assembly itself will be placed in the same place in my archive.

If I understand what you're proposing, it's, with a macro:

1) I move all my parts and assemblies to where I want in my archive folders

2) I open all the documents I have just put in my archives.

3) I open my assembly, and solidworks remakes all the links itself.

4) I record my assembly and that's it.

Yes, I feel like it can all work, and it's doable for me. It just seems a bit heavy to me as a method for large assemblies. That's why I'd prefer a method like solidworks explorer in macro mode. 

It's a solution, but it's cumbersome indeed, and I was thinking more about opening the assembly with the parts in the old locations, then launching the macro to automatically save to the new locations and then saving the assembly up to date.

 

The question is, how do you know which piece goes in which folder?

Do you have a marker like a custom property or part of the filename to tell you?

Otherwise it won't be possible...

And as I said above, to my knowledge , SolidWorks Explorer cannot launch macros, you will have to go through SolidWorks.

1 Like

Yes, I'll try to program your method and see what happens.

I do have a personal property for each of the parts that tells me where I should archive the part. Knowing where I need to archive the part is the easiest part of the job:)

Thank you very much in any case for the advice

So a few more leads:

1) Have an open assembly,

2) Go through all the components of it, see this link:

http://help.solidworks.com/2012/English/api/sldworksapi/Traverse_Assembly_at_Component_Level_Example_VB.htm

3) Open each of the pieces (one by one with a loop),

3) Check the custom property for example for the "path" property:

PATH = SWmoddoc.GetCustomInfoValue("", "path")

 

4) Save-under your piece (with the learning macro you made) or this link:

http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IModelDocExtension~SaveAs.html

 

5) Update your custom property that indicates where the room should be registered?

6) Close the room.

7) Save the assembly.


PS: 8) choose this answer as the best if this algorithm suits you ;-)

I'm coming after the battle... And honestly, I was wondering how you were going to designate the file for the receipt of the documents. Apparently, it's solved with a personal property.

 

Well on the other hand, stupid question. Instead of saving it as and opening all the rooms, why not go with a take-home composition?

You can designate piece by piece the registration file, the new name and not lose the link (even attach the 2Ds, but it's a little heavier)

So, since the acceptance file is already defined for each entity, it must be easy to set up.

 

Well I say that, but I've never tried it. I don't even know if it's possible to program. Just a trail passing ;)

1 Like
Does the take-away composition also allow you to change the path of the parts if you don't change the assembly? If so, it seems to me that it is not automatable because with a macro, you will not be able to check or uncheck the boxes in the take-home composition window...
1 Like

To answer your question, yes. You can only change the path of the parts if you don't change the assembly. for all the pieces or just for some. Change names, etc. In short, it's pretty cool (and no, I'm not a fan of it!)

 

On the other hand, it is indeed the fear that I had the ticking and unchecking of the boxes.

So I was thinking of bypassing him by telling him not to record over it (or vice versa) But it's not very clean, you're right.

1 Like

Yes, I just tried the take-home compositing trick, and as you both say it doesn't seem possible with a macro.

1 Like