Professional Documents
Culture Documents
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.
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
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
Return
S_OK
E_POINTER
E_FAIL
Success.
pVal is NULL or otherwise corrupt.
User did not first open a part document.
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
page - 3
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.
page - 4
page - 5
page - 6
E_FAIL
page - 7
Return
page - 8
S_OK
E_POINTER
E_INVALIDARG
E_FAIL
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
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.
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
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.
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
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.
page - 12
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
Success.
User did not first open a style library.
page - 14
Return
S_OK
E_POINTER
E_FAIL
Success.
pVal is NULL or otherwise corrupt.
User did not first open a style library.
page - 15
Return
S_OK
E_POINTER
E_FAIL
Success.
pVal is NULL or otherwise corrupt.
User did not first open a style library.
page - 16
Success.
pVal is NULL.
User did not first open a style library.
Success.
pVal is NULL.
User did not first open a style library.
page - 17
Return
S_OK
E_INVALIDARG
E_FAIL
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
Return
S_OK
E_INVALIDARG
E_FAIL
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
page - 20
TransBG
TransColor
Return
S_OK
E_POINTER
E_FAIL
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
page - 22
Return
S_OK
E_POINTER
E_FAIL
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
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)
page - 25
Return
S_OK
E_INVALIDARG
E_POINTER
E_FAIL
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
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.
2.
3.
4.
5.
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
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
page - 30
End Sub
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.
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
page - 32
Dim
Dim
Dim
Dim
TexStr As String
temp1 As String
temp2 As String
temp3 As String
page - 33
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
page - 34
WireColor As Long
WireWidth As Single
StipplePattern As Long
StippleScale As Long
StipplePatternString As String
StippleLength As Integer
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
+ TextureFile
List1.AddItem (Output)
Output = "
Texture(" + CStr(FaceStyle) + ") =
Rotation (" + CStr(TextureRotation) + ")"
page - 35
List1.AddItem (Output)
Output = "
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 = "
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
page - 36
Output = "
+ BumpFile
List1.AddItem (Output)
Output = "
Bumpmap(" + CStr(FaceStyle) + ") =
Rotation (" + CStr(BumpRotation) + ")"
List1.AddItem (Output)
Output = "
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 = "
Type "
Select Case SkyboxType
Case 1
Output = Output + "(Sphere Map)"
Case 2
Output = Output + "(Single Image)"
Case 3
Output = Output + "(Environment Box)"
End Select
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
page - 38
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
page - 39
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.
page - 40