AddAttachment

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Commands Reference > Document >

AddAttachment

Description

Adds an attachment to the currently selected document or to the passed unique_id

Syntax

call DBWShell("AddAttachment AttachmentPath [UniqueID [updateAttachmentGrid]]")

Parameters

AttachmentPath

The full file path of the attachment to add

UniqueID

Optional. It is the unique_id of the parent document

updateAttachmentGrid

Optional. if 1 it will activate/refresh automatically the Attachments grid within the Tree page for the specific record's UniqueID

Results

@OK_ATTACHED


Remarks

According with Mechworks concept of attachments, no record will be inserted in the DOCUMENT table for the created relationship.

For updateAttachmentGrid parameter, the PDM browser must be opened and the Tree page must be activated.

See also

File attachments (Main help)
AddAttachment
AddComponent
AddDocument
AddToParent

Examples

'select the parent document making it the current one

call DBWShell("SelectById my|project 0")
'retrieve info about the current document
call DBWShell("CurrentDocument")
ParentUniqueId = DBWResult("@DOCUMENT_UNIQUE_ID")
call DBWShell ("AddAttachment c:\temp\mypart.sldprt " & ParentUniqueId)
res = DBWResult("@DOCUMENT_UNIQUE_ID")
DBWMsgBox "New document has been added with UID " & res

DBWShell("AddAttachment C:\MyAssemblies\MyAsm.sldasm 123456")

The following example (registerWithStdAlone.vbs) shows how to register an assembly structure by using the DBWorks Standalone server:

Set DBWApp = CreateObject("DBWAlone.Api")

okDBW = DBWApp.CallBack("@StartApplication")   'support for DBWArm/Login dialog
asmName = replace("C:\MyAssemblies\MyAsm.SLDASM"," ","|")  'the assembly is known to the script
parentUid = 123456      'the parentUid is known to the script
traverseChildComponents = 1
okDBW = DBWApp.CallBack("AddAttachment " & asmName & " " & parentUid)

here below is an example of the updateAttachmentGrid parameter

call DBWShell( "CurrentDocument" )

docUId = DBWResult( "@DOCUMENT_UNIQUE_ID" )
file = "c:\temp\myAttachment.txt"
call DBWShell ("AddAttachment " & file & " " & docUId & " 1")