×
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

Attaching file to SW design binder

Attaching file to SW design binder

Attaching file to SW design binder

(OP)
I am looking to automatically attach a file to the design binder of a solidworks model. I am using SW VB macro code but I cannot figure out how to get my program to automatically place an exiting file, (for example c:\sample.txt} into the binder.

RE: Attaching file to SW design binder

I think a simple macro will not work. You may need to write API to do this. The file will have to be open in SW to access the DB.

Chris
SolidWorks 07 4.0/PDMWorks 07
AutoCAD 06
ctopher's home (updated 04-21-07)

RE: Attaching file to SW design binder

(OP)
I recieved this reply from SW below:

Dear Rick,

Sorry for the delay in getting to this issue.  You can use ModelDocExtension::InsertAttachment to add items to the design binder.  Below is short example macro.  Let me know if you have further questions.


Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swExt As ModelDocExtension
Dim swSelMgr As SelectionMgr
Dim swComp As Component2
Dim swFeat As Feature
Dim swView As View

Dim filePath As String
Dim macroPath As String

Dim swAssem As AssemblyDoc
Dim swPart As PartDoc
Dim swDraw As DrawingDoc

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager

Select Case swModel.GetType
    Case swDocPART
        Set swPart = swModel
    Case swDocASSEMBLY
        Set swAssem = swModel
    Case swDocDRAWING
        Set swDraw = swModel
End Select

filePath = ""
macroPath = CurDir & "\"


Dim bRes As Boolean
bRes = swExt.InsertAttachment("C:\sample.txt", False)

End Sub


Regards,
Robin Richter
SolidWorks Technical Support

SolidWorks Corporation | 300 Baker Avenue | Concord | MA | 01742 | USA www.solidworks.com

Resellers: When reporting customer issues to SolidWorks Technical Support please include customer name, contact name, e-mail address and serial number.

Service Request Number: [SR:1-614669050]

VAR SR#



This works very well

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