DraftDataAPI.doc

(146 KB) Pobierz
User’s Guide to the DraftDataAPI

User’s Guide to the DraftDataAPI

 

 

Introduction

 

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.

 

 

Section 1:  API Definition

 

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



CDraftInfo::Open

 

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.

 



 

CDraftInfo::GetViewerVersionNumber

 

C++ Syntax

HRESULT GetViewerVersionNumber(long *ViewerVersionNumber)

 

Visual Basic Syntax

Long ViewerVersionNumber = GetViewerVersionNumber
 

Purpose

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.

 

Return

S_OK                                          Success.

E_INVALIDARG              ViewerVersionNumber is invalid.

E_FAIL                            A draft file has not yet been opened.

 

 


CDraftInfo::GetSheetCount

 

C++ Syntax

HRESULT GetSheetCount(long *SheetCount)

 

Visual Basic Syntax

Long SheetCount = GetSheetCount

 

Purpose

Returns the number of sheets in the draft document.

 

Parameters

SheetCount                            Placeholder for the return value of the function.

 

Return

S_OK                                          Success.

E_INVALIDARG              Var1 is NULL or otherwise corrupt.

E_FAIL                            User did not first open a draft document.

 



 

CDraftInfo::GetCurrentSheetIndex

 

C++ Syntax

HRESULT GetCurrentSheetIndex(long *SheetIndex)

 

Visual Basic Syntax

Long SheetIndex = GetCurrentSheetIndex

 

Purpose

Returns the current sheet index in the draft document.

 

Parameters

SheetIndex                            Placeholder for the return value of the function.

 

Return

S_OK                                          Success.

E_INVALIDARG              SheetIndex is NULL or otherwise corrupt.

E_FAIL                            User did not first open a draft document.

 

 

 


CDraftInfo::GetGeometricVersion

 

C++ Syntax

HRESULT GetGeometricVersion(long *GeometricVersion)

 

Visual Basic Syntax

Long GeometricVersion = GetGeometricVersion

 

Purpose

Returns the geometric version of the draft document.

 

Parameters

GeometricVersion              Placeholder for the return value of the function.

 

Return

S_OK                                          Success

E_INVALIDARG              GeometricVersion is NULL or otherwise corrupt.

E_FAIL                            User did not first open a draft document.

 

 



 

CDraftInfo::GetSheetName

 

Purpose

Returns the name of the sheet at the specified sheet index.   CDraftInfo::Open must be called before calling CDraftInfo::GetSheetName.

 

C++ Syntax

HRESULT GetSheetName(ULONG SheetIndex, BSTR *SheetName)

 

Visual Basic Syntax

Long SheetIndex =1

String SheetName = GetSheetName(SheetIndex)

 

Parameters

SheetIndex                            A 1-based index.

SheetName                            A pointer to a BSTR.

 

Return

S_OK                                          Success.

E_INVALIDARG              SheetIndex contains an invalid index number.

E_FAIL                            User did not first open a draft document.


CDraftInfo::GetUnitsUsed

 

C++ Syntax

HRESULT GetUnitsUsed(int *UnitsUsed)

 

Visual Basic Syntax

Integer UnitsUsed = GetUnitsUsed

 

Purpose

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

...
Zgłoś jeśli naruszono regulamin