Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API code for seperating individual prt files from Design Table config.

Status
Not open for further replies.

murugansubham

Mechanical
Sep 24, 2003
89
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.
 
Replies continue below

Recommended for you

I have not tried the following macro, but it is supposed to do what you want. It is not mine so I cannot take credit for it & unfortunately I do not remember where I downloaded it from. Hope it helps anyway.


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


[cheers]
CorBlimeyLimey, Barrie, Ontario.
[bigsmile] Sign on a Barrie restaurant reads, &quot;We serve Molsons, but we only smoke Ribs&quot; [bigsmile]
faq559-863
 
Do you need to do this an a regular basis? If not I would think that it would be much less time consuming to just make multiple copies of the file, then go in and delete all but one configuration in each. It would seem that in the time taken to ask the forum, write up, install and debugg the program you could do it manualy. (Not suggesting there is anything wrong with the macro CBL posted - there's always some debug of some sort with new stuff.)

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.
 
thanks CorBlimeyLimey and JNR for quick reply.i'll check it out.
thanks,

Regards,
Murugan.S
Design Engineer,
GlobalSoft Pvt Ltd,
New Delhi, INDIA.
murugan_subham@yahoo.com.








 
JNR
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?

[cheers]
CorBlimeyLimey, Barrie, Ontario.
[bigsmile] Sign on a Barrie restaurant reads, &quot;We serve Molsons, but we only smoke Ribs&quot; [bigsmile]
faq559-863
 
Hmm.... interesting apparently a Macro to make multiple copies of a part - one for each configuration (whether in the DT of not?). That in itself could perhaps be useful.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor