03 - SP3DNetAPI - LAB - Writing Commands
03 - SP3DNetAPI - LAB - Writing Commands
Net API
LAB
–
Writing Commands
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 1
LAB - Overview
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 2
Create a VB.Net Class Library Project
• Use Visual Studio
– VS2010 with .NET Framework v4.0 (from Smart 3D v2014).
– VS2013 with .NET Framework v4.5 (from Smart 3D v2016).
– Choose a .Net language VB.Net / C#
• VB.Net is preferred. Most samples are in VB.Net. Our examples will be VB.Net.
• Project Type
– Use a Windows “Class Library” project template
– Can create the new command in
• an existing Class Library project you already have with other commands you have
developed. Choose File Open Project
• a new Class Library Project Choose File New Project
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 3
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 4
Create a VB.Net Class Library Project
• It creates a Class1.vb
which has an empty class
named Class1.
• Rename the Name of the
class from Class1 to a
name of your choice and
also rename the
filename accordingly.
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 5
5. Browse to
Folder location
3. Click
“Browse” Tab
4. Click
“Browse” Button
1. Select CommonClient.DLL and CommonMiddle.DLL, which are required for writing a basic command.
2. Also add the following reference for Smart3D V2016.
“Smart3D\Core\Container\Bin\SxS\Intergraph\Intergraph.CommonToolkit.Client.dll“
3. You can choose other assemblies as needed for the functionality of the command.
4. Then Select “OK” Reference Manager dialog.
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 6
References : Copy Local setting
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 7
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 8
Inherit from a Base command class
– Modal, Suspendable,
EnableUIFlags
– OnStart( ), OnStop ( )
– OnSuspend( ), OnResume( )
(for suspendable commands)
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 9
Lets see next page why we don’t have to do any more overrides.
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 10
Override Required Implementation
• We don’t have any specific OnStop( ) implementation as there is
nothing specific we want to do at the moment when the command
is stopped.
– Typically, one would want to implement cleanup code in the OnStop( ).
– The BaseModalCommand class implementation of OnStop( ) is good enough
for our case and we don’t need to provide an OnStop( )
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 13
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 14
Debugging the Command
Approach #1:
Attach to an already running SP3D / SM3D process.
Approach #2:
Specify Executable to start which invokes the
Command class.
(details next)
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 15
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 17
• With this changes, system doesn’t start our command when the
command’s EnableUIFlags property (i.e. its prerequisite expectations)
does not conform to the system state at the time of invocation of the
command.
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 18
Final code – SampleModalCmd.
Imports Ingr.SP3D.Common.Client Public Overrides Sub OnStart(ByVal commandID As Integer, ByVal argument As Object)
Imports Ingr.SP3D.Common.Client.Services MyBase.OnStart(commandID, argument)
Imports Ingr.SP3D.Common.Middle 1 3
Imports Ingr.SP3D.Common.Middle.Services
Dim oSelectSet As SelectSet = ClientServiceProvider.SelectSet
Public Overrides ReadOnly Property Modal As Boolean We extend this lab little
Get to study how non-Modal,
Return False
End Get
Suspendable commands
End Property work.
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 19
Smart 3D .Net API Training – © 2018. Hexagon PPM. All Rights Reserved.
LAB – Writing Commands - 20