User’s Guide to the DraftDataAPI
It is often useful to display CAD data using a light-weight viewing tool that allows access to part or assembly drawings for review or redlining. Each Solid Edge Draft file contains viewer information that is stored as a compressed metafile for each sheet in the draft file. This information is now accessible through an ATL-generated DLL that can be linked into Visual Basic or C/C++ programs. This document describes the API provided by the DLL and sample Visual Basic code.
The following draft file properties are available:
· Version information for the draft viewer library (not the draft file itself)
· Number of sheets in the draft document. For each sheet in the draft file, the sheet’s name and the sheet’s metafile data is also available.
· Current active sheet index.
· Geometric version.
· Units of measurement used.
The following functions provide access to this information:
DraftDataAPI User’s Manual page - 12
1. Open
2. GetViewerVersionNumber
3. GetSheetCount
4. GetCurrentSheetIndex
5. GetGeometricVersion
6. GetSheetName
7. GetUnitsUsed
8. GetUnitsDescription
9. SetMetafileName
10. GetEnhMetafile
C++ Syntax
HRESULT Open(BSTR *Filename)
Visual Basic Syntax
String Filename = “somename.dft”
Open(Filename)
Purpose
Opens the specified draft file and ensures that it contains draft viewer information.
Return
S_OK Success.
E_OUTOFMEMORY Cannot allocate the necessary memory for the operation.
E_INVALIDARG Filename is NULL.
E_FAIL General Failure.
HRESULT GetViewerVersionNumber(long *ViewerVersionNumber)
Long ViewerVersionNumber = GetViewerVersionNumber
Returns the version number of the CDraftViewerInfo library, not the version of the draft file.
Parameters
ViewerVersionNumber Pointer to placeholder for the CDraftViewerInfo version
Number.
E_INVALIDARG ViewerVersionNumber is invalid.
E_FAIL A draft file has not yet been opened.
HRESULT GetSheetCount(long *SheetCount)
Long SheetCount = GetSheetCount
Returns the number of sheets in the draft document.
SheetCount Placeholder for the return value of the function.
E_INVALIDARG Var1 is NULL or otherwise corrupt.
E_FAIL User did not first open a draft document.
HRESULT GetCurrentSheetIndex(long *SheetIndex)
Long SheetIndex = GetCurrentSheetIndex
Returns the current sheet index in the draft document.
SheetIndex Placeholder for the return value of the function.
E_INVALIDARG SheetIndex is NULL or otherwise corrupt.
HRESULT GetGeometricVersion(long *GeometricVersion)
Long GeometricVersion = GetGeometricVersion
Returns the geometric version of the draft document.
GeometricVersion Placeholder for the return value of the function.
S_OK Success
E_INVALIDARG GeometricVersion is NULL or otherwise corrupt.
CDraftInfo::GetSheetName
Returns the name of the sheet at the specified sheet index. CDraftInfo::Open must be called before calling CDraftInfo::GetSheetName.
HRESULT GetSheetName(ULONG SheetIndex, BSTR *SheetName)
Long SheetIndex =1
String SheetName = GetSheetName(SheetIndex)
SheetIndex A 1-based index.
SheetName A pointer to a BSTR.
E_INVALIDARG SheetIndex contains an invalid index number.
HRESULT GetUnitsUsed(int *UnitsUsed)
Integer UnitsUsed = GetUnitsUsed
Returns the units used in the draft document. The returned values are mapped as follows:
Defined Type Name
Value
Description
IDS_DISTANCE_METER
59
Meters
IDS_DISTANCE_NANOMETER
60
Nanometers
IDS_DISTANCE_MILLIMETER
61
Millimeters
IDS_DISTANCE_CENTIMETER
62
Centimeters
IDS_DISTANCE_KILOMETER
63
Kilometers
IDS_DISTANCE_INCH
64
Inches
IDS_DISTANCE_FOOT
65
Feet
IDS_DISTANCE_YARD
66
Yards
IDS_DISTANCE_MILE
67
Miles
IDS_DISTANCE_TENTH
68
Tenths
IDS_DISTANCE_HUNDREDTH
koper_Upload