IsDocumentUsedByInMemoryAsmOrDrw

<< Click to Display Table of Contents >>

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

IsDocumentUsedByInMemoryAsmOrDrw

Description

Checks if the passed document file name is already a component of an assembly or of a drawing loaded in memory.

Syntax

call DBWShell("IsDocumentUsedByInMemoryAsmOrDrw DocFileName [getFullReferencingDocumentsList [onlyDrawings]]")

Parameters

DocFileName

the document file name

getFullReferencingDocumentsList

Optional.
0:(default) does not return the list of the referencing documents full path names
1: enables the return of the list of the referencing documents full path names

onlyDrawings

Optional.
1: processes only currently opened drawings

Results

@OK_USED

0: not used
1: used

@REFERENCING_DOCUMENT

list of referencing document
returned only if getFullReferencingDocumentsList=1

Example

Sub main()

 DBWinit(TRUE)
 file = "c:\temp\my sw documents\part1.sldprt"
 file = replace(file," ","|")
 call DBWShell ("IsDocumentUsedByInMemoryAsmOrDrw " & file)
 res = DBWResult("@OK_USED")
 if res=1 then
  DBWMsgBox "the referred document is used" & _
  "by another document (assembly or drawing) loaded in memory"
 else
  DBWMsgBox "the referred document is not used" & _
  "by any document loaded in memory"
 end if
End Sub

another example:

sub main()

 DBWInit(TRUE)
 documentToBeQueried = "E:\test\gene\burn\27527.SLDASM"
 DBWShell("IsDocumentUsedByInMemoryAsmOrDrw " & replace(documentToBeQueried," ","|") & " 1" )
 okUsed = DBWResult("@OK_USED")
 if okUsed then
  msgString = "okUsed=" & okUsed & vbcrlf
  Set fs = CreateObject("Scripting.FileSystemObject")
  Set tfolder = fs.GetSpecialFolder(TemporaryFolder)
  Set a = fs.OpenTextFile( tfolder & "\" & "dbwreslt.in", ForReading, True )
  Dim tokens
  Do While a.AtEndOfStream <> True
   line = a.ReadLine
   tokens = Split( line, "=", 2, 1)
   if tokens(0) = "@REFERENCING_DOCUMENT" then
   msgString = msgString + "Referencing document: " + tokens(1) + vbcrlf
   end if
  Loop
  a.Close
  DBWMsgBox msgString
 else
  DBWMsgBox "No other document is referencing the assign document"
 end if
end sub