Sunteți pe pagina 1din 4

Table Bend Equation sample

The example demonstrates how you can use Visual Basic to customize the Solid Edge
Sheet Metal application to compute the flat pattern length of bend features. This value is
called Bend Allowance, Bend Compensation, Plastic Zone Length (PZL for short) etc.
In general the Sheet Metal documentation refers to this value as PZL.

This example uses table values defined in ModConvert.vb to define the PZL value for
bends in Sheet Metal. If the radius or thickness is not defined in the table then the
program computes the value using a standard formula.

You can easily edit the program so that it will use your standard formula. The program
defines a public OLE Server called PZL. Inside this server is a public function called
PZL. When connected to a Sheet Metal document via Materials property settings Solid
Edge will call this function instead of using the built in formula.

Solid Edge passes the material thickness, bend radius, bend angle and other
arguments to this function. You can use any or all of these values to compute the PZL

This sample has been built using Visual Studio 2010 and .Net 4.0.
The value you return for PZL must be > 0.000
All length values in this example are in millimeter units.

To register the DLL for use with Solid Edge in Windows Explorer double click on the file:


NOTE: You must have Administrator privileges to execute this routine. In some cases,
you may need to also need to Run As Administrator depending on your security

This will add the DLL to the system registry. (Turns it on so Solid Edge can use it)

The registration batch files under bin for registering and unregistering are used by the
above program and should not be removed. On Windows 8, the batch files cannot be
used directly as in Windows 7 due to heightened security in Windows 8.

Open a file in SE-Sheet Metal

- Select the Application button.
- On the Properties menu, click Material Table
- On the Material Table dialog, select a material
- On the Settings dropdown list, select Material Thickness (gage)
- set "Custom formula" option
- In the field key-in: TABLE.PZL
- Click Apply. The dialog box should disappear.

This connects the file to the custom VB DLL. Now, whenever the length of the bend in
the flat is needed Sheet Metal will call the PZL function defined in the DLL.
HINT: You can save a file with this setting as a document template so you do not have
to repeat this operation.

Modifying the sample

Using standard Visual Basic methodology, functions are created and stored in a DLL.
The calculations used to determine the PZL value are in the PZL function. You can
change the calculations by modifying this section of the VB code.

Should you modify the code, you will then need to rebuild the dll in a two step process:
1. From a Visual Studio Command Prompt window, run Build_Step_1.bat.
2. From a Visual Studio Command Prompt window, run Build_Step_2.bat. This
second build step pushes the type library into the pzl.dll.

Building your own Bend Equation sample

The argument function is paired with the executing function by a naming convention.
This function contains arguments which represent the objects from Solid Edge to be
used in the executing function.

Steps for Making the DLL

Refer to the provided sample for specifics and examples. Net DLLs require specific
definitions included in the code: InterfaceType and ClassInterface. You will need to
acquire and include GUIDs for the InterfaceType and ClassInterface. You will also need
to define a GUID for the AssemblyGUID. The AssemblyGUID defines the GUID for the
typelib of functions related to your DLL. Defining the above GUIDs in the project will
ensure that the class id, Interface id and typelib id of the custom sensor object will not
change every time the dll is built, and therefore will not require changes to the .reg file
(which implies re-registration) every time the dll is built.

The following steps should be followed in creating your own DLL. For convenience, we
will refer to files related to your project as yourDLL with the related extension. VB .Net
does not provide a simple approach for building a typelib into a DLL. However, this is
the preferred approach for developing a sensor. The steps outlined below describe the
process for building a sensor DLL with the typelib built in.

1. The first step is to get the three GUIDs you will want to include. Open a Visual
Studio Command Prompt window, cd to your project and type guidgen. This will
bring up a dialog that will allow you to define a unique QUID. Define three New
GUIDS. Copy and Paste them into a file that you can save for future reference.
Leave the Cmdprompt window open as you will need it later.
2. Add the GUIDs to you project code. Two of the GUIDs should be added directly in
yourDLL.vb as illustrated in the sample. The AssemblyGUID is added as a project
property. You can set this by going to the project properties Application tab,
selecting Assembly Information and pasting the third GUID in the GUID field. Do not
include the { brackets. While you are there, make sure to check the COM-
Visible checkbox. OK out of the Assembly options and save your project.

While in the Project settings, go to Compile and set the target to the desired output
target ; i.e. bin. Uncheck the Register for COM interop option. Go into
Advanced Compiler Options and set the Target CPU explicitly to x64. Do not
use the AnyCPU setting.

3. You will also want to define a strong name for yourDLL. While you are still in project
properties, select the Signing tab, select the Strong Name checkbox and on the
enabled dropdown list select new and follow the directions. You should end up
with a .snk file in your project with the name you provided. Save your project

4. Build your project the first time. It is highly recommended that you use the Visual
Studio IDE to build the DLL the first time as it will also create all the SE interops
required by your project. Be sure to set the MSBuild project output verbosity
= Normal in order to see the VBE string in the Output tab. To do this, go to
Debug\Options and Setting. On the dialog, go to Projects and Solutions/Build and

Building the project will also create a typelib file (i.e. yourDLL.tlb) which will be
needed later. Another reason for building with the IDE is that you can copy the VBC
command line that you will need later to build the typelib into your DLL. Go to the
Output tab of the IDE and copy the line that includes vbc.exe and paste it into the
file where you saved the GUIDs.

5. The IDE build will create the interops and yourDLL.dll in two locations: where ever
your compile target is set (in our sample and we will use bin as the target for the rest
of these steps for convenience) and under obj\Release. The TLB file is only
created in the bin folder.

6. You will next need to create a res file that will contain a reference to you typelib file.
To do this, first create a yourDLL.rc file in notepad that contains the following line:
1 typelib bin\yourDLL.tlb

NOTE: rc cannot properly interpret bin\Table.tlb. It has a problem

handling the \T. Name the tlb file to something slightly different (i.e.
CTable.tlb) and point your rc file to the copy.

7. In a CmdPrompt window type the following line and enter.

rc yourDLL.rc

This will create the yourDLL.res file that you will need in the next step.
8. You will want to create a batch file to handle the last two steps of the build process.
Create a batch file similar to build_step_2.bat in the sample.

9. Paste the vbc line from the first compile that you previously saved and add the
following two switches:
It probably does not matter where the /win32Resource switch is added, but most
examples show it added at the end.

10. The command line will rebuild the DLL under obj/Release but not the DLL under the
bin folder so you will want to copy the newly build yourDLL.dll to the bin folder with a
line similar to:
copy obj\release\yourDLL.dll bin\yourDLL.dll /y

11. Save the batch file and then run the batch file in the cmdprompt window. You will
now have a DLL with the typelib built in. You can confirm this by typing
oleview bin\yourDLL.dll
in the cmdprompt window. If the file has successfully included the typelib, the file will
open successfully and you will see your interface definitions.

Registering your Bend Equation in Solid Edge

The next step will be to register the DLL for use with Solid Edge. This will need to be
done in two steps. The first step is to register the DLL. The second step is to register
the TLB. For deployment you will want to create a batch file similar to the one provided
in the sample that includes the following two lines:
Regasm /codebase bin\yourDLL.dll
Regasm /tlb bin\yourDLL.dll

The first line registers the DLL and the second line registers the TLB contained in the

End of Sample