se facet

50
User’s Guide to the SEFacet API 1.1.1 Introduction For translation and other purposes, it is useful to be able to get facet data from a part or weldment file using a light-weight reader tool. Each Solid Edge Part, Sheet Metal, and Weldment file contains facet information that describes the part’s geometry. This information is now accessible through an ATL-generated DLL that can be linked into Visual Basic or C/C++ programs. SEFacet can also read face style information from Part, Sheet Metal, and Weldment files, through a StyleLibrary API. This document describes the APIs provided by the DLL and sample Visual Basic code. 1.1.2 Section 1: FacetReader API Definition The following facet properties are available: Number of bodies in the part or weldment document Number of faces in a given body. Number of strips in a given body and face. Number of vertices in a given body, face, and strip. Vertex information, in either array form, or vertex-by- vertex Face Style IDs for faces and entire bodies The following functions provide access to this information: 1. Open 2. Close 3. get_BodyCount 4. get_BodyFaceCount 5. get_BodyFaceStripCount 6. get_BodyFaceStripVertCount 7. GetBodyFaceStrip SEFacet User’s Manual page - 1

Upload: fagner-brilhante

Post on 12-Jan-2016

22 views

Category:

Documents


4 download

DESCRIPTION

solid

TRANSCRIPT

Page 1: Se Facet

User’s Guide to the SEFacet API

1.1.1 Introduction

For translation and other purposes, it is useful to be able to get facet data from a part or weldment file using a light-weight reader tool. Each Solid Edge Part, Sheet Metal, and Weldment file contains facet information that describes the part’s geometry. This information is now accessible through an ATL-generated DLL that can be linked into Visual Basic or C/C++ programs. SEFacet can also read face style information from Part, Sheet Metal, and Weldment files, through a StyleLibrary API. This document describes the APIs provided by the DLL and sample Visual Basic code.

1.1.2 Section 1: FacetReader API Definition

The following facet properties are available: Number of bodies in the part or weldment document Number of faces in a given body. Number of strips in a given body and face. Number of vertices in a given body, face, and strip. Vertex information, in either array form, or vertex-by-vertex Face Style IDs for faces and entire bodies

The following functions provide access to this information:

1. Open2. Close3. get_BodyCount4. get_BodyFaceCount5. get_BodyFaceStripCount6. get_BodyFaceStripVertCount7. GetBodyFaceStrip8. GetBodyFaceStripVertex9. get_BodyStyle10. get_BodyConstructionStyle11. get_BodyFaceStyle

SEFacet User’s Manual page - 1

Page 2: Se Facet

1.1.2.1 CFacetReader::Open

C++ SyntaxHRESULT Open(BSTR Filename)

Visual Basic SyntaxString Filename = “somename.par”Open(Filename)

PurposeOpens the specified part or weldment file and ensures that it contains facet information. It can read either a *.par or a *.pwd file.

ReturnS_OK Success.E_INVALIDARG Filename is NULL.E_FAIL General Failure.

1.1.2.2 CFacetReader::Close

C++ SyntaxHRESULT Close()

Visual Basic SyntaxCall Close

PurposeCloses the part or weldment file.

ReturnS_OK Success.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 2

Page 3: Se Facet

1.1.2.3 CFacetReader::get_BodyCount

C++ SyntaxHRESULT get_BodyCount(long *pVal)

Visual Basic SyntaxLong BodyNum = BodyCount

PurposeReturns the number of bodies in the part or weldment document. ParameterspVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_FAIL User did not first open a part document.

1.1.2.4 CFacetReader:: get_BodyFaceCount

C++ SyntaxHRESULT get_BodyFaceCount(long nBody, long *pVal)

Visual Basic SyntaxDim BodyID as LongLong FaceCount = BodyFaceCount(BodyID)

PurposeReturns the number of faces in the body with index nBody. ParametersBodyID Index of the body where the face can be foundPVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 3

Page 4: Se Facet

1.1.2.5 CFacetReader:: get_BodyFaceStripCount

C++ SyntaxHRESULT get_BodyFaceStripCount(long nBody, long nFace, long *pVal)

Visual Basic SyntaxDim BodyID as LongDim FaceID as LongLong StripCount = BodyFaceStripCount(BodyID, FaceID)

PurposeReturns the number of strips in the face with index nFace, in the body with index nBody. ParametersBodyID Index of the body where the strip can be foundFaceID Index of the face where the strip can be foundPVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID, or nFace is not a valid face ID.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 4

Page 5: Se Facet

1.1.2.6 CFacetReader:: get_BodyFaceStripVertCount

C++ SyntaxHRESULT get_BodyFaceStripVertCount(long nBody, long nFace, long nStrip, long

*pVal)

Visual Basic SyntaxDim BodyID as LongDim FaceID as LongDim StripID as LongLong VertCount = BodyFaceStripVertCount (BodyID, FaceID, StripID)

PurposeReturns the number of vertices in the strip with index nStrip, in the face with index nFace, in the body with index nBody. ParametersBodyID Index of the body where the strip can be foundFaceID Index of the face where the strip can be foundStripID Index of the strip which the user wants a vertex count fromPVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID, nFace is not a valid face ID,

or nStrip is not a valid strip ID.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 5

Page 6: Se Facet

1.1.2.7 CFacetReader:: GetBodyFaceStrip

C++ SyntaxHRESULT GetBodyFaceStrip(long nBody, long nFace, long nStrip, long *nVerts,

SAFEARRAY **ppVerts, VARIANT *ppNorms, VARIANT *ppParams)

Visual Basic SyntaxGetBodyFaceStripVertex is easier to use in VB, but this code will work with GetBodyFaceStrip:

Dim VertCount as LongDim VertCount2 as LongDim BodyID as LongDim FaceID as LongDim StripID as LongDim Verts() as DoubleDim Norms() as DoubleDim Params() as DoubleVertCount = BodyFaceStripVertCount(BodyID, FaceID, StripID)

ReDim Verts(3 * VertCount) as DoubleReDim Norms(3 * VertCount) as DoubleReDim Params(2 * VertCount) as DoubleCall GetBodyFaceStrip (BodyID, FaceID, StripID, VertCount2, Verts, Norms, Params)

PurposeReturns the number of vertices in the strip, as well as arrays containing the vertex locations, normals, and texture (uv) coordinates. ParametersBodyID Index of the body where the strip can be foundFaceID Index of the face containing the strip the user wants vertex

information fromStripID Index of the strip the user wants vertex information fromnVerts Number of verts returned for this strip.ppVerts Array containing vertex locations. The array has 3 x nVerts

elements, in x, y, z, x, y, z order.ppNorms Array containing vertex normals. The array has 3 x nVerts

elements, in x, y, z, x, y, z order.ppParams Array containing vertex uv coordinates. The array has

2 x nVerts elements, in u, v, u, v order.

ReturnS_OK Success.E_INVALIDARG nBody is not a valid body ID, nFace is not a valid face

SEFacet User’s Manual page - 6

Page 7: Se Facet

ID, nStrip is not a valid strip ID, or ppNorms or ppParamspoint to invalid Variant arrays.

E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 7

Page 8: Se Facet

1.1.2.8 CFacetReader:: GetBodyFaceStripVertex

C++ SyntaxHRESULT GetBodyFaceStripVertex(long nBody, long nFace, long nStrip, long nVert,

double *dVertX, double *dVertY, double *dVertZ, double *dNormX, double *dNormY, double *dNormZ, double *dTexU, double *dTexV)

Visual Basic SyntaxDim BodyID as LongDim FaceID as LongDim StripID as LongDim VertID as LongDim VertX as DoubleDim VertY as DoubleDim VertZ as DoubleDim NormX as DoubleDim NormY as DoubleDim NormZ as DoubleDim TexU as DoubleDim TexV as DoubleCall GetBodyFaceStripVertex (BodyID, FaceID, StripID, VertID, VertX, VertY, VertZ,

NormX, NormY, NormZ, TexU, TexV)

PurposeReturns the location, normal, and texture coordinate of the desired vertex. If the pointers to the normal return values are NULL, SEFacet will assume you don’t want normal information. If the pointers to the texture coordinate return values are NULL, SEFacet will assume you don’t want texture information. ParametersBodyID Index of the body where the strip can be foundFaceID Index of the face containing the strip the user wants vertex

information fromStripID Index of the strip containing the desired vertexVertID Index of the desired vertex.VertX X coordinate of the vertex’s location.VertY Y coordinate of the vertex’s location.VertZ Z coordinate of the vertex’s location.NormX X coordinate of the vertex’s normal.NormY Y coordinate of the vertex’s normal.NormZ Z coordinate of the vertex’s normal.TexU U coordinate of the vertex’s texture coordinate.TexV V coordinate of the vertex’s texture coordinate.

SEFacet User’s Manual page - 8

Page 9: Se Facet

ReturnS_OK Success.E_POINTER One or more of the required return pointers (dVertX, dVertY, or

dVertZ) is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID, nFace is not a valid face ID, nStrip is

not a valid strip ID, or nVert is not a valid vertex ID. Also returnedif one or two of the normal return variables are null, or if one of

thetwo texture coordinate return variables is NULL.

E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 9

Page 10: Se Facet

1.1.2.9 CFacetReader:: get_BodyStyle

C++ SyntaxHRESULT get_BodyStyle(long nBody, long *pVal)

Visual Basic SyntaxDim BodyID as LongLong StyleID = BodyStyle(BodyID)

PurposeReturns the style ID assigned to the body with index nBody. ParametersBodyID Index of the body where the style ID can be foundPVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 10

Page 11: Se Facet

1.1.2.10 CFacetReader:: get_BodyConstructionStyle

C++ SyntaxHRESULT get_BodyConstructionStyle (long nBody, long *pVal)

Visual Basic SyntaxDim BodyID as LongLong StyleID = BodyConstructionStyle (BodyID)

PurposeReturns the construction style ID assigned to the body with index nBody. ParametersBodyID Index of the body where the style ID can be foundpVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 11

Page 12: Se Facet

1.1.2.11 CFacetReader:: get_BodyFaceStyle

C++ SyntaxHRESULT get_BodyFaceStyle(long nBody, long nFace, long *pVal)

Visual Basic SyntaxDim BodyID as LongDim FaceID as LongLong StyleID = BodyFaceStyle(BodyID, FaceID)

PurposeReturns the style ID of the face with index nFace, in the body with index nBody. A style ID of 0 means that there is no style applied to the face. ParametersBodyID Index of the body where the face can be foundFaceID Index of the facePVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_INVALIDARG nBody is not a valid body ID, or nFace is not a valid face ID.E_FAIL User did not first open a part document.

SEFacet User’s Manual page - 12

Page 13: Se Facet

1.1.3 Section 1: StyleLibrary API Definition

The following face style properties are available: Whether or not the style ID is valid. Style type (face style or view style). Style name. Style’s short description string. Surface color settings (diffuse, specular, ambient, and emission colors, shininess,

and alpha). Extended surface information. Wireframe settings. Texture map and bump map settings. Environment box settings.

The following functions provide access to this information:

1. Open2. Close3. get_StyleExists4. get_StyleType5. get_StyleName6. get_StyleDescription7. StyleSurface8. StyleSurfaceEx9. StyleTexture10. StyleBumpmap11. StyleWireframe12. get_StyleSkyboxType13. get_StyleSkyboxSideCount14. get_StyleSkyboxSideFilename15. StyleSkyboxOrientation

The primary use for this API is to get color/style information for each body/face as the FacetReader reads through SE documents. So, the user gets style IDs from FacetReader’s get_BodyStyle, get_BodyConstructionStyle, and get_BodyFaceStyle members, then uses those style IDs to retrieve style info from the StyleLibrary API. Note that only SE documents saved by v10 or later of Solid Edge will have style information.

SEFacet User’s Manual page - 13

Page 14: Se Facet

1.1.3.1 CStyleLibrary::Open

C++ SyntaxHRESULT Open(BSTR Filename)

Visual Basic SyntaxString Filename = “somename.par”Open(Filename)

PurposeOpens the style library in the specified part or weldment file. It can read either a *.par or a *.pwd file.

ReturnS_OK Success.E_INVALIDARG Filename is empty or NULL.E_FAIL General Failure.

1.1.3.2 CStyleLibrary::Close

C++ SyntaxHRESULT Close()

Visual Basic SyntaxCall Close

PurposeCloses the style library of the part or weldment file.

ReturnS_OK Success.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 14

Page 15: Se Facet

1.1.3.3 CStyleLibrary:: get_StyleExists

C++ SyntaxHRESULT get_StyleExists(ULONG ID, VARIANT_BOOL *pVal)

Visual Basic SyntaxDim StyleID As LongBoolean BodyNum = StyleExists(StyleID)

PurposeReturns True (VARIANT_TRUE in C++) if the style ID corresponds to a valid face style in the library. ParametersID Index of the stylepVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 15

Page 16: Se Facet

1.1.3.4 CStyleLibrary:: get_StyleType

C++ SyntaxHRESULT get_StyleType(ULONG ID, short *pVal)

Visual Basic SyntaxDim StyleID as LongInteger StyleTypeNumber = StyleType(StyleID)

PurposeReturns 1 if the style corresponding to ID points to a face style, and returns 2 if the style is a view style. ParametersID Index of the stylepVal Placeholder for the return value of the function.

ReturnS_OK Success.E_POINTER pVal is NULL or otherwise corrupt.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 16

Page 17: Se Facet

1.1.3.5 CStyleLibrary:: get_StyleName

C++ SyntaxHRESULT get_StyleName (ULONG ID, BSTR *pVal)

Visual Basic SyntaxDim StyleID as LongString Name = StyleName(StyleID)

PurposeGets the name of the style corresponding to ID.

ReturnS_OK Success.E_INVALIDARG pVal is NULL.E_FAIL User did not first open a style library.

1.1.3.6 CStyleLibrary:: get_StyleDescription

C++ SyntaxHRESULT get_StyleDescription (ULONG ID, BSTR *pVal)

Visual Basic SyntaxDim StyleID as LongString Desc = StyleDescription(StyleID)

PurposeGets a short string describing the style corresponding to ID.

ReturnS_OK Success.E_INVALIDARG pVal is NULL.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 17

Page 18: Se Facet

1.1.3.7 CStyleLibrary:: StyleSurface

C++ SyntaxHRESULT StyleSurface (ULONG ID, long *Diffuse, long *Specular, long *Ambient,

long *Emission, float *Shininess, float *Alpha)

Visual Basic SyntaxDim StyleID as LongDim Diffuse as LongDim Specular as LongDim Ambient as LongDim Emission as LongDim Shininess as DoubleDim Alpha as DoubleCall StyleSurface (StyleID, Diffuse, Specular, Ambient, Emission, Shininess, Alpha)

PurposeReturns the color, shininess, and opacity information of the face style corresponding to the given style index. If the pointer to one of the return values is NULL, SEFacet will assume the user doesn’t want that information. ParametersID Index of the face style with the desired surface information.Diffuse The surface’s Diffuse color. C++ users can type-cast it to

COLORREF.Specular Color of the surface’s specular highlights. C++ users can

type-cast it to COLORREF.Ambient The surface’s ambient color. C++ users can type-cast it to

COLORREF.Emission The surface’s emitted color. C++ users can type-cast it to

COLORREF.Shininess Shininess of the surface. Ranges from no shininess (0) to

completely shiny (1).Alpha Surface’s opacity, ranging from completely transparent (0)

to completely opaque (1).

ReturnS_OK Success.E_INVALIDARG All of the return pointers are NULL or otherwise corrupt, so there’s

no information to return.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 18

Page 19: Se Facet

1.1.3.8 CStyleLibrary:: StyleSurfaceEx

C++ SyntaxHRESULT StyleSurfaceEx (ULONG ID, float *Reflectivity, float *Refraction, int

*Shadows)

Visual Basic SyntaxDim StyleID as LongDim Reflectivity as DoubleDim Refraction as DoubleDim Shadows as IntegerCall StyleSurface (StyleID, Reflectivity, Refraction, Shadows)

PurposeReturns the extended surface information of the face style corresponding to the given style index, including shadow settings, and optical properties like reflectivity and refraction. This information is in a separate function from StyleSurface, because extended surface settings are not enabled by default in the Solid Edge rendering engine. If the pointer to one of the return values is NULL, SEFacet will assume the user doesn’t want that information. ParametersID Index of the face style with the desired surface information.Reflectivity The amount of light the surface reflects. Ranges from no reflection

(0) to perfect mirror-like reflection (1).Refraction Equivalent to the index of refraction from optics. Refraction only

makes sense for surfaces with a certain amount of transparency.Ranges from no refraction (0) to full refraction (1).

Shadows Surface’s shadow settings. Values can be 0 (neither casts noraccepts shadows), 1 (only casts shadows), 2 (only acceptsshadows), or 3 (both casts and accepts shadows).

ReturnS_OK Success.E_INVALIDARG All of the return pointers are NULL or otherwise corrupt, so there’s

no information to return.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 19

Page 20: Se Facet

1.1.3.9 CStyleLibrary:: StyleTexture

C++ SyntaxHRESULT StyleTexture (ULONG ID, BSTR *Filename, int *Units, float *Rotation,

float *ScaleX, float *ScaleY, float *OffsetX, float *OffsetY, float *Weight, int *Mirror, VARIANT_BOOL *TransBG, long *TransColor)

Visual Basic SyntaxDim StyleID as LongDim TextureFile As StringDim Units as IntegerDim Rotation as DoubleDim ScaleX as DoubleDim ScaleY as DoubleDim OffsetX as DoubleDim OffsetY as DoubleDim Weight as DoubleDim Mirror as IntegerDim TransBG as BooleanDim TransColor as LongCall StyleTexture (StyleID, TextureFile, Units, Rotation, ScaleX, ScaleY, OffsetX,

OffsetY, Weight, Mirror, TransBG, TransColor)

PurposeReturns texture map information from the face style corresponding to the given style index. If the pointer to one of the return values is NULL, SEFacet will assume the user doesn’t want that information. ParametersID Index of the face style with the desired surface information.Filename The name of the file containing the texture map image.Units Specifies whether the scale values are in surface (0) or world (1)

coordinates. Surface scale is relative to the face’s texture coordinates, and world scale is relative to 3D space.

Rotation Rotation angle of the texture map relative to the UV texturecoordinates, in degrees. Ranges from 0° to 360°.

ScaleX Scales the texture map in the x direction, using either surface orworld scale units.

ScaleY Scales the texture map in the y direction.OffsetX Offsets the texture map in the x direction, relative to UV texture

coordinates.OffsetY Offsets the texture map in the y direction.Weight Determines how much the texture affects the surface color. Ranges

from 0, where the texture map can’t even be seen, to 1, wheresurface appearance comes entirely from the texture map.

SEFacet User’s Manual page - 20

Page 21: Se Facet

Mirror Flips the texture map. Values can be 0 (not mirrored around eitherx or y axis), 1 (mirrored only about x axis), 2 (mirrored only abouty axis), or 3 (mirrored about both x and y axes).

TransBG True if the texture has a transparent color defined. When atransparent color is defined, the texture map will be transparent ateach pixel that has that color.

TransColor The color that will be transparent in the texture map. C++ users can

type-cast it to COLORREF.

ReturnS_OK Success.E_POINTER All of the return pointers are NULL or otherwise corrupt, so there’s

no information to return.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 21

Page 22: Se Facet

1.1.3.10 CStyleLibrary:: StyleBumpmap

C++ SyntaxHRESULT StyleBumpmap (ULONG ID, BSTR *Filename, int *Units, float *Rotation,

float *ScaleX, float *ScaleY, float *OffsetX, float *OffsetY, float *Height, int *Mirror)

Visual Basic SyntaxDim StyleID as LongDim TextureFile As StringDim Units as IntegerDim Rotation as DoubleDim ScaleX as DoubleDim ScaleY as DoubleDim OffsetX as DoubleDim OffsetY as DoubleDim Weight as DoubleDim Mirror as IntegerCall StyleBumpmap (StyleID, TextureFile, Units, Rotation, ScaleX, ScaleY, OffsetX,

OffsetY, Weight, Mirror)

PurposeReturns bump map information from the face style corresponding to the given style index. If the pointer to one of the return values is NULL, SEFacet will assume the user doesn’t want that information. ParametersID Index of the face style with the desired surface information.Filename The name of the file containing the bump map image.Units Specifies whether the scale values are in surface (0) or world (1)

coordinates. Surface scale is relative to the face’s texture coordinates, and world scale is relative to 3D space.

Rotation Rotation angle of the bump map relative to the UV texturecoordinates, in degrees. Ranges from 0° to 360°.

ScaleX Scales the bump map in the x direction, using either surface orworld scale units.

ScaleY Scales the bump map in the y direction.OffsetX Offsets the bump map in the x direction, relative to UV texture

coordinates.OffsetY Offsets the bump map in the y direction.Height Determines how bumpy the bump map will be. At 0 height, the

bump map has no effect. There is no upper limit, but height looksbest below about 5.

Mirror Flips the bump map. Values can be 0 (not mirrored around eitherx or y axis), 1 (mirrored only about x axis), 2 (mirrored only about

SEFacet User’s Manual page - 22

Page 23: Se Facet

y axis), or 3 (mirrored about both x and y axes).

ReturnS_OK Success.E_POINTER All of the return pointers are NULL or otherwise corrupt, so there’s

no information to return.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 23

Page 24: Se Facet

1.1.3.11 CStyleLibrary:: StyleWireframe

C++ SyntaxHRESULT StyleWireframe (ULONG ID, long *Color, float *Width, long

*StipplePattern, long *StippleScale)

Visual Basic SyntaxDim StyleID as LongDim WireColor as LongDim Width as DoubleDim StipplePattern as LongDim StippleScale as LongCall StyleWireframe (StyleID, WireColor, Width, StipplePattern, StippleScale)

PurposeReturns information about wireframe display, for the face style corresponding to the given style index. If the pointer to one of the return values is NULL, SEFacet will assume the user doesn’t want that information. ParametersID Index of the face style with the desired surface information.Color The color of the object’s outlines. C++ users can type-cast it to

COLORREF.Width Width of the outlines, in pixels.StipplePattern Its bits encode the Wireframe dashed lines’ pattern.StippleScale Defines the length of the dash pattern specified in StipplePattern.

The default value is 1.

ReturnS_OK Success.E_INVALIDARG All of the return pointers are NULL or otherwise corrupt, so there’s

no information to return.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 24

Page 25: Se Facet

1.1.3.12 CStyleLibrary:: get_StyleSkyboxType

C++ SyntaxHRESULT get_StyleSkyboxType (ULONG ID, short *pVal)

Visual Basic SyntaxDim StyleID as LongInteger SkyboxType = StyleSkyboxType(StyleID)

PurposeGets the type of skybox in the face style corresponding to ID. The skybox type is 0 if there is no skybox. There are three types of skyboxes: sphere map (1), single image (2), and environment box (3).

ReturnS_OK Success.E_POINTER pVal is NULL.E_FAIL User did not first open a style library.

1.1.3.13 CStyleLibrary:: get_StyleSkyboxSideCount

C++ SyntaxHRESULT get_StyleSkyboxSideCount (ULONG ID, short *pVal)

Visual Basic SyntaxDim StyleID as LongInteger SkyboxSide = StyleSkyboxSideCount(StyleID)

PurposeGets the number of skybox sides in the face style corresponding to ID. A “side” is an image file used to form the skybox. A sphere map or single image skybox only has one side. An environment box skybox is a cube formed from six images, so it has 6 sides.

ReturnS_OK Success.E_ POINTER pVal is NULL.E_FAIL User did not first open a style library.

1.1.3.14 CStyleLibrary:: get_StyleSkyboxSideFilename

SEFacet User’s Manual page - 25

Page 26: Se Facet

C++ SyntaxHRESULT get_StyleSkyboxSideFilename (ULONG ID , int Side, BSTR *pVal)

Visual Basic SyntaxDim StyleID as LongDim SkyboxSide as IntegerString SkyboxSideName = StyleSkyboxSideFilename (StyleID, SkyboxSide)

PurposeGets the image file name of one side of the skybox in the style corresponding to ID.

ParametersID Index of the face style with the desired surface information.Side The index of the desired side. Side must be in the range of 1

through 6 for environment box skyboxes, and it must be 1 forsphere map and single image skyboxes.

ReturnS_OK Success.E_INVALIDARG Side is not valid.E_POINTER pVal is NULL.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 26

Page 27: Se Facet

1.1.3.15 CStyleLibrary:: StyleSkyboxOrientation

C++ SyntaxHRESULT StyleSkyboxOrientation (ULONG ID, float *Azimuth, float *Altitude, float

*Roll, float *FieldOfView)

Visual Basic SyntaxDim StyleID as LongDim Azimuth as DoubleDim Altitude as DoubleDim Roll as DoubleDim FieldOfView as DoubleCall StyleSkyboxOrientation (StyleID, Azimuth, Altitude, Roll, FieldOfView)

PurposeReturns orientation information about a skybox, for the face style corresponding to the given style index. If the pointer to one of the return values is NULL, SEFacet will assume the user doesn’t want that information. Only environment box skyboxes can be oriented, so this method isn’t helpful for the other two kinds of skyboxes. ParametersID Index of the face style with the desired surface information.Azimuth Horizontal aim angle of the skybox, in degrees. Also known as

yaw in an aircraft. Ranges from 0° to 360°.Altitude Vertical aim angle of the skybox, in degrees. Also known as pitch

in an aircraft. Ranges from -90° to 90°.Roll The roll is how far your skybox view has rotated away from the

horizon. Ranges from 0° to 360°.FieldOfView The cone angle is like a camera's field of view angle. Small values

zoom to a tight focus on a small area of the skybox, and largevalues show a wide area of the skybox. Ranges from maximumzoom-in (0°) to maximum wide-angle lens zoom-out (180°).

ReturnS_OK Success.E_POINTER All of the return pointers are NULL or otherwise corrupt, so there’s

no information to return.E_FAIL User did not first open a style library.

SEFacet User’s Manual page - 27

Page 28: Se Facet

1.1.4 Section 2 : Visual Basic Examples

SEFacet enables the user to access facet information from Solid Edge part and weldment files. To use SEFacet, first register the SEFacet.dll. Follow these steps:

1. Copy SEFacet.dll to your system.2. Register SEFacet.dll by running the following command in the command prompt

(DOS window):regsvr32 /s <drive>:/<directory name>/SEFacet.dll

1.1.4.1 No Style Information

To use the DLL in a Visual Basic environment, follow these steps:

1. Create a new project and add a form to it. Label the form as Form1. 2. Change the caption to “SEFacet Reader.” 3. Add controls to the form as follows:

1. A ListBox named List12. A Button named Command1, with caption

“Read”

3. A FileListBox named AvailFiles4. A DirListBox named Dir15. A DriveListBox named Drive1

SEFacet User’s Manual page - 28

Page 29: Se Facet

Double-click the Command1 control (#2 in the image), and add the following code:

Private Sub Command1_Click()Dim doc As ObjectDim Output As StringDim filename As StringDim currentDrive As StringDim i As LongDim j As LongDim k As LongDim m As Long

Dim BodyCount As LongDim FaceCount As LongDim StripCount As LongDim VertCount As LongDim VertX As DoubleDim VertY As DoubleDim VertZ As DoubleDim NormX As DoubleDim NormY As DoubleDim NormZ As DoubleDim TexU As DoubleDim TexV As Double

Dim VertStr As StringDim NormStr As StringDim TexStr As StringDim temp1 As StringDim temp2 As StringDim temp3 As String

' Get the current path for the selected filecurrentDrive = Drive1.Drive + "\"currentDrive = StrConv(currentDrive, vbUpperCase)

' If the Dir1.Path is anything but the root directory, append a backslash' before appending the draft filename.

If (Dir1.Path <> currentDrive) Thenfilename = Dir1.Path + "\" + AvailFiles.filenameElse filename = Dir1.Path + AvailFiles.filenameEnd If

' Set up error handlingOn Error GoTo FileError

' Make sure we have a valid filenameIf (AvailFiles.filename <> "") Then ' set up the object and open the draft file Set doc = CreateObject("SEFacet.FacetReader") Call doc.Open(filename)

BodyCount = doc.BodyCount

List1.AddItem (CStr(BodyCount) + " bodies in '" + filename + "'")

For i = 1 To BodyCount FaceCount = doc.BodyFaceCount(i) Output = " FaceCount(" + CStr(i) + ") = " + CStr(FaceCount) List1.AddItem (Output)

SEFacet User’s Manual page - 29

Page 30: Se Facet

For j = 1 To FaceCount StripCount = doc.BodyFaceStripCount(i, j) Output = " StripCount(" + CStr(i) + ", " + CStr(j) Output = Output + ") = " + CStr(StripCount) List1.AddItem (Output) For k = 1 To StripCount VertCount = doc.BodyFaceStripVertCount(i, j, k) Output = " VertCount(" + CStr(i) + ", " Output = Output + CStr(j) + ", " + CStr(k) + ") = " Output = Output + CStr(VertCount) List1.AddItem (Output) VertStr = "Verts(" + CStr(i) + ", " + CStr(j) VertStr = VertStr + ", " + CStr(k) + ") = " NormStr = "Norms(" + CStr(i) + ", " + CStr(j) + ", " NormStr = NormStr + CStr(k) + ") = " TexStr = "UVs(" + CStr(i) + ", " + CStr(j) + ", " TexStr = TexStr + CStr(k) + ") = " For m = 1 To VertCount Call doc.GetBodyFaceStripVertex(i, j, k, m, VertX, VertY, VertZ, NormX, NormY, NormZ, TexU, TexV) temp1 = FormatNumber(VertX, 3) temp2 = FormatNumber(VertY, 3) temp3 = FormatNumber(VertZ, 3) VertStr = VertStr + "(" + temp1 + ", " + temp2 VertStr = VertStr + ", " + temp3 + ")" temp1 = FormatNumber(NormX, 3) temp2 = FormatNumber(NormY, 3) temp3 = FormatNumber(NormZ, 3) NormStr = NormStr + "(" + temp1 + ", " + temp2 NormStr = NormStr + ", " + temp3 + ")" temp1 = FormatNumber(TexU, 3) temp2 = FormatNumber(TexV, 3) TexStr = TexStr + "(" + temp1 + ", " + temp2 + ")" If m < VertCount Then VertStr = VertStr + ", " NormStr = NormStr + ", " TexStr = TexStr + ", " End If Next List1.AddItem (VertStr) List1.AddItem (NormStr) List1.AddItem (TexStr) Next Next Next List1.AddItem ("----------") Call doc.CloseEnd If

FileError: Exit Sub

SEFacet User’s Manual page - 30

Page 31: Se Facet

End Sub

SEFacet User’s Manual page - 31

Page 32: Se Facet

Double-click the DirListBox control (#4 in the image), and add the following code:

Private Sub Dir1_Change() ‘ Make the directory change known to the FileListBox control (AvailFiles) AvailFiles.Path = Dir1.Path AvailFiles.RefreshEnd Sub

Double-click the DriveListBox control (#5 in the image), and add the following code:

Private Sub Drive1_Change() ‘ Make the drive change known to the DirListBox (Dir1). ‘ The DirListBox control will notify the FileListBox control ‘ automatically.

Dir1.Path = Drive1.Drive Dir1.RefreshEnd Sub

Run the program. Use the Directory, Drive, and Filename controls to select the part or weldment file to read, then push the “Read” button to see the geometry information.

1.1.4.2 Adding Style Information

To add StyleLibrary support to the VB program above, replace the code in Command1_Click with the following code:

Private Sub Command1_Click()Dim doc As ObjectDim StyleLib As ObjectDim Output As StringDim filename As StringDim currentDrive As StringDim i As LongDim j As LongDim k As LongDim m As Long

Dim BodyCount As LongDim FaceCount As LongDim StripCount As LongDim VertCount As LongDim VertX As DoubleDim VertY As DoubleDim VertZ As DoubleDim NormX As DoubleDim NormY As DoubleDim NormZ As DoubleDim TexU As DoubleDim TexV As Double

Dim VertStr As StringDim NormStr As String

SEFacet User’s Manual page - 32

Page 33: Se Facet

Dim TexStr As StringDim temp1 As StringDim temp2 As StringDim temp3 As String

Dim BodyStyle As LongDim ConstructionStyle As LongDim FaceStyle As Long

' Get the current path for the selected filecurrentDrive = Drive1.Drive + "\"currentDrive = StrConv(currentDrive, vbUpperCase)

' If the Dir1.Path is anything but the root directory, append a backslash' before appending the draft filename.

If (Dir1.Path <> currentDrive) Thenfilename = Dir1.Path + "\" + AvailFiles.filenameElse filename = Dir1.Path + AvailFiles.filenameEnd If

' Set up error handlingOn Error GoTo FileError

' Make sure we have a valid filenameIf (AvailFiles.filename <> "") Then ' set up the object and open the SE file Set doc = CreateObject("SEFacet.FacetReader") Call doc.Open(filename) Set StyleLib = CreateObject("SEFacet.StyleLibrary") Call StyleLib.Open(filename)

BodyCount = doc.BodyCount

List1.AddItem (CStr(BodyCount) + " bodies in '" + filename + "'")

For i = 1 To BodyCount FaceCount = doc.BodyFaceCount(i) Output = " FaceCount(" + CStr(i) + ") = " + CStr(FaceCount) List1.AddItem (Output) BodyStyle = doc.BodyStyle(i) ConstructionStyle = doc.BodyConstructionStyle(i) For j = 1 To FaceCount StripCount = doc.BodyFaceStripCount(i, j) Output = " StripCount(" + CStr(i) + ", " + CStr(j) Output = Output + ") = " + CStr(StripCount) List1.AddItem (Output) FaceStyle = doc.BodyFaceStyle(i, j) ' If there's no face style, use the body style If (Not StyleLib.StyleExists(FaceStyle)) Then FaceStyle = BodyStyle

' If there's no body style, use the construction style If (Not StyleLib.StyleExists(FaceStyle)) Then FaceStyle = ConstructionStyle

SEFacet User’s Manual page - 33

Page 34: Se Facet

' Output the style ID Output = " Style ID(" + CStr(i) + ", " + CStr(j) Output = Output + ") = " + CStr(FaceStyle) List1.AddItem (Output) If StyleLib.StyleExists(FaceStyle) Then ' Get the StyleName Dim StyleName As String StyleName = StyleLib.StyleName(FaceStyle) Output = " Style Name(" + CStr(FaceStyle) + ") = " + StyleName List1.AddItem (Output) ' Get info from StyleSurface Dim diffuse As Long Dim specular As Long Dim ambient As Long Dim emission As Long Dim shiny As Single Dim alpha As Single Call StyleLib.StyleSurface(FaceStyle, diffuse, specular, ambient, emission, shiny, alpha) Output = " Style Info(" + CStr(FaceStyle) + ") = Diffuse " + ColorString(diffuse) + "," List1.AddItem (Output) Output = " Specular " + ColorString(specular) + ", Ambient " + ColorString(ambient) + "," List1.AddItem (Output) Output = " Emission " + ColorString(emission) List1.AddItem (Output) Output = " Style Info(" + CStr(FaceStyle) + ") = Shininess (" + CStr(shiny) + "), Alpha (" + CStr(alpha) + ")" List1.AddItem (Output) ' Get info from StyleSurfaceEx Dim reflect As Single Dim refract As Single Dim shadows As Long Call StyleLib.StyleSurfaceEx(FaceStyle, reflect, refract, shadows) Output = " Style Info(" + CStr(FaceStyle) + ") = Reflection (" + CStr(reflect) + "), Refraction (" + CStr(refract) + ")" List1.AddItem (Output) Output = " Style Info(" + CStr(FaceStyle) + ") = " Select Case shadows Case 0 Output = Output + "No Shadows" Case 1 Output = Output + "Casts Shadows" Case 2

SEFacet User’s Manual page - 34

Page 35: Se Facet

Output = Output + "Accepts Shadows" Case 3 Output = Output + "Casts and Accepts Shadows" End Select List1.AddItem (Output) ' Get info from StyleWireframe Dim WireColor As Long Dim WireWidth As Single Dim StipplePattern As Long Dim StippleScale As Long Dim StipplePatternString As String Dim StippleLength As Integer Call StyleLib.StyleWireframe(FaceStyle, WireColor, WireWidth, StipplePattern, StippleScale) ' Format the hex string for output StipplePatternString = Hex(StipplePattern) StippleLength = Len(StipplePatternString) If StippleLength < 4 Then StipplePatternString = String(4 - StippleLength, 48) + StipplePatternString StipplePatternString = "&H" + StipplePatternString Output = " Wireframe(" + CStr(FaceStyle) + ") = Color " + ColorString(WireColor) + ", Width (" + CStr(WireWidth) + ")" List1.AddItem (Output) Output = " Wireframe(" + CStr(FaceStyle) + ") = Stipple Pattern (" + StipplePatternString + "), Scale (" + CStr(StippleScale) + ")" List1.AddItem (Output) ' Get info from StyleTexture Dim TextureFile As String Dim TextureUnits As Long Dim TextureRotation As Single Dim TextureScaleX As Single Dim TextureScaleY As Single Dim TextureOffsetX As Single Dim TextureOffsetY As Single Dim Weight As Single Dim TextureMirror As Long Dim TextureTrans As Boolean Dim BGColor As Long Call StyleLib.StyleTexture(FaceStyle, TextureFile, TextureUnits, TextureRotation, TextureScaleX, TextureScaleY, TextureOffsetX, TextureOffsetY, Weight, TextureMirror, TextureTrans, BGColor) If TextureFile <> "" Then Output = " Texture(" + CStr(FaceStyle) + ") = " + TextureFile List1.AddItem (Output) Output = " Texture(" + CStr(FaceStyle) + ") = Rotation (" + CStr(TextureRotation) + ")"

SEFacet User’s Manual page - 35

Page 36: Se Facet

List1.AddItem (Output) Output = " Texture(" + CStr(FaceStyle) + ") = " If TextureScale = 0 Then Output = Output + "Surface " Else Output = Output + "World " End If Output = Output + "Scale (" + CStr(TextureScaleX) + ", " + CStr(TextureScaleY) + ")" List1.AddItem (Output) Output = " Texture(" + CStr(FaceStyle) + ") = Offset (" + CStr(TextureOffsetX) + ", " + CStr(TextureOffsetY) + "), Weight (" + CStr(Weight) + ")" List1.AddItem (Output) Output = " Texture(" + CStr(FaceStyle) + ") = " Select Case TextureMirror Case 0 Output = Output + "No Mirror" Case 1 Output = Output + "X Mirror" Case 2 Output = Output + "Y Mirror" Case 3 Output = Output + "X and Y Mirror" End Select List1.AddItem (Output) If TextureTrans Then Output = " Texture(" + CStr(FaceStyle) + ") = Transparent Color " + ColorString(BGColor) End If List1.AddItem (Output) End If ' Get info from StyleBumpmap Dim BumpFile As String Dim BumpUnits As Long Dim BumpRotation As Single Dim BumpScaleX As Single Dim BumpScaleY As Single Dim BumpOffsetX As Single Dim BumpOffsetY As Single Dim Height As Single Dim BumpMirror As Long Call StyleLib.StyleBumpmap(FaceStyle, BumpFile, BumpUnits, BumpRotation, BumpScaleX, BumpScaleY, BumpOffsetX, BumpOffsetY, Height, BumpMirror) If BumpFile <> "" Then

SEFacet User’s Manual page - 36

Page 37: Se Facet

Output = " Bumpmap(" + CStr(FaceStyle) + ") = " + BumpFile List1.AddItem (Output) Output = " Bumpmap(" + CStr(FaceStyle) + ") = Rotation (" + CStr(BumpRotation) + ")" List1.AddItem (Output) Output = " Bumpmap(" + CStr(FaceStyle) + ") = " If BumpScale = 0 Then Output = Output + "Surface " Else Output = Output + "World " End If Output = Output + "Scale (" + CStr(BumpScaleX) + ", " + CStr(BumpScaleY) + ")" List1.AddItem (Output) Output = " Bumpmap(" + CStr(FaceStyle) + ") = Offset (" + CStr(BumpOffsetX) + ", " + CStr(BumpOffsetY) + "), Weight (" + CStr(Weight) + ")" List1.AddItem (Output) Output = " Bumpmap(" + CStr(FaceStyle) + ") = " Select Case BumpMirror Case 0 Output = Output + "No Mirror" Case 1 Output = Output + "X Mirror" Case 2 Output = Output + "Y Mirror" Case 3 Output = Output + "X and Y Mirror" End Select List1.AddItem (Output) End If ' Get Skybox info

Dim SkyboxType As Integer SkyboxType = StyleLib.StyleSkyboxType(FaceStyle) If SkyboxType > 0 Then Output = " Skybox(" + CStr(FaceStyle) + ") = Type " Select Case SkyboxType Case 1 Output = Output + "(Sphere Map)" Case 2 Output = Output + "(Single Image)" Case 3 Output = Output + "(Environment Box)" End Select

SEFacet User’s Manual page - 37

Page 38: Se Facet

List1.AddItem (Output) Dim SideCount As Integer Dim count As Integer SideCount = StyleLib.StyleSkyboxSideCount(FaceStyle) For count = 1 To SideCount Dim SideName As String SideName = StyleLib.StyleSkyboxSideFilename(FaceStyle, count) Output = " Skybox(" + CStr(FaceStyle) + "), Side " + CStr(count) + " = (" + SideName + ")" List1.AddItem (Output) Next If SkyboxType = 3 Then Dim Azimuth As Single Dim Altitude As Single Dim Roll As Single Dim FieldofView As Single Call StyleLib.StyleSkyboxOrientation(FaceStyle, Azimuth, Altitude, Roll, FieldofView) Output = " Skybox Orientation(" + CStr(FaceStyle) + ") = Azimuth (" + CStr(Azimuth) + ")" List1.AddItem (Output) Output = " Skybox Orientation(" + CStr(FaceStyle) + ") = Altitude (" + CStr(Altitude) + ")" List1.AddItem (Output) Output = " Skybox Orientation(" + CStr(FaceStyle) + ") = Roll (" + CStr(Roll) + ")" List1.AddItem (Output) Output = " Skybox Orientation(" + CStr(FaceStyle) + ") = FieldofView (" + CStr(FieldofView) + ")" List1.AddItem (Output) End If End If End If For k = 1 To StripCount VertCount = doc.BodyFaceStripVertCount(i, j, k) Output = " VertCount(" + CStr(i) + ", " Output = Output + CStr(j) + ", " + CStr(k) + ") = " Output = Output + CStr(VertCount) List1.AddItem (Output) VertStr = "Verts(" + CStr(i) + ", " + CStr(j) VertStr = VertStr + ", " + CStr(k) + ") = " NormStr = "Norms(" + CStr(i) + ", " + CStr(j) + ", " NormStr = NormStr + CStr(k) + ") = " TexStr = "UVs(" + CStr(i) + ", " + CStr(j) + ", " TexStr = TexStr + CStr(k) + ") = " For m = 1 To VertCount

SEFacet User’s Manual page - 38

Page 39: Se Facet

Call doc.GetBodyFaceStripVertex(i, j, k, m, VertX, VertY, VertZ, NormX, NormY, NormZ, TexU, TexV) temp1 = FormatNumber(VertX, 3) temp2 = FormatNumber(VertY, 3) temp3 = FormatNumber(VertZ, 3) VertStr = VertStr + "(" + temp1 + ", " + temp2 VertStr = VertStr + ", " + temp3 + ")" temp1 = FormatNumber(NormX, 3) temp2 = FormatNumber(NormY, 3) temp3 = FormatNumber(NormZ, 3) NormStr = NormStr + "(" + temp1 + ", " + temp2 NormStr = NormStr + ", " + temp3 + ")" temp1 = FormatNumber(TexU, 3) temp2 = FormatNumber(TexV, 3) TexStr = TexStr + "(" + temp1 + ", " + temp2 + ")" If m < VertCount Then VertStr = VertStr + ", " NormStr = NormStr + ", " TexStr = TexStr + ", " End If Next List1.AddItem (VertStr) List1.AddItem (NormStr) List1.AddItem (TexStr) Next Next Next List1.AddItem ("----------") Call doc.CloseEnd If

FileError: Exit SubEnd Sub

Add this function to the VB program above:

Function ColorString(Color As Long) As String Dim red As Integer Dim green As Integer Dim blue As Integer Dim temp As Long temp = Color red = temp Mod 256 temp = (temp - red) / 256 green = temp Mod 256 temp = (temp - green) / 256 blue = temp ColorString = "(" + CStr(red) + ", " + CStr(green) + ", " + CStr(blue) + ")"End Function

SEFacet User’s Manual page - 39

Page 40: Se Facet

1.1.5 Section 3: MFC Example

The following ZIP file contains the necessary files to build the MFC example. Note that this project was developed using Microsoft Visual C++ 6.0 (SP3)

Although comments are included in the code, the general workflow is described below.

1. GLFacet is started2. The program waits for the Open button to be pressed, or for the most recently

used file to be selected.3. After a part or weldment file is chosen, the function CGLFacetDoc::Open is

called, which opens the part file through the SEFacet DLL (using both FacetReader’s and StyleLibrary’s Open members). CGLFacetDoc::Open then uses SEFacet’s interface to read the part file’s facet information, and copies the vertex locations and normals into an OpenGL display list, which is a form that can easily be displayed in 3D. In the process, it also reads style information through the StyleLibrary interface, and assigns to each face the style information that OpenGL supports.

4. The user can click and drag the mouse in the display window to rotate the part around, to view it from several angles.

SEFacet User’s Manual page - 40