Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Attaching file to SW design binder

Status
Not open for further replies.

rrohret

Mechanical
Jul 14, 2002
6
0
0
US
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.
 
Replies continue below

Recommended for you

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