Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part

Status
Not open for further replies.

ckorte

Mechanical
Mar 31, 2016
1
0
0
US
We have multiple parts that contain several configurations used for multiple custom assemblies. For example, a length of flexible PVC maintains a part number within our PDM system. Within that part number of PVC there are multiple configurations. This means that wherever this part is used, which is several different custom assemblies, this part hogs a lot of disk space because it has to carry its multiple configs., even though it only needs one for that specific assembly. Our solution is to convert the PVC part into a virtual part in every assembly that it is used and delete that virtual parts' unneeded configs.

So the question I am asking is this:
Is there a macro out there that prompts for a part number, finds where it is used, converts it to a virtual part, and deletes all unnecessary configurations within that virtual part?

If not, what other way might I automate this process? As of now, it is extremely time consuming.

Thanks for any help,

Cole Korte
 
Replies continue below

Recommended for you

So you have one part that is used in multiple assemblies (each assembly using a unique configuration of the part) and now you want to split the part into individual models, each used in it's own assembly as a virtual part? Are all the other parts in these assemblies virtual? I guess I am having a hard time understanding the logic behind doing this?
 
I'm 99% sure this macro doesn't exist.
I'm also 99% sure it could be written, although probably not for free.
May be worth pursuing if you can justify time spent doing it manually vs. cost for the macro.

-handleman, CSWP (The new, easy test)
 
I agree with handleman, what you are requesting is a purpose built macro. Depending on what you are doing, here are some alternatives.

1) If you are reusing a limited set of geometry, there is a macro out there for saving all of the configs as independent files. These could then be inserted as normal parts in your assemblies.

2) If you are tweaking / recreating the geometry for each application, you could strip down your main files and save them out as one or more part templates that include the part number, description and starter geometry / sketches. These templates could then be used as a quick start for creating the part for the assembly.

Eric
 
Unless I missed something, making the part virtual just makes the assembly file larger so I am not sure what you are gaining in disk space. Virtual parts also bring their own issues. Every time the assembly is open, SolidWorks must create a folder on your hard drive (VC~~), save the virtual part there then open the part. While I have nothing against virtual parts (I like them for reference geometry that does not have part numbers), I think it would be better to make sure the PVC model be made virtual for future assemblies and not worry about existing assemblies. If you are still interested in making the model virtual here is some code you can look at (The component must be pre-selected in your assembly before running it).

Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swComp As SldWorks.Component2
Dim swSelMgr As SldWorks.SelectionMgr

Sub main()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swSelMgr = swDoc.SelectionManager
Set swComp = swSelMgr.GetSelectedObject6(1, -1)

Debug.Print swComp.MakeVirtual

End Sub
 
Status
Not open for further replies.
Back
Top