GetDWGInfo Method
Description
Gets basic information about the named DWG file in the specified object. The basic information includes the file format, current layout, all layout names and reference information. Reference information does not include nested references. The data is returned as a DrawingInfo object which contains properties providing access to the information.
A log file is generated if a LogIdentifier is provided, no log file is created if the LogIdentifier is Nothing. Please see Log Files for more information.
An error is raised if:
- their is no valid DWG Processor license
- the object does not contain a DWG file
- the method fails for another reason
Consult the generated log file for detailed error information.
Syntax
Function GetDWGInfo(Vault As Vault, DrawingObjVer As ObjVer, DrawingName As String, LogIdentifier As Object) As DrawingInfo
Parameters
Name |
Data Type |
Description |
Vault |
The Vault object provided by the event handler. |
|
DrawingObjVer |
ObjVer of object containing a DWG file to process. This could be provided by the event handler or created dynamically using CreateObject("MFilesAPI.ObjVer"). |
|
DrawingName |
String |
The name of the DWG file to process (excluding the file extension). Use with Multi File Document (MFD) objects containing more than one DWG file. |
LogIdentifier |
String or TypedValue |
Used to determine the filename of the log file. To create a log file for the current activity pass in the provided ActivityID. If this parameter is Nothing, then no log file is generated. |
Return
Returns a DrawingInfo object or throws an exception.
Example
'create ExcitechDOCS DWG Processor object
Set dwgProcessor = GetExtensionObject("ExcitechDOCS.DWGProcessor")
'ignore errors
On Error Resume Next
'try to get drawing information
Dim dwgInfo : Set dwgInfo = dwgProcessor.GetDWGInfo(Vault, ObjVer, "A Drawing Name", ActivityID)
'reinstate errors
On Error Goto 0
'on failure dwgInfo will be empty
If Not IsEmpty(dwgInfo) Then
'write file format and current layout to log file
dwgProcessor.WriteLog ActivityID, "File Format: " + dwgInfo.DWGFileFormat
dwgProcessor.WriteLog ActivityID, "Current Layout: " + dwgInfo.CurrentLayout
'write all layout names to log file
For Each Layout In dwgInfo.Layouts
dwgProcessor.WriteLog ActivityID, "Layout: " + Layout
Next
'write the boolean HasXrefs flag to log file
dwgProcessor.WriteLog ActivityID, "Has Xrefs: " + CStr(dwgInfo.HasXrefs)
'write all references to log file
Dim xref
For Each xref In dwgInfo.References
dwgProcessor.WriteLog ActivityID, "Reference Name : " + xref.Name + ", Path: " + xref.Path + ", Type: " + xref.Type
Next
Else
'write to log
dwgProcessor.WriteLog ActivityID, "An Error has occurred."
End If
The resulting log file would contain the following information:
01/01/2019 09:00:00:3477 - Get Drawing Information
01/01/2019 09:00:00:3607 - DWG File Count: 1
01/01/2019 09:00:00:3637 - Creating RealDWG COM Object. (dllhost.exe)
01/01/2019 09:00:00:8807 - Call GetDrawingInformation COM method.
01/01/2019 09:00:00:9012 - Processing Object: ID 495 Version 33
01/01/2019 09:00:00:9176 - DrawingName: A Drawing Name
01/01/2019 09:00:00:9267 - FileVer: ID 2 Version 2
01/01/2019 09:00:00:9307 - Download DWG to temp file: C:\ProgramData\Excitech Docs\DWG Processor\Temp\4rqb1hvd.dwg
01/01/2019 09:00:00:9547 - Open DWG file
01/01/2019 09:00:01:0587 - Create DrawingInfo object
01/01/2019 09:00:01:0597 - Populate file format
01/01/2019 09:00:01:0607 - Populate current layout: A1
01/01/2019 09:00:01:0617 - Populate Layout array
01/01/2019 09:00:01:0807 - Populate DWG References
01/01/2019 09:00:01:0867 - Populate Image References
01/01/2019 09:00:01:0907 - Populate PDF References
01/01/2019 09:00:01:0997 - Delete temp files from server
01/01/2019 09:00:01:2747 - Deserialize drawing information from JSON.
01/01/2019 09:00:01:2987 - Releasing COM object.
01/01/2019 09:00:01:3007 - File Format: AC1032
01/01/2019 09:00:01:3017 - Current Layout: A1
01/01/2019 09:00:01:3037 - Layout: A1
01/01/2019 09:00:01:3037 - Layout: Model
01/01/2019 09:00:01:3047 - Has Xrefs: False