You are on page 1of 40

Users 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 parts 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
8. GetBodyFaceStripVertex
9. get_BodyStyle
10. get_BodyConstructionStyle
11. get_BodyFaceStyle

SEFacet Users Manual

page - 1

1.1.2.1 CFacetReader::Open
C++ Syntax
HRESULT Open(BSTR Filename)
Visual Basic Syntax
String Filename = somename.par
Open(Filename)
Purpose
Opens the specified part or weldment file and ensures that it contains facet information. It
can read either a *.par or a *.pwd file.
Return
S_OK
E_INVALIDARG
E_FAIL

Success.
Filename is NULL.
General Failure.

1.1.2.2 CFacetReader::Close
C++ Syntax
HRESULT Close()
Visual Basic Syntax
Call Close
Purpose
Closes the part or weldment file.
Return
S_OK
E_FAIL

SEFacet Users Manual

Success.
User did not first open a part document.

page - 2

1.1.2.3 CFacetReader::get_BodyCount
C++ Syntax
HRESULT get_BodyCount(long *pVal)
Visual Basic Syntax
Long BodyNum = BodyCount
Purpose
Returns the number of bodies in the part or weldment document.
Parameters
pVal

Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_FAIL

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

1.1.2.4 CFacetReader:: get_BodyFaceCount


C++ Syntax
HRESULT get_BodyFaceCount(long nBody, long *pVal)
Visual Basic Syntax
Dim BodyID as Long
Long FaceCount = BodyFaceCount(BodyID)
Purpose
Returns the number of faces in the body with index nBody.
Parameters
BodyID
PVal

Index of the body where the face can be found


Placeholder for the return value of the function.

Return
S_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.
1.1.2.5 CFacetReader:: get_BodyFaceStripCount
C++ Syntax

SEFacet Users Manual

page - 3

HRESULT get_BodyFaceStripCount(long nBody, long nFace, long *pVal)


Visual Basic Syntax
Dim BodyID as Long
Dim FaceID as Long
Long StripCount = BodyFaceStripCount(BodyID, FaceID)
Purpose
Returns the number of strips in the face with index nFace, in the body with index nBody.
Parameters
BodyID
FaceID
PVal

Index of the body where the strip can be found


Index of the face where the strip can be found
Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_INVALIDARG
E_FAIL

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

SEFacet Users Manual

page - 4

1.1.2.6 CFacetReader:: get_BodyFaceStripVertCount


C++ Syntax
HRESULT get_BodyFaceStripVertCount(long nBody, long nFace, long nStrip, long
*pVal)
Visual Basic Syntax
Dim BodyID as Long
Dim FaceID as Long
Dim StripID as Long
Long VertCount = BodyFaceStripVertCount (BodyID, FaceID, StripID)
Purpose
Returns the number of vertices in the strip with index nStrip, in the face with index nFace,
in the body with index nBody.
Parameters
BodyID
FaceID
StripID
PVal
Return
S_OK
E_POINTER
E_INVALIDARG
E_FAIL

SEFacet Users Manual

Index of the body where the strip can be found


Index of the face where the strip can be found
Index of the strip which the user wants a vertex count from
Placeholder for the return value of the function.
Success.
pVal is NULL or otherwise corrupt.
nBody is not a valid body ID, nFace is not a valid face ID,
or nStrip is not a valid strip ID.
User did not first open a part document.

page - 5

1.1.2.7 CFacetReader:: GetBodyFaceStrip


C++ Syntax
HRESULT GetBodyFaceStrip(long nBody, long nFace, long nStrip, long *nVerts,
SAFEARRAY **ppVerts, VARIANT *ppNorms, VARIANT *ppParams)
Visual Basic Syntax
GetBodyFaceStripVertex is easier to use in VB, but this code will work with
GetBodyFaceStrip:
Dim VertCount as Long
Dim VertCount2 as Long
Dim BodyID as Long
Dim FaceID as Long
Dim StripID as Long
Dim Verts() as Double
Dim Norms() as Double
Dim Params() as Double
VertCount = BodyFaceStripVertCount(BodyID, FaceID, StripID)
ReDim Verts(3 * VertCount) as Double
ReDim Norms(3 * VertCount) as Double
ReDim Params(2 * VertCount) as Double
Call GetBodyFaceStrip (BodyID, FaceID, StripID, VertCount2, Verts, Norms, Params)
Purpose
Returns the number of vertices in the strip, as well as arrays containing the vertex
locations, normals, and texture (uv) coordinates.
Parameters
BodyID
FaceID
StripID
nVerts
ppVerts
ppNorms
ppParams
Return
S_OK
E_INVALIDARG

SEFacet Users Manual

Index of the body where the strip can be found


Index of the face containing the strip the user wants vertex
information from
Index of the strip the user wants vertex information from
Number of verts returned for this strip.
Array containing vertex locations. The array has 3 x nVerts
elements, in x, y, z, x, y, z order.
Array containing vertex normals. The array has 3 x nVerts
elements, in x, y, z, x, y, z order.
Array containing vertex uv coordinates. The array has
2 x nVerts elements, in u, v, u, v order.
Success.
nBody is not a valid body ID, nFace is not a valid face
ID, nStrip is not a valid strip ID, or ppNorms or ppParams

page - 6

E_FAIL

SEFacet Users Manual

point to invalid Variant arrays.


User did not first open a part document.

page - 7

1.1.2.8 CFacetReader:: GetBodyFaceStripVertex


C++ Syntax
HRESULT 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 Syntax
Dim BodyID as Long
Dim FaceID as Long
Dim StripID as Long
Dim VertID as Long
Dim VertX as Double
Dim VertY as Double
Dim VertZ as Double
Dim NormX as Double
Dim NormY as Double
Dim NormZ as Double
Dim TexU as Double
Dim TexV as Double
Call GetBodyFaceStripVertex (BodyID, FaceID, StripID, VertID, VertX, VertY, VertZ,
NormX, NormY, NormZ, TexU, TexV)
Purpose
Returns the location, normal, and texture coordinate of the desired vertex. If the pointers
to the normal return values are NULL, SEFacet will assume you dont want normal
information. If the pointers to the texture coordinate return values are NULL, SEFacet
will assume you dont want texture information.
Parameters
BodyID
FaceID
StripID
VertID
VertX
VertY
VertZ
NormX
NormY
NormZ
TexU
TexV

Index of the body where the strip can be found


Index of the face containing the strip the user wants vertex
information from
Index of the strip containing the desired vertex
Index of the desired vertex.
X coordinate of the vertexs location.
Y coordinate of the vertexs location.
Z coordinate of the vertexs location.
X coordinate of the vertexs normal.
Y coordinate of the vertexs normal.
Z coordinate of the vertexs normal.
U coordinate of the vertexs texture coordinate.
V coordinate of the vertexs texture coordinate.

Return

SEFacet Users Manual

page - 8

S_OK
E_POINTER
E_INVALIDARG

E_FAIL

SEFacet Users Manual

Success.
One or more of the required return pointers (dVertX, dVertY, or
dVertZ) is NULL or otherwise corrupt.
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 returned
if one or two of the normal return variables are null, or if one of the
two texture coordinate return variables is NULL.
User did not first open a part document.

page - 9

1.1.2.9 CFacetReader:: get_BodyStyle


C++ Syntax
HRESULT get_BodyStyle(long nBody, long *pVal)
Visual Basic Syntax
Dim BodyID as Long
Long StyleID = BodyStyle(BodyID)
Purpose
Returns the style ID assigned to the body with index nBody.
Parameters
BodyID
PVal

Index of the body where the style ID can be found


Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_INVALIDARG
E_FAIL

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

SEFacet Users Manual

page - 10

1.1.2.10

CFacetReader:: get_BodyConstructionStyle

C++ Syntax
HRESULT get_BodyConstructionStyle (long nBody, long *pVal)
Visual Basic Syntax
Dim BodyID as Long
Long StyleID = BodyConstructionStyle (BodyID)
Purpose
Returns the construction style ID assigned to the body with index nBody.
Parameters
BodyID
pVal

Index of the body where the style ID can be found


Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_INVALIDARG
E_FAIL

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

SEFacet Users Manual

page - 11

1.1.2.11

CFacetReader:: get_BodyFaceStyle

C++ Syntax
HRESULT get_BodyFaceStyle(long nBody, long nFace, long *pVal)
Visual Basic Syntax
Dim BodyID as Long
Dim FaceID as Long
Long StyleID = BodyFaceStyle(BodyID, FaceID)
Purpose
Returns 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.
Parameters
BodyID
FaceID
PVal

Index of the body where the face can be found


Index of the face
Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_INVALIDARG
E_FAIL

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

SEFacet Users Manual

page - 12

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.
Styles 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. Open
2. Close
3. get_StyleExists
4. get_StyleType
5. get_StyleName
6. get_StyleDescription
7. StyleSurface
8. StyleSurfaceEx
9. StyleTexture
10. StyleBumpmap
11. StyleWireframe
12. get_StyleSkyboxType
13. get_StyleSkyboxSideCount
14. get_StyleSkyboxSideFilename
15. 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 FacetReaders
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 Users Manual

page - 13

1.1.3.1 CStyleLibrary::Open
C++ Syntax
HRESULT Open(BSTR Filename)
Visual Basic Syntax
String Filename = somename.par
Open(Filename)
Purpose
Opens the style library in the specified part or weldment file. It can read either a *.par or a
*.pwd file.
Return
S_OK
E_INVALIDARG
E_FAIL

Success.
Filename is empty or NULL.
General Failure.

1.1.3.2 CStyleLibrary::Close
C++ Syntax
HRESULT Close()
Visual Basic Syntax
Call Close
Purpose
Closes the style library of the part or weldment file.
Return
S_OK
E_FAIL

SEFacet Users Manual

Success.
User did not first open a style library.

page - 14

1.1.3.3 CStyleLibrary:: get_StyleExists


C++ Syntax
HRESULT get_StyleExists(ULONG ID, VARIANT_BOOL *pVal)
Visual Basic Syntax
Dim StyleID As Long
Boolean BodyNum = StyleExists(StyleID)
Purpose
Returns True (VARIANT_TRUE in C++) if the style ID corresponds to a valid face style
in the library.
Parameters
ID
pVal

Index of the style


Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_FAIL

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

SEFacet Users Manual

page - 15

1.1.3.4 CStyleLibrary:: get_StyleType


C++ Syntax
HRESULT get_StyleType(ULONG ID, short *pVal)
Visual Basic Syntax
Dim StyleID as Long
Integer StyleTypeNumber = StyleType(StyleID)
Purpose
Returns 1 if the style corresponding to ID points to a face style, and returns 2 if the style is
a view style.
Parameters
ID
pVal

Index of the style


Placeholder for the return value of the function.

Return
S_OK
E_POINTER
E_FAIL

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

SEFacet Users Manual

page - 16

1.1.3.5 CStyleLibrary:: get_StyleName


C++ Syntax
HRESULT get_StyleName (ULONG ID, BSTR *pVal)
Visual Basic Syntax
Dim StyleID as Long
String Name = StyleName(StyleID)
Purpose
Gets the name of the style corresponding to ID.
Return
S_OK
E_INVALIDARG
E_FAIL

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

1.1.3.6 CStyleLibrary:: get_StyleDescription


C++ Syntax
HRESULT get_StyleDescription (ULONG ID, BSTR *pVal)
Visual Basic Syntax
Dim StyleID as Long
String Desc = StyleDescription(StyleID)
Purpose
Gets a short string describing the style corresponding to ID.
Return
S_OK
E_INVALIDARG
E_FAIL

SEFacet Users Manual

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

page - 17

1.1.3.7 CStyleLibrary:: StyleSurface


C++ Syntax
HRESULT StyleSurface (ULONG ID, long *Diffuse, long *Specular, long *Ambient, long
*Emission, float *Shininess, float *Alpha)
Visual Basic Syntax
Dim StyleID as Long
Dim Diffuse as Long
Dim Specular as Long
Dim Ambient as Long
Dim Emission as Long
Dim Shininess as Double
Dim Alpha as Double
Call StyleSurface (StyleID, Diffuse, Specular, Ambient, Emission, Shininess, Alpha)
Purpose
Returns 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 doesnt want that information.
Parameters
ID
Diffuse
Specular
Ambient
Emission
Shininess
Alpha

Index of the face style with the desired surface information.


The surfaces Diffuse color. C++ users can type-cast it to
COLORREF.
Color of the surfaces specular highlights. C++ users can
type-cast it to COLORREF.
The surfaces ambient color. C++ users can type-cast it to
COLORREF.
The surfaces emitted color. C++ users can type-cast it to
COLORREF.
Shininess of the surface. Ranges from no shininess (0) to
completely shiny (1).
Surfaces opacity, ranging from completely transparent (0)
to completely opaque (1).

Return
S_OK
E_INVALIDARG
E_FAIL

SEFacet Users Manual

Success.
All of the return pointers are NULL or otherwise corrupt, so theres
no information to return.
User did not first open a style library.

page - 18

1.1.3.8 CStyleLibrary:: StyleSurfaceEx


C++ Syntax
HRESULT StyleSurfaceEx (ULONG ID, float *Reflectivity, float *Refraction, int
*Shadows)
Visual Basic Syntax
Dim StyleID as Long
Dim Reflectivity as Double
Dim Refraction as Double
Dim Shadows as Integer
Call StyleSurface (StyleID, Reflectivity, Refraction, Shadows)
Purpose
Returns 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 doesnt want that information.
Parameters
ID
Reflectivity
Refraction
Shadows

Return
S_OK
E_INVALIDARG
E_FAIL

SEFacet Users Manual

Index of the face style with the desired surface information.


The amount of light the surface reflects. Ranges from no reflection
(0) to perfect mirror-like reflection (1).
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).
Surfaces shadow settings. Values can be 0 (neither casts nor
accepts shadows), 1 (only casts shadows), 2 (only accepts
shadows), or 3 (both casts and accepts shadows).

Success.
All of the return pointers are NULL or otherwise corrupt, so theres
no information to return.
User did not first open a style library.

page - 19

1.1.3.9 CStyleLibrary:: StyleTexture


C++ Syntax
HRESULT 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 Syntax
Dim StyleID as Long
Dim TextureFile As String
Dim Units as Integer
Dim Rotation as Double
Dim ScaleX as Double
Dim ScaleY as Double
Dim OffsetX as Double
Dim OffsetY as Double
Dim Weight as Double
Dim Mirror as Integer
Dim TransBG as Boolean
Dim TransColor as Long
Call StyleTexture (StyleID, TextureFile, Units, Rotation, ScaleX, ScaleY, OffsetX,
OffsetY, Weight, Mirror, TransBG, TransColor)
Purpose
Returns 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
doesnt want that information.
Parameters
ID
Filename
Units
Rotation
ScaleX
ScaleY
OffsetX
OffsetY
Weight
Mirror

SEFacet Users Manual

Index of the face style with the desired surface information.


The name of the file containing the texture map image.
Specifies whether the scale values are in surface (0) or world (1)
coordinates. Surface scale is relative to the faces texture
coordinates, and world scale is relative to 3D space.
Rotation angle of the texture map relative to the UV texture
coordinates, in degrees. Ranges from 0 to 360.
Scales the texture map in the x direction, using either surface or
world scale units.
Scales the texture map in the y direction.
Offsets the texture map in the x direction, relative to UV texture
coordinates.
Offsets the texture map in the y direction.
Determines how much the texture affects the surface color. Ranges
from 0, where the texture map cant even be seen, to 1, where
surface appearance comes entirely from the texture map.
Flips the texture map. Values can be 0 (not mirrored around either

page - 20

TransBG
TransColor

Return
S_OK
E_POINTER
E_FAIL

SEFacet Users Manual

x or y axis), 1 (mirrored only about x axis), 2 (mirrored only about


y axis), or 3 (mirrored about both x and y axes).
True if the texture has a transparent color defined. When a
transparent color is defined, the texture map will be transparent at
each pixel that has that color.
The color that will be transparent in the texture map. C++ users can
type-cast it to COLORREF.

Success.
All of the return pointers are NULL or otherwise corrupt, so theres
no information to return.
User did not first open a style library.

page - 21

1.1.3.10

CStyleLibrary:: StyleBumpmap

C++ Syntax
HRESULT StyleBumpmap (ULONG ID, BSTR *Filename, int *Units, float *Rotation,
float *ScaleX, float *ScaleY, float *OffsetX, float *OffsetY, float *Height, int
*Mirror)
Visual Basic Syntax
Dim StyleID as Long
Dim TextureFile As String
Dim Units as Integer
Dim Rotation as Double
Dim ScaleX as Double
Dim ScaleY as Double
Dim OffsetX as Double
Dim OffsetY as Double
Dim Weight as Double
Dim Mirror as Integer
Call StyleBumpmap (StyleID, TextureFile, Units, Rotation, ScaleX, ScaleY, OffsetX,
OffsetY, Weight, Mirror)
Purpose
Returns 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 doesnt
want that information.
Parameters
ID
Filename
Units
Rotation
ScaleX
ScaleY
OffsetX
OffsetY
Height
Mirror

SEFacet Users Manual

Index of the face style with the desired surface information.


The name of the file containing the bump map image.
Specifies whether the scale values are in surface (0) or world (1)
coordinates. Surface scale is relative to the faces texture
coordinates, and world scale is relative to 3D space.
Rotation angle of the bump map relative to the UV texture
coordinates, in degrees. Ranges from 0 to 360.
Scales the bump map in the x direction, using either surface or
world scale units.
Scales the bump map in the y direction.
Offsets the bump map in the x direction, relative to UV texture
coordinates.
Offsets the bump map in the y direction.
Determines how bumpy the bump map will be. At 0 height, the
bump map has no effect. There is no upper limit, but height looks
best below about 5.
Flips the bump map. Values can be 0 (not mirrored around either
x or y axis), 1 (mirrored only about x axis), 2 (mirrored only about
y axis), or 3 (mirrored about both x and y axes).

page - 22

Return
S_OK
E_POINTER
E_FAIL

SEFacet Users Manual

Success.
All of the return pointers are NULL or otherwise corrupt, so theres
no information to return.
User did not first open a style library.

page - 23

1.1.3.11

CStyleLibrary:: StyleWireframe

C++ Syntax
HRESULT StyleWireframe (ULONG ID, long *Color, float *Width, long *StipplePattern,
long *StippleScale)
Visual Basic Syntax
Dim StyleID as Long
Dim WireColor as Long
Dim Width as Double
Dim StipplePattern as Long
Dim StippleScale as Long
Call StyleWireframe (StyleID, WireColor, Width, StipplePattern, StippleScale)
Purpose
Returns 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 doesnt want that information.
Parameters
ID
Color
Width
StipplePattern
StippleScale

Return
S_OK
E_INVALIDARG
E_FAIL

SEFacet Users Manual

Index of the face style with the desired surface information.


The color of the objects outlines. C++ users can type-cast it to
COLORREF.
Width of the outlines, in pixels.
Its bits encode the Wireframe dashed lines pattern.
Defines the length of the dash pattern specified in StipplePattern.
The default value is 1.

Success.
All of the return pointers are NULL or otherwise corrupt, so theres
no information to return.
User did not first open a style library.

page - 24

1.1.3.12

CStyleLibrary:: get_StyleSkyboxType

C++ Syntax
HRESULT get_StyleSkyboxType (ULONG ID, short *pVal)
Visual Basic Syntax
Dim StyleID as Long
Integer SkyboxType = StyleSkyboxType(StyleID)
Purpose
Gets 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).
Return
S_OK
E_POINTER
E_FAIL

1.1.3.13

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

CStyleLibrary:: get_StyleSkyboxSideCount

C++ Syntax
HRESULT get_StyleSkyboxSideCount (ULONG ID, short *pVal)
Visual Basic Syntax
Dim StyleID as Long
Integer SkyboxSide = StyleSkyboxSideCount(StyleID)
Purpose
Gets 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.
Return
S_OK
E_ POINTER
E_FAIL
1.1.3.14

Success.
pVal is NULL.
User did not first open a style library.
CStyleLibrary:: get_StyleSkyboxSideFilename

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

SEFacet Users Manual

page - 25

Visual Basic Syntax


Dim StyleID as Long
Dim SkyboxSide as Integer
String SkyboxSideName = StyleSkyboxSideFilename (StyleID, SkyboxSide)
Purpose
Gets the image file name of one side of the skybox in the style corresponding to ID.
Parameters
ID
Side

Return
S_OK
E_INVALIDARG
E_POINTER
E_FAIL

SEFacet Users Manual

Index of the face style with the desired surface information.


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 for
sphere map and single image skyboxes.
Success.
Side is not valid.
pVal is NULL.
User did not first open a style library.

page - 26

1.1.3.15

CStyleLibrary:: StyleSkyboxOrientation

C++ Syntax
HRESULT StyleSkyboxOrientation (ULONG ID, float *Azimuth, float *Altitude, float
*Roll, float *FieldOfView)
Visual Basic Syntax
Dim StyleID as Long
Dim Azimuth as Double
Dim Altitude as Double
Dim Roll as Double
Dim FieldOfView as Double
Call StyleSkyboxOrientation (StyleID, Azimuth, Altitude, Roll, FieldOfView)
Purpose
Returns 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 doesnt want that information. Only environment box skyboxes can be oriented,
so this method isnt helpful for the other two kinds of skyboxes.
Parameters
ID
Azimuth
Altitude
Roll
FieldOfView

Return
S_OK
E_POINTER
E_FAIL

SEFacet Users Manual

Index of the face style with the desired surface information.


Horizontal aim angle of the skybox, in degrees. Also known as
yaw in an aircraft. Ranges from 0 to 360.
Vertical aim angle of the skybox, in degrees. Also known as pitch
in an aircraft. Ranges from -90 to 90.
The roll is how far your skybox view has rotated away from the
horizon. Ranges from 0 to 360.
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 large
values show a wide area of the skybox. Ranges from maximum
zoom-in (0) to maximum wide-angle lens zoom-out (180).

Success.
All of the return pointers are NULL or otherwise corrupt, so theres
no information to return.
User did not first open a style library.

page - 27

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.
2.

A ListBox named List1


A Button named Command1, with caption
Read

SEFacet Users Manual

3.
4.
5.

A FileListBox named AvailFiles


A DirListBox named Dir1
A DriveListBox named Drive1

page - 28

Double-click the Command1 control (#2 in the image), and add the following code:
Private Sub Command1_Click()
Dim doc As Object
Dim Output As String
Dim filename As String
Dim currentDrive As String
Dim i As Long
Dim j As Long
Dim k As Long
Dim m As Long
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim

BodyCount As Long
FaceCount As Long
StripCount As Long
VertCount As Long
VertX As Double
VertY As Double
VertZ As Double
NormX As Double
NormY As Double
NormZ As Double
TexU As Double
TexV As Double

Dim
Dim
Dim
Dim
Dim
Dim

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

' Get the current path for the selected file


currentDrive = 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) Then
filename = Dir1.Path + "\" + AvailFiles.filename
Else
filename = Dir1.Path + AvailFiles.filename
End If
' Set up error handling
On Error GoTo FileError
' Make sure we have a valid filename
If (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 Users Manual

page - 29

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 =
temp2 =
temp3 =
VertStr
VertStr

FormatNumber(VertX, 3)
FormatNumber(VertY, 3)
FormatNumber(VertZ, 3)
= VertStr + "(" + temp1 + ", " + temp2
= VertStr + ", " + temp3 + ")"

temp1 =
temp2 =
temp3 =
NormStr
NormStr

FormatNumber(NormX, 3)
FormatNumber(NormY, 3)
FormatNumber(NormZ, 3)
= NormStr + "(" + temp1 + ", " + temp2
= 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.Close
End If
FileError:
Exit Sub

SEFacet Users Manual

page - 30

End Sub

SEFacet Users Manual

page - 31

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.Refresh
End 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.Refresh
End 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 Object
Dim StyleLib As Object
Dim Output As String
Dim filename As String
Dim currentDrive As String
Dim i As Long
Dim j As Long
Dim k As Long
Dim m As Long
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim

BodyCount As Long
FaceCount As Long
StripCount As Long
VertCount As Long
VertX As Double
VertY As Double
VertZ As Double
NormX As Double
NormY As Double
NormZ As Double
TexU As Double
TexV As Double

Dim VertStr As String


Dim NormStr As String

SEFacet Users Manual

page - 32

Dim
Dim
Dim
Dim

TexStr As String
temp1 As String
temp2 As String
temp3 As String

Dim BodyStyle As Long


Dim ConstructionStyle As Long
Dim FaceStyle As Long
' Get the current path for the selected file
currentDrive = 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) Then
filename = Dir1.Path + "\" + AvailFiles.filename
Else
filename = Dir1.Path + AvailFiles.filename
End If
' Set up error handling
On Error GoTo FileError
' Make sure we have a valid filename
If (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 Users Manual

page - 33

' 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
Dim
Dim
Dim
Dim
Dim

diffuse As Long
specular As Long
ambient As Long
emission As Long
shiny As Single
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 Users Manual

page - 34

Output = Output + "Accepts Shadows"


Case 3
Output = Output + "Casts and Accepts Shadows"
End Select
List1.AddItem (Output)
' Get info from StyleWireframe
Dim
Dim
Dim
Dim
Dim
Dim

WireColor As Long
WireWidth As Single
StipplePattern As Long
StippleScale As Long
StipplePatternString As String
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
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim

TextureFile As String
TextureUnits As Long
TextureRotation As Single
TextureScaleX As Single
TextureScaleY As Single
TextureOffsetX As Single
TextureOffsetY As Single
Weight As Single
TextureMirror As Long
TextureTrans As Boolean
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 Users Manual

page - 35

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
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim

BumpFile As String
BumpUnits As Long
BumpRotation As Single
BumpScaleX As Single
BumpScaleY As Single
BumpOffsetX As Single
BumpOffsetY As Single
Height As Single
BumpMirror As Long

Call StyleLib.StyleBumpmap(FaceStyle, BumpFile, BumpUnits,


BumpRotation, BumpScaleX, BumpScaleY, BumpOffsetX, BumpOffsetY, Height,
BumpMirror)
If BumpFile <> "" Then

SEFacet Users Manual

page - 36

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 Users Manual

page - 37

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 Users Manual

page - 38

Call doc.GetBodyFaceStripVertex(i, j, k, m, VertX,


VertY, VertZ, NormX, NormY, NormZ, TexU, TexV)
temp1 =
temp2 =
temp3 =
VertStr
VertStr

FormatNumber(VertX, 3)
FormatNumber(VertY, 3)
FormatNumber(VertZ, 3)
= VertStr + "(" + temp1 + ", " + temp2
= VertStr + ", " + temp3 + ")"

temp1 =
temp2 =
temp3 =
NormStr
NormStr

FormatNumber(NormX, 3)
FormatNumber(NormY, 3)
FormatNumber(NormZ, 3)
= NormStr + "(" + temp1 + ", " + temp2
= 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.Close
End If
FileError:
Exit Sub
End 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 Users Manual

page - 39

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)

GLFacet.zip

Although comments are included in the code, the general workflow is described below.
1. GLFacet is started
2. 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 FacetReaders and
StyleLibrarys Open members). CGLFacetDoc::Open then uses SEFacets interface
to read the part files 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 Users Manual

page - 40

You might also like