×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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.

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

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


CorBlimeyLimey, Barrie, Ontario.
Sign on a Barrie restaurant reads, "We serve Molsons, but we only smoke Ribs"
FAQ559-863

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

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.

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

(OP)
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.
 



 
 


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

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?


CorBlimeyLimey, Barrie, Ontario.
Sign on a Barrie restaurant reads, "We serve Molsons, but we only smoke Ribs"
FAQ559-863

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

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources