API code for seperating individual prt files from Design Table config.
API code for seperating individual prt files from Design Table config.
(OP)
hi,
Has anyone API coding to seperate indivdual files from design table config file?.
i already created multiple configurations (nearly 60 configurations) using design table.but my client needs these config files as a single, separate, individual file.
anybody using API macro for separating the config file as individual files? pls send the api coding....
thanks,
Regards,
Murugan.S
Design Engineer,
GlobalSoft Pvt Ltd,
New Delhi, INDIA.
murugan_subham@yahoo.com.
Has anyone API coding to seperate indivdual files from design table config file?.
i already created multiple configurations (nearly 60 configurations) using design table.but my client needs these config files as a single, separate, individual file.
anybody using API macro for separating the config file as individual files? pls send the api coding....
thanks,
Regards,
Murugan.S
Design Engineer,
GlobalSoft Pvt Ltd,
New Delhi, INDIA.
murugan_subham@yahoo.com.






RE: API code for seperating individual prt files from Design Table config.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc
Dim swConfig As SldWorks.configuration
Set swConfig = swModel.GetActiveConfiguration
Dim fname, ext, current As String
fname = swModel.GetPathName
ext = Mid(fname, InStr(fname, ".")) ' extension with leading dot
fname = Mid(fname, 1, InStr(fname, ".") - 1) ' path + name without extension
current = swModel.GetActiveConfiguration.name
Dim configs As Variant
configs = swModel.GetConfigurationNames
Dim i As Long
For i = 0 To UBound(configs)
If Not swModel.ShowConfiguration2(configs(i)) Then
Debug.Print ("Could not switch to config " + configs(i))
Else
Dim name As String
name = fname + "-" + configs(i) + ext
Dim err As Long
Dim warning As Long
Call swModel.SaveAs4(name, swSaveAsCurrentVersion, _
swSaveAsOptions_Copy + swSaveAsOptions_Silent + swSaveAsOptions_AvoidRebuildOnSave, _
err, warning)
Dim newdoc As SldWorks.ModelDoc2
Set newdoc = swApp.OpenDoc(name, swDocPART) ' works only for parts at the moment
If Not (newdoc Is Nothing) Then ' let's remove the unneeded configs
Dim j As Long
For j = 0 To UBound(configs)
If (i <> j) Then newdoc.DeleteConfiguration (configs(j))
Next j
swApp.CloseDoc (name)
End If
End If
Next i
swModel.ShowConfiguration2 (current) ' revert to current config
End Sub
CorBlimeyLimey, Barrie, Ontario.
FAQ559-863
RE: API code for seperating individual prt files from Design Table config.
John Richards Sr. Mech. Engr.
Rockwell Collins Flight Dynamics
A hobbit's lifestyle sounds rather pleasant...... it's the hairy feet that turn me off.
RE: API code for seperating individual prt files from Design Table config.
thanks,
Regards,
Murugan.S
Design Engineer,
GlobalSoft Pvt Ltd,
New Delhi, INDIA.
murugan_subham@yahoo.com.
RE: API code for seperating individual prt files from Design Table config.
I tried the macro last night & it worked...sort of....it made copies of the file complete with all configurations and left each one with the relevant config active. So you have to go in & delete all the unused or unwanted configs anyway. So you were right. Oh well, you never know unless you try.
It could probably be modified to work properly.....if I knew what I was doing!!!!
murugansubham
Did you have better luck?
CorBlimeyLimey, Barrie, Ontario.
FAQ559-863
RE: API code for seperating individual prt files from Design Table config.
Well, like I said it is often a case of do I need this once only, or is it something I need on a regular basis?
John Richards Sr. Mech. Engr.
Rockwell Collins Flight Dynamics
A hobbit's lifestyle sounds rather pleasant...... it's the hairy feet that turn me off.