The notes below are intended to help with the transition from using PowerSolutionOLE ActiveX in VB6 to the PowerSolutionDOTNETOle DLL in VB.NET. The principals are the same if using C#.NET.
Note that the list below is only related to existing functionality in the ActiveX control. Check out the Class Library Documentation installed with the DLL for a full list of functionality available.
From the menus... Project -> Add Reference -> Browse The DLL consists of a number of classes
which you can access directly from code. There is no need to create an
instance of a particular class since the classes for linking to PowerSHAPE,
PowerMILL and CopyCAD contained SHARED (or STATIC) mehods. PowerSolutionDOTNetOLE.clsPowerSHAPEOLE So for example to connect to PowerSHAPE, you use... PowerSolutionDOTNetOLE.clsPowerSHAPEOLE.Connect Because its a shared class, you can now directly use the methods in this class
from any other form without have to use Connect. To reduce the amount of typing, you can declare a reference to the class in your
code, e.g. Dim PS As PowerSolutionDOTNetOLE.clsPowerSHAPEOLE Note you don't create a NEW object, its just a quick link to the main class,
e.g. you can now use... PS.Connect Also to give quicker access to the classes, you can add to the top of your
code... Imports PowerSolutionDOTNetOLE Then you can use for example... clsPowerSHAPEOLE.Connect or Dim PS As clsPowerSHAPEOLE clsPowerSHAPEOLE.Connect
clsPowerMILLOLE.Connect clsPowerMILLOLE.ConnectToNew clsPowerMILLOLE.StartAndConnectToPowerMILL clsPowerSHAPEOLE.Execute
Only available for PowerSHAPE, you use... PSHAPE.AddBatchCommand PSHAPE.ProcessBatch Now available for PowerSHAPE, PowerMILL and
CopyCAD. You use the same Execute method, except you can
add multiple commands separated by a comma, e.g.
clsPowerSHAPEOLE.Execute("CREATE LINE SINGLE", "0 0
0", "10 0 0", "SELECT") For PowerSHAPE, use the IsPSConnected
function For PowerSHAPE, use the SetDialogMode. clsPowerSHAPEOLE.Evaluate For PowerSHAPE, you can also use the clsEntityType class
to readily get object information, e.g. PMILL.BlockDefined Many of these functions have been
consolidated into general functions... Get entity size - clsPowerMILLOLE.GetEntitySize
passing in the required entity type. This function will return the sizes,
or False if the entity does not exist. So you also use this function to
determine if an entity exists, e.g. the block or model. Get full list of entity parameter
information... You can then search for specific settings
within this array by using the clsPowerMILLOLE.ParseParameterInfoForSetting
method, e.g. This will get the tolerance and tool diameter used for a
toolpath... Dim Params() As String =
PM.GetEntityParameterInfo(clsPowerMILLOLE.enumPowerMILLEntityType.pmToolpath,
"1") Check out the PowerMILL_Example1
sample for more ways to extract entity information and parameters. The extraction of information from
PowerSHAPE has been simplified and is based on the clsEntityType class.
Check out the Class Library Documentation for the full list of available
methods in this class. clspowershapeole.GetSelectedEntities
- you optionally add specific entity types to extract from the list. e.g. to get the names of all entities selected, you can use... Dim a() As clsEntityType
VB6
VB.NET
Adding the Reference
From the menus...
Project -> Components -> BROWSE
Select the PowerSolutionOLE.OCX file and ensure it is checked in the Available
References list.
The objects are then added to the toolbox.
Browse for and select the DLL (usually installed to
C:\Program Files\Delcam PLC\PowerSolutionDOTNetOLE API
Classes\PowerSolutionDOTNetOLE.dll)
Creating Objects
In VB6, the OLE links are Objects which
you add to a form. The difficulty with this method, is that if you have
multiple forms requiring OLE links to products, you have to add the object to
multiple forms. Each object working independantly.
Once you have added an object to your form you can access the methods within
that object.
This means you can use the classes from any form or class in your application
directly, and you are always using the same OLE connection.
So you can these shared classes directly using for example...
Connecting
PSHAPE.Connect
Executing Commands
PSHAPE.Execute
Executing Multiple Commands
Checking Connection
Use the Connectedfunction.
For PowerMILL and CopyCAD, use the IsConnectedfunction.
Turn off Popup dialogs
Use the Dialogs function.
For PowerMILL and CopyCAD, use the DialogsOff and DialogsOnfunctions.
Getting information
PSHAPE.Evaluate
PMILL.ExecuteEx
clsPowerMILLOLE.ExecuteEx
clsCopyCADOLE.ExecuteAndReturnCMDLine
Dim a as New clsEntityType("1", enum_EntityType.Surface)
Dim NumLats As Integer = a.GetObjectInfo("NLATS")
Getting PowerMILL information
PMILL.BlockSize
PMILL.GetPatternList
PMILL.GetWorkplaneList
PMILL.GetToolpathList
PMILL.IsModelLoaded
PMILL.ModelSize
PMILL.SizeToolpath
PMILL.StoreBlock
PMILL.StoreModel
PMILL.Units
Entity Lists - use clsPowerMILLOLE.GetEntityList passing in
the required entity type, e.g.
Dim Num As Integer, List() As String, Active As String clsPowerMILLOLE.GetEntityList(clsPowerMILLOLE.enumPowerMILLEntityType.pmTool,
Num, List, Active)
Get active entity name -
clsPowerMILLOLE.GetActiveGetActiveEntityName passing in the
required entity type.
You can use the clsPowerMILLOLE.GetLastCreatedEntityName function
to find the last entity name in the list quickly.
use the clsPowerMILLOLE.GetEntityParameterInfo function.
This returns an array of parameters.
Dim Tol As Double = PM.ParseParameterInfoForSetting(Params,
":dmkMcParFinCommon", "TOLERANCE",
clsPowerMILLOLE.enumEntitySettingDataType.parDouble)
Dim Dia As Double = PM.ParseParameterInfoForSetting(Params, ":dmkMcParTool",
"DIAMETER", clsPowerMILLOLE.enumEntitySettingDataType.parDouble)
txtToolDia.Text = Dia.ToString("0.####")
Getting PowerSHAPE information
PSHAPE.GetCreatedEntities
PSHAPE.GetFilteredSelection
PSHAPE.GetModifiedEntities
PSHAPE.GetSelectedEntities
PSHAPE.ItemsCretedCount
PSHAPE.ItemsModifiedCount
PSHAPE.ItemsSelectedCount
To extract list of entities in various lists...
clspowershapeole.GetCreatedEntities
a = clsPowerSHAPEOLE.GetSelectedEntities()
If a Is Nothing Then
Msgbox("Nothing selected")
Else
Dim i As Integer
For i = 0 To a.Length-1
Msgbox a(i).Name
Next
End If