An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part
An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part
(OP)
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
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






RE: An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part
RE: An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part
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)
RE: An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part
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
RE: An API Macro to Search Assemblies for a Part and Replace it with a Virtual Part
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