Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX Journal and Block UI Styler combination

Status
Not open for further replies.

Soyasauce

Aerospace
Apr 18, 2017
4
Hi all, with the help of ufsure, I've learnt to combined a journal code with the UI Block Styler so as to retrieve the input co-ordinate values from the block dialog into my journal code.

The code was changed from

NXOpen.Point3d originPoint1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, "100", "100", "100");

to

NXOpen.Point3d originPoint1 = new NXOpen.Point3d(coOrds[0], coOrds[1], coOrds[2]);
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, "100", "100", "100");


This allowed me to change the co-ordinate to where the block will be created at.
Now i am trying to retrieve values to change the dimension of the block but am unable to succeed.

How do i convert the value into a string so that it can be used to replaced "100" ?


Below attached is my code :


//==============================================================================
// WARNING!! This file is overwritten by the Block UI Styler while generating
// the automation code. Any modifications to this file will be lost after
// generating the code again.
//
// Filename: C:\Users\MTS PG 6\Desktop\BlockDialog2.cs
//
// This file was generated by the NX Block UI Styler
// Created by: MTS PG 6
// Version: NX 10
// Date: 04-21-2017 (Format: mm-dd-yyyy)
// Time: 11:20 (Format: hh-mm)
//
//==============================================================================

//==============================================================================
// Purpose: This TEMPLATE file contains C# source to guide you in the
// construction of your Block application dialog. The generation of your
// dialog file (.dlx extension) is the first step towards dialog construction
// within NX. You must now create a NX Open application that
// utilizes this file (.dlx).
//
// The information in this file provides you with the following:
//
// 1. Help on how to load and display your Block UI Styler dialog in NX
// using APIs provided in NXOpen.BlockStyler namespace
// 2. The empty callback methods (stubs) associated with your dialog items
// have also been placed in this file. These empty methods have been
// created simply to start you along with your coding requirements.
// The method name, argument list and possible return values have already
// been provided for you.
//==============================================================================

//------------------------------------------------------------------------------
//These imports are needed for the following template code
//------------------------------------------------------------------------------
using System;
using NXOpen;
using NXOpen.BlockStyler;

//------------------------------------------------------------------------------
//Represents Block Styler application class
//------------------------------------------------------------------------------
public class BlockDialog2
{
//class members
private static Session theSession = null;
private static UI theUI = null;
private string theDlxFileName;
private NXOpen.BlockStyler.BlockDialog theDialog;
private NXOpen.BlockStyler.Group group0;// Block type: Group
private NXOpen.BlockStyler.IntegerBlock integer0;// Block type: Integer
private NXOpen.BlockStyler.IntegerBlock integer01;// Block type: Integer
private NXOpen.BlockStyler.IntegerBlock integer02;// Block type: Integer
private NXOpen.BlockStyler.Group group01;// Block type: Group
private NXOpen.BlockStyler.LinearDimension linear_dim0;// Block type: Linear Dim
private NXOpen.BlockStyler.LinearDimension linear_dim01;// Block type: Linear Dim
private NXOpen.BlockStyler.LinearDimension linear_dim02;// Block type: Linear Dim
//------------------------------------------------------------------------------
//Bit Option for Property: SnapPointTypesOnByDefault
//------------------------------------------------------------------------------
public static readonly int SnapPointTypesOnByDefault_UserDefined = (1 << 0);
public static readonly int SnapPointTypesOnByDefault_Inferred = (1 << 1);
public static readonly int SnapPointTypesOnByDefault_ScreenPosition = (1 << 2);
public static readonly int SnapPointTypesOnByDefault_EndPoint = (1 << 3);
public static readonly int SnapPointTypesOnByDefault_MidPoint = (1 << 4);
public static readonly int SnapPointTypesOnByDefault_ControlPoint = (1 << 5);
public static readonly int SnapPointTypesOnByDefault_Intersection = (1 << 6);
public static readonly int SnapPointTypesOnByDefault_ArcCenter = (1 << 7);
public static readonly int SnapPointTypesOnByDefault_QuadrantPoint = (1 << 8);
public static readonly int SnapPointTypesOnByDefault_ExistingPoint = (1 << 9);
public static readonly int SnapPointTypesOnByDefault_PointonCurve = (1 <<10);
public static readonly int SnapPointTypesOnByDefault_PointonSurface = (1 <<11);
public static readonly int SnapPointTypesOnByDefault_PointConstructor = (1 <<12);
public static readonly int SnapPointTypesOnByDefault_TwocurveIntersection = (1 <<13);
public static readonly int SnapPointTypesOnByDefault_TangentPoint = (1 <<14);
public static readonly int SnapPointTypesOnByDefault_Poles = (1 <<15);
public static readonly int SnapPointTypesOnByDefault_BoundedGridPoint = (1 <<16);
public static readonly int SnapPointTypesOnByDefault_FacetVertexPoint = (1 <<17);

//------------------------------------------------------------------------------
//Constructor for NX Styler class
//------------------------------------------------------------------------------
public BlockDialog2()
{
try
{
theSession = Session.GetSession();
theUI = UI.GetUI();
theDlxFileName = "BlockDialog2.dlx";
theDialog = theUI.CreateDialog(theDlxFileName);
theDialog.AddApplyHandler(new NXOpen.BlockStyler.BlockDialog.Apply(apply_cb));
theDialog.AddOkHandler(new NXOpen.BlockStyler.BlockDialog.Ok(ok_cb));
theDialog.AddUpdateHandler(new NXOpen.BlockStyler.BlockDialog.Update(update_cb));
theDialog.AddInitializeHandler(new NXOpen.BlockStyler.BlockDialog.Initialize(initialize_cb));
theDialog.AddDialogShownHandler(new NXOpen.BlockStyler.BlockDialog.DialogShown(dialogShown_cb));
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
throw ex;
}
}
//------------------------------- DIALOG LAUNCHING ---------------------------------
//
// Before invoking this application one needs to open any part/empty part in NX
// because of the behavior of the blocks.
//
// Make sure the dlx file is in one of the following locations:
// 1.) From where NX session is launched
// 2.) $UGII_USER_DIR/application
// 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
// recommended. This variable is set to a full directory path to a file
// containing a list of root directories for all custom applications.
// e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
//
// You can create the dialog using one of the following way:
//
// 1. Journal Replay
//
// 1) Replay this file through Tool->Journal->Play Menu.
//
// 2. USER EXIT
//
// 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
// 2) Invoke the Shared Library through File->Execute->NX Open menu.
//
//------------------------------------------------------------------------------
public static void Main()
{
BlockDialog2 theBlockDialog2 = null;
try
{
theBlockDialog2 = new BlockDialog2();
// The following method shows the dialog immediately
theBlockDialog2.Show();
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
finally
{
if(theBlockDialog2 != null)
theBlockDialog2.Dispose();
theBlockDialog2 = null;
}
}
//------------------------------------------------------------------------------
// This method specifies how a shared image is unloaded from memory
// within NX. This method gives you the capability to unload an
// internal NX Open application or user exit from NX. Specify any
// one of the three constants as a return value to determine the type
// of unload to perform:
//
//
// Immediately : unload the library as soon as the automation program has completed
// Explicitly : unload the library from the "Unload Shared Image" dialog
// AtTermination : unload the library when the NX session terminates
//
//
// NOTE: A program which associates NX Open applications with the menubar
// MUST NOT use this option since it will UNLOAD your NX Open application image
// from the menubar.
//------------------------------------------------------------------------------
public static int GetUnloadOption(string arg)
{
//return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);
return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
// return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
}

//------------------------------------------------------------------------------
// Following method cleanup any housekeeping chores that may be needed.
// This method is automatically called by NX.
//------------------------------------------------------------------------------
public static void UnloadLibrary(string arg)
{
try
{
//---- Enter your code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//This method shows the dialog on the screen
//------------------------------------------------------------------------------
public NXOpen.UIStyler.DialogResponse Show()
{
try
{
theDialog.Show();
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}

//------------------------------------------------------------------------------
//Method Name: Dispose
//------------------------------------------------------------------------------
public void Dispose()
{
if(theDialog != null)
{
theDialog.Dispose();
theDialog = null;
}
}

//------------------------------------------------------------------------------
//---------------------Block UI Styler Callback Functions--------------------------
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//Callback Name: initialize_cb
//------------------------------------------------------------------------------
public void initialize_cb()
{
try
{
group0 = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("group0");
integer0 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer0");
integer01 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer01");
integer02 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer02");
group01 = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("group01");
linear_dim0 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim0");
linear_dim01 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim01");
linear_dim02 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim02");
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//Callback Name: dialogShown_cb
//This callback is executed just before the dialog launch. Thus any value set
//here will take precedence and dialog will be launched showing that value.
//------------------------------------------------------------------------------
public void dialogShown_cb()
{
try
{
//---- Enter your callback code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//Callback Name: apply_cb
//------------------------------------------------------------------------------
public int apply_cb()
{
int errorCode = 0;
try
{
double[] coOrds = new double[3];

coOrds[0] = (double)integer0.Value;
coOrds[1] = (double)integer01.Value;
coOrds[2] = (double)integer02.Value;

double[] dimension = new double[3];

dimension[0] = (double)linear_dim0.Value;
dimension[1] = (double)linear_dim01.Value;
dimension[2] = (double)linear_dim02.Value;

CreateBlock(coOrds);
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
errorCode = 1;
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return errorCode;
}

//------------------------------------------------------------------------------
//Callback Name: update_cb
//------------------------------------------------------------------------------
public int update_cb( NXOpen.BlockStyler.UIBlock block)
{
try
{
if(block == integer0)
{
//---------Enter your code here-----------
}
else if(block == integer01)
{
//---------Enter your code here-----------
}
else if(block == integer02)
{
//---------Enter your code here-----------
}
else if(block == linear_dim0)
{
//---------Enter your code here-----------
}
else if(block == linear_dim01)
{
//---------Enter your code here-----------
}
else if(block == linear_dim02)
{
//---------Enter your code here-----------
}
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}

//------------------------------------------------------------------------------
//Callback Name: ok_cb
//------------------------------------------------------------------------------
public int ok_cb()
{
int errorCode = 0;
try
{
errorCode = apply_cb();
//---- Enter your callback code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
errorCode = 1;
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return errorCode;
}

//------------------------------------------------------------------------------
//Function Name: GetBlockProperties
//Returns the propertylist of the specified BlockID
//------------------------------------------------------------------------------
public PropertyList GetBlockProperties(string blockID)
{
PropertyList plist =null;
try
{
plist = theDialog.GetBlockProperties(blockID);
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return plist;
}

public void CreateBlock(double[] coOrds)
{
NXOpen.Session theSession = NXOpen.Session.GetSession();
NXOpen.Part workPart = theSession.Parts.Work;
NXOpen.Part displayPart = theSession.Parts.Display;

NXOpen.Features.Feature nullNXOpen_Features_Feature = null;

NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1;
blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullNXOpen_Features_Feature);

NXOpen.Point3d originPoint1 = new NXOpen.Point3d(coOrds[0], coOrds[1], coOrds[2]);
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, "100", "100", "100");

NXOpen.Features.Feature feature1;
feature1 = blockFeatureBuilder1.CommitFeature();
}

}


Thank you in advance for the help ! Much appreciated !
 
Replies continue below

Recommended for you

Code:
int x = 100;
string expression = x.ToString();
 
Hi
A long time ago I wrote a program that uses a block styler
And I'm lazy to review my code and reduce it to a short and simple program
so I present the program as it is and I believe you will know how to
pull out what you want from it.

Code:
'==============================================================================
'  WARNING!!  This file is overwritten by the Block Styler while generating
'  the automation code. Any modifications to this file will be lost after
'  generating the code again.
'
'       Filename:  C:\HoneyCombHolesSketch.vb
'
'        This file was generated by the NX Block Styler
'        Created by: Internet
'              Version: NX 6
'              Date: 04-28-2014  (Format: mm-dd-yyyy)
'              Time: 19:34 (Format: hh-mm)
'
'==============================================================================

'==============================================================================
'  Purpose:  This TEMPLATE file contains VB.NET source to guide you in the
'  construction of your Block application dialog. The generation of your
'  dialog file (.dlx extension) is the first step towards dialog construction
'  within NX.  You must now create a NX Open application that
'  utilizes this file (.dlx).
'
'  The information in this file provides you with the following:
'
'  1.  Help on how to load and display your Block Styler dialog in NX
'      using APIs provided in NXOpen.BlockStyler namespace
'  2.  The empty callback methods (stubs) associated with your dialog items
'      have also been placed in this file. These empty methods have been
'      created simply to start you along with your coding requirements.
'      The method name, argument list and possible return values have already
'      been provided for you.
'==============================================================================

'------------------------------------------------------------------------------
'These imports are needed for the following template code
'------------------------------------------------------------------------------
Option Strict Off
Imports System
Imports System.Environment
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.BlockStyler

'------------------------------------------------------------------------------
'Represents Block Styler application class
'------------------------------------------------------------------------------
Public Class HoneyCombROCEPatterns
    'class members
    Private Shared theSession As Session
    Private Shared theUI As UI
    Public Shared theHoneyCombROCEPatterns As HoneyCombROCEPatterns
    Private theDialogName As String
    Private theDialog As NXOpen.BlockStyler.BlockDialog
    Private grpOptions As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private SelectOption As NXOpen.BlockStyler.UIBlock' Block type: Enumeration
    Private grpType As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private SelectPatternType As NXOpen.BlockStyler.UIBlock' Block type: Enumeration
    Private grpSpecifyPoint As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private SelectPoint As NXOpen.BlockStyler.UIBlock' Block type: Specify Point
    Private grpSpecifyOrientation As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private SelectManip As NXOpen.BlockStyler.UIBlock' Block type: Specify Orientation
    Private grpData As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private DataHoneyCombW As NXOpen.BlockStyler.UIBlock' Block type: Double
    Private DataHoneyCombH As NXOpen.BlockStyler.UIBlock' Block type: Double
    Private DataHole As NXOpen.BlockStyler.UIBlock' Block type: Double
    Private DataSpace As NXOpen.BlockStyler.UIBlock' Block type: Double
    Private QTYholes As NXOpen.BlockStyler.UIBlock' Block type: Integer
    Private DataAdjut As NXOpen.BlockStyler.UIBlock' Block type: Double
    Private DataLabel As NXOpen.BlockStyler.UIBlock' Block type: Label
    '------------------------------------------------------------------------------
    'Bit Option for Property: SnapPointTypesEnabled
    '------------------------------------------------------------------------------
    Public Shared ReadOnly              SnapPointTypesEnabled_UserDefined =     1
    Public Shared ReadOnly                 SnapPointTypesEnabled_Inferred =     2
    Public Shared ReadOnly           SnapPointTypesEnabled_ScreenPosition =     4
    Public Shared ReadOnly                 SnapPointTypesEnabled_EndPoint =     8
    Public Shared ReadOnly                 SnapPointTypesEnabled_MidPoint =    16
    Public Shared ReadOnly             SnapPointTypesEnabled_ControlPoint =    32
    Public Shared ReadOnly             SnapPointTypesEnabled_Intersection =    64
    Public Shared ReadOnly                SnapPointTypesEnabled_ArcCenter =   128
    Public Shared ReadOnly            SnapPointTypesEnabled_QuadrantPoint =   256
    Public Shared ReadOnly            SnapPointTypesEnabled_ExistingPoint =   512
    Public Shared ReadOnly             SnapPointTypesEnabled_PointonCurve =  1024
    Public Shared ReadOnly           SnapPointTypesEnabled_PointonSurface =  2048
    Public Shared ReadOnly         SnapPointTypesEnabled_PointConstructor =  4096
    Public Shared ReadOnly     SnapPointTypesEnabled_TwocurveIntersection =  8192
    Public Shared ReadOnly             SnapPointTypesEnabled_TangentPoint = 16384
    Public Shared ReadOnly                    SnapPointTypesEnabled_Poles = 32768
    '------------------------------------------------------------------------------
    'Bit Option for Property: SnapPointTypesOnByDefault
    '------------------------------------------------------------------------------
    Public Shared ReadOnly          SnapPointTypesOnByDefault_UserDefined =     1
    Public Shared ReadOnly             SnapPointTypesOnByDefault_Inferred =     2
    Public Shared ReadOnly       SnapPointTypesOnByDefault_ScreenPosition =     4
    Public Shared ReadOnly             SnapPointTypesOnByDefault_EndPoint =     8
    Public Shared ReadOnly             SnapPointTypesOnByDefault_MidPoint =    16
    Public Shared ReadOnly         SnapPointTypesOnByDefault_ControlPoint =    32
    Public Shared ReadOnly         SnapPointTypesOnByDefault_Intersection =    64
    Public Shared ReadOnly            SnapPointTypesOnByDefault_ArcCenter =   128
    Public Shared ReadOnly        SnapPointTypesOnByDefault_QuadrantPoint =   256
    Public Shared ReadOnly        SnapPointTypesOnByDefault_ExistingPoint =   512
    Public Shared ReadOnly         SnapPointTypesOnByDefault_PointonCurve =  1024
    Public Shared ReadOnly       SnapPointTypesOnByDefault_PointonSurface =  2048
    Public Shared ReadOnly     SnapPointTypesOnByDefault_PointConstructor =  4096
    Public Shared ReadOnly SnapPointTypesOnByDefault_TwocurveIntersection =  8192
    Public Shared ReadOnly         SnapPointTypesOnByDefault_TangentPoint = 16384
    Public Shared ReadOnly                SnapPointTypesOnByDefault_Poles = 32768

    'my class members
    Dim PointOnface As Boolean = False
    Dim Manipulator As Boolean = False
    Dim applyin As Boolean = False

    Dim None As Boolean = False
    Dim Rectangular As Boolean = False
    Dim needDeleteRectangular As Boolean = False
    Dim Oval As Boolean = False
    Dim needDeleteOval As Boolean = False
    Dim Circular As Boolean = False
    Dim needDeleteCircular As Boolean = False
    Dim Elliptic As Boolean = False
    Dim needDeleteElliptic As Boolean = False

    Dim ufs As UFSession
    Dim facetag As Tag = Tag.Null
    Dim myPointTag As Tag = Tag.Null
    Dim cp(2) As Double
    Dim origin1 As Point3d
    Dim matrix1 As Matrix3x3
    Dim Honeycomb_Y As Double
    Dim Honeycomb_X As Double
    Dim holesDia As Double
    Dim holesSpace As Double
    Dim adjustment As Double                             
    Dim arcs(-1) As Arc
    Dim arc_ref As Arc = Nothing
    Dim ellipse_ref As Ellipse = Nothing
    Dim oval_ref_1 As Line = Nothing
    Dim oval_ref_2 As Arc = Nothing
    Dim oval_ref_3 As Line = Nothing
    Dim oval_ref_4 As Arc = Nothing
    Dim rect_ref_1 As Line = Nothing
    Dim rect_ref_2 As Line = Nothing
    Dim rect_ref_3 As Line = Nothing
    Dim rect_ref_4 As Line = Nothing
    Dim arcs_cnt As Integer
    Dim refs_cnt As Integer
    Dim geom2_cnt As Integer
    Dim needDelete As Boolean = False
    Dim wp_wcs_matrix3x3 As Matrix3x3
    Dim wp_wcs_origin As Point3d
    
#Region "Block Styler Dialog Designer generator code"
    '------------------------------------------------------------------------------
    'Constructor for NX Styler class
    '------------------------------------------------------------------------------
    Public Sub New()
        Try
        
            ufs = UFSession.GetUFSession()        
            theSession = Session.GetSession()
            theUI = UI.GetUI()
            theDialogName = "C:\HoneyCombROCEPatterns3.dlx"
            theDialog = theUI.CreateDialog(theDialogName)
            theDialog.AddApplyHandler(AddressOf apply_cb)
            theDialog.AddOkHandler(AddressOf ok_cb)
            theDialog.AddUpdateHandler(AddressOf update_cb)
            theDialog.AddCancelHandler(AddressOf cancel_cb)
            theDialog.AddInitializeHandler(AddressOf initialize_cb)
            theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
            Throw ex
        End Try
    End Sub
#End Region
    
    '------------------------------- DIALOG LAUNCHING ---------------------------------
    '
    '    Before invoking this application one needs to open any part/empty part in NX
    '    because of the behavior of the blocks.
    '
    '    Make sure the dlx file is in one of the following locations:
    '        1.) From where NX session is launched
    '        2.) $UGII_USER_DIR/application
    '        3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
    '            recommended. This variable is set to a full directory path to a file 
    '            containing a list of root directories for all custom applications.
    '            e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
    '
    '    You can create the dialog using one of the following way:
    '
    '    1. Journal Replay
    '
    '        1) Replay this file through Tool->Journal->Play Menu.
    '
    '    2. USER EXIT
    '
    '        1) Create the Shared Library -- Refer "Block Styler programmer's guide"
    '        2) Invoke the Shared Library through File->Execute->NX Open menu.
    '
    '------------------------------------------------------------------------------
    Public Shared Sub Main()

      Dim ui As UI = UI.GetUI()
      Dim theSession As Session = Session.GetSession()
      Dim workPart As Part = theSession.Parts.Work
      Dim wp_wcs_origin As Point3d = workPart.WCS.Origin
      Dim wp_wcs_matrix3x3 As Matrix3x3 = workPart.WCS.CoordinateSystem.Orientation.Element

        'ui.NXMessageBox.Show("Information",NXMessageBox.DialogType.Information, _
                                                '"*** Helo HoneyCombROCEPatterns ***")
        Try
        
            theHoneyCombROCEPatterns = New HoneyCombROCEPatterns()
            theHoneyCombROCEPatterns.wp_wcs_origin = wp_wcs_origin
            theHoneyCombROCEPatterns.wp_wcs_matrix3x3 = wp_wcs_matrix3x3 

            ' The following method shows the dialog immediately
            theHoneyCombROCEPatterns.Show()

        'ui.NXMessageBox.Show("Information",NXMessageBox.DialogType.Information, _
                                                '"*** Bye HoneyCombROCEPatterns ***")
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        Finally
            theHoneyCombROCEPatterns.Dispose()
        End Try
    End Sub
    '------------------------------------------------------------------------------
    ' This method specifies how a shared image is unloaded from memory
    ' within NX. This method gives you the capability to unload an
    ' internal NX Open application or user  exit from NX. Specify any
    ' one of the three constants as a return value to determine the type
    ' of unload to perform:
    '
    '
    '    Immediately : unload the library as soon as the automation program has completed
    '    Explicitly  : unload the library from the "Unload Shared Image" dialog
    '    AtTermination : unload the library when the NX session terminates
    '
    '
    ' NOTE:  A program which associates NX Open applications with the menubar
    ' MUST NOT use this option since it will UNLOAD your NX Open application image
    ' from the menubar.
    '------------------------------------------------------------------------------
    Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
        'Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
         Return CType(Session.LibraryUnloadOption.Immediately, Integer)
        ' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
    End Function
    '------------------------------------------------------------------------------
    ' Following method cleanup any housekeeping chores that may be needed.
    ' This method is automatically called by NX.
    '------------------------------------------------------------------------------
    Public Shared Function UnloadLibrary(ByVal arg As String) As Integer
        Try
        
            Return 0
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Function
    
    '------------------------------------------------------------------------------
    'This method shows the dialog on the screen
    '------------------------------------------------------------------------------
    Public Sub Show()
        Try
        
            theDialog.Show
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             'theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub
    
    '------------------------------------------------------------------------------
    'Method Name: Dispose
    '------------------------------------------------------------------------------
    Public Sub Dispose()
        If theDialog IsNot Nothing Then 
            theDialog.Dispose()
            theDialog = Nothing
        End If
    End Sub
    
    '------------------------------------------------------------------------------
    '---------------------Block Styler Callback Functions--------------------------
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    'Callback Name: initialize_cb
    '------------------------------------------------------------------------------
    Public Sub initialize_cb()
        Try
        
            grpOptions = theDialog.TopBlock.FindBlock("grpOptions")
            SelectOption = theDialog.TopBlock.FindBlock("SelectOption")
            grpType = theDialog.TopBlock.FindBlock("grpType")
            SelectPatternType = theDialog.TopBlock.FindBlock("SelectPatternType")
            grpSpecifyPoint = theDialog.TopBlock.FindBlock("grpSpecifyPoint")
            SelectPoint = theDialog.TopBlock.FindBlock("SelectPoint")
            grpSpecifyOrientation = theDialog.TopBlock.FindBlock("grpSpecifyOrientation")
            SelectManip = theDialog.TopBlock.FindBlock("SelectManip")
            grpData = theDialog.TopBlock.FindBlock("grp4")
            DataHoneyCombW = theDialog.TopBlock.FindBlock("DataHoneyCombW")
            DataHoneyCombH = theDialog.TopBlock.FindBlock("DataHoneyCombH")
            DataHole = theDialog.TopBlock.FindBlock("DataHole")
            DataSpace = theDialog.TopBlock.FindBlock("DataSpace")
            QTYholes = theDialog.TopBlock.FindBlock("QTYholes")
            DataAdjut = theDialog.TopBlock.FindBlock("DataAdjut")
            DataLabel = theDialog.TopBlock.FindBlock("DataLabel")

            DataHoneyCombW.GetProperties.SetLogical("Enable",False)        
            DataHoneyCombH.GetProperties.SetLogical("Enable",False)        
            DataHole.GetProperties.SetLogical("Enable",False)
            DataSpace.GetProperties.SetLogical("Enable",False)
            DataAdjut.GetProperties.SetLogical("Enable",False)
            SelectOption.GetProperties.SetEnumAsString("Value","XY Plane By Default WCS")
            SelectPatternType.GetProperties.SetEnumAsString("Value","None")

        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub
    
    '------------------------------------------------------------------------------
    'Callback Name: dialogShown_cb
    'This callback is executed just before the dialog launch. Thus any value set 
    'here will take precedence and dialog will be launched showing that value. 
    '------------------------------------------------------------------------------
    Public Sub dialogShown_cb()
        Try
        
            '---- Enter your callback code here -----
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub
    
    '------------------------------------------------------------------------------
    'Callback Name: apply_cb
    '------------------------------------------------------------------------------
    Public Function apply_cb() As Integer
        Try
        
            '---- Enter your callback code here -----

        Dim rnd1 As New Random()
        Dim str(20) As String
        Dim i As Integer
        Dim ui As UI = UI.GetUI()

        'i = rnd1.Next(1,20)
        str(0) = "*** To create PATTERN Sketch Click OK ***"
        'str(1) = "*** You have not Enough IQ to use this program ***"
        'str(2) = "*** Your computer is older than you ***"
        'str(3) = "*** Get off me ***"
        'str(4) = "*** I'm tired Is it possible to put off until tomorrow ***"
        'str(5) = "*** I forgot what I should do  ***"
        'str(6) = "*** You have not paid your taxes ***"
        'str(7) = "*** Go look for your friends ***"
        'str(8) = "*** It is hard for me, I will take it to a friend ***"
        'str(9) = "*** You're wasting your time ***"
        'str(10) = "*** Do you have nothing more useful to do ? ***"
        'str(11) = "*** Go complain to the programmer ***"
        'str(12) = "*** Dream that I will do it ***"
        'str(13) = "*** You happy ah ? ***"
        'str(14) = "*** Call me tomorrow and see what we can do ***"
        'str(15) = "*** The programmer does not know how to solve this ***"
        'str(16) = "*** Let me think what to do with it ***"
        'str(17) = "*** What happens a lot of time not heard from you ***"
        'str(18) = "*** Zumzum what do you want ***"
        'str(19) = "*** Every other day is OK but not today ***"
        'str(20) = "*** The code you entered is incorrect ***"

     If Not PointOnface And Not Manipulator Then
        ui.NXMessageBox.Show("Information",NXMessageBox.DialogType.Information,str(0))
     End If
       
        If needDelete Then
          DeletHoneyComb()
        End If

        Catch ex As Exception
            Return 0
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        apply_cb = 0
    End Function
    
    '------------------------------------------------------------------------------
    'Callback Name: update_cb
    '------------------------------------------------------------------------------
    Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
        Try
        
            If block Is SelectOption Then
            '---- Enter your code here -----

              Apply_SelectOption()


            ElseIf block Is SelectPatternType Then
            '---- Enter your code here -----

              Apply_SelectPatternType()

            
            ElseIf block Is SelectPoint Then
            '---- Enter your code here --------

              Apply_SelectPoint()

            
            ElseIf block Is SelectManip Then
            '---- Enter your code here ---------

              Apply_SelectManip()


            ElseIf block Is DataHoneyCombW Then
            '---- Enter your code here ---------
            
            ElseIf block Is DataHoneyCombH Then
            '---- Enter your code here ---------
            
            ElseIf block Is DataHole Then
            '---- Enter your code here ---------
            
            ElseIf block Is DataSpace Then
            '---- Enter your code here ---------

            
            ElseIf block Is QTYholes Then
            '---- Enter your code here -----

            Dim QTYholesPL As PropertyList = QTYholes.GetProperties() 
            QTYholesPL.SetInteger("Value",(arcs_cnt+1).ToString())
            QTYholesPL.Dispose()
            QTYholesPL = Nothing

            ElseIf block Is DataAdjut Then
            '---- Enter your code here ---------

              Apply_DataAdjut()


            ElseIf block Is DataLabel Then
            '---- Enter your code here -----


            End If
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        update_cb = 0
    End Function
    
    '------------------------------------------------------------------------------
    'Callback Name: ok_cb
    '------------------------------------------------------------------------------
    Public Function ok_cb() As Integer
        Try
        
            '---- Enter your callback code here -----

            Apply_Data( )
            CreatHoneyCombSketch()
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        ok_cb = 0
    End Function
    
    '------------------------------------------------------------------------------
    'Callback Name: cancel_cb
    '------------------------------------------------------------------------------
    Public Function cancel_cb() As Integer
        Try
        
            '---- Enter your callback code here -----
           
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        cancel_cb = 0
    End Function
 
'==================================================================================== 
'***************************    - MY ROUTINES -    **********************************
'==================================================================================== 
 Function GetPointParentFace(ByVal objTag As Tag) As Face
 
  Dim n_parents As Integer
  Dim parentTags As Tag()
  Dim myFace As Face

  Try
   ufs.So.AskParents(objTag, UFConstants.UF_SO_ASK_ALL_PARENTS, n_parents, parentTags)
   For Each parentTag As Tag In parentTags
    Dim parent_object As TaggedObject = Utilities.NXObjectManager.Get(parentTag)
    If parent_object.ToString.ToLower.Contains("face") Then
      myFace = parent_object
    End If
   Next
 
  Catch ex As Exception
    ' NXOpen.NXException: Current object is not smart
    'MessageBox.Show(" Error: " + ex.Message + NewLine _
                      ' + "    " + myTaggedObject.GetType.ToString)
  End Try
  
  GetPointParentFace = myFace
 
 End Function
'------------------------------------------------------------------------------------ 
    
 Public Function SetWcsByFaceUAndNormalAtPoint(ByVal face As Tag, ByRef origin() As Double)

  Dim mx As Tag
  Dim wcs As Tag

  Dim csys(8) As Double
  Dim xuv_csys(2) As Double
  Dim yuv_csys(2) As Double
  Dim zuv_csys(2) As Double
  Dim v1(2),u2(2),v2(2) As Double
  Dim mag As Double
  Dim parm(1) As Double
  Dim pnt(2) As Double
  Dim tol As Double
  Dim x_dir(2) As Double
  Dim y_dir(2) As Double
  Dim z_dir(2) As Double
  Dim radii(1) As Double
  Dim i As Integer

  ufs.Modl.AskDistanceTolerance(tol)

  ufs.Modl.AskFaceParm(face, Origin, parm, pnt)
  ufs.Modl.AskFaceProps(face, parm, pnt, x_dir, v1, u2, v2, Z_dir, radii)

  ufs.Vec3.Cross(Z_dir, x_dir, y_dir)

  ufs.Vec3.Unitize(x_dir, tol, mag, xuv_csys)
  ufs.Vec3.Unitize(y_dir, tol, mag, yuv_csys)
  ufs.Vec3.Unitize(z_dir, tol, mag, zuv_csys)
  For i=0 To 2
   csys(0+i) = xuv_csys(i)
   csys(3+i) = yuv_csys(i)
   csys(6+i) = zuv_csys(i)
  Next

  ufs.Mtx3.OrthoNormalize(csys)

  ufs.Csys.CreateMatrix(csys, mx) 
  ufs.Csys.CreateTempCsys(origin, mx, wcs)
  ufs.Csys.SetWcs(wcs)

 End Function
'------------------------------------------------------------------------------------ 

 Function Point3d2Doubles(ByVal pt As Point3d) As Double()
  Dim da As Double() = {pt.X, pt.Y, pt.Z}
  Return da
 End Function

'---------------------------------------------------------------

Function Doubles2Matrix3x3(ByVal mtx As Double()) As Matrix3x3

 Dim mx As Matrix3x3
  With mx
    .Xx = mtx(0)
    .Xy = mtx(1)
    .Xz = mtx(2)
    .Yx = mtx(3)
    .Yy = mtx(4)
    .Yz = mtx(5)
    .Zx = mtx(6)
    .Zy = mtx(7)
    .Zz = mtx(8)
  End With
  Return mx

 End Function

'---------------------------------------------------------------
 Function CreateHoneyCombROCEPatterns()

  If Rectangular Then

    CreateHoneyCombROCEPatterns = _
     CreateRectangularHoneyCombROCEPatterns()

  ElseIf Oval Then

    CreateHoneyCombROCEPatterns = _
     CreateOvalHoneyCombROCEPatterns()

  ElseIf Circular Then

    CreateHoneyCombROCEPatterns = _
      CreateCircularHoneyCombROCEPatterns()

  ElseIf Elliptic Then

    CreateHoneyCombROCEPatterns = _
      CreateEllipticHoneyCombROCEPatterns()

  End If

 End Function

'---------------------------------------------------------------

 Function CreateRectangularHoneyCombROCEPatterns()

   Dim theSession As Session = Session.GetSession()
   Dim workPart As Part = theSession.Parts.Work
   Dim wcs_nxmatrix As NXMatrix = workPart.WCS.CoordinateSystem.Orientation
   Dim xlimit As Integer  
   Dim ylimit As Integer  
   Dim x As Integer  
   Dim y As Integer  
   Dim xyPt As Point3d
   Dim hole_radius As Double
   Dim arc_ref_radius As Double
   Dim a As Double
   Dim XC As Double
   Dim YC As Double
   Dim Ws As Double
   Dim Hs As Double
   Dim arcs_cnt As Integer
  
   a = (holesSpace + holesDia)/2
   xlimit = ( (Honeycomb_X/2)/a ) + 2
   ylimit = ( (Honeycomb_Y/2)/(a*(3^0.5)) ) + 2
   hole_radius = holesDia/2
   arc_ref_radius = Honeycomb_Y/2
   adjustment = adjustment*holesDia
   arcs_cnt = -1
   Ws = ((Honeycomb_Y/2)-hole_radius + adjustment)
   Hs = ((Honeycomb_X/2)-hole_radius + adjustment)

  For y = -ylimit To ylimit
   For x = -xlimit To xlimit

    XC = (2*x+1)*a
    YC = (2*y+1)*a*(3^0.5)
    If Abs(XC) <= Hs AND Abs(YC) <= Ws Then 
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

    XC = (2*x)*a
    YC = (2*y)*a*(3^0.5)
    If Abs(XC) <= Hs AND Abs(YC) <= Ws Then 
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

   Next
  Next

  arcs(0).Color = 7
  arcs(0).RedisplayObject

  Dim startPoint1 As Point3d = New Point3d((-Honeycomb_X/2), (Honeycomb_Y/2), 0.0)
  startPoint1 = WCS2Abs(startPoint1)
  Dim endPoint1 As Point3d = New Point3d((Honeycomb_X/2), (Honeycomb_Y/2), 0.0)
  endPoint1 = WCS2Abs(endPoint1)
  rect_ref_1 = workPart.Curves.CreateLine(startPoint1, endPoint1)
  rect_ref_1.LineFont = 1
  rect_ref_1.Color = 6
  rect_ref_1.RedisplayObject

  Dim startPoint2 As Point3d = New Point3d((Honeycomb_X/2), (Honeycomb_Y/2), 0.0)
  startPoint2 = WCS2Abs(startPoint2)
  Dim endPoint2 As Point3d = New Point3d((Honeycomb_X/2), (-Honeycomb_Y/2), 0.0)
  endPoint2 = WCS2Abs(endPoint2)
  rect_ref_2 = workPart.Curves.CreateLine(startPoint2, endPoint2)
  rect_ref_2.LineFont = 1
  rect_ref_2.Color = 6
  rect_ref_2.RedisplayObject

  Dim startPoint3 As Point3d = New Point3d((Honeycomb_X/2), (-Honeycomb_Y/2), 0.0)
  startPoint3 = WCS2Abs(startPoint3)
  Dim endPoint3 As Point3d = New Point3d((-Honeycomb_X/2), (-Honeycomb_Y/2), 0.0)
  endPoint3 = WCS2Abs(endPoint3)
  rect_ref_3 = workPart.Curves.CreateLine(startPoint3, endPoint3)
  rect_ref_3.LineFont = 1
  rect_ref_3.Color = 6
  rect_ref_3.RedisplayObject

  Dim startPoint4 As Point3d = New Point3d((-Honeycomb_X/2), (-Honeycomb_Y/2), 0.0)
  startPoint4 = WCS2Abs(startPoint4)
  Dim endPoint4 As Point3d = New Point3d((-Honeycomb_X/2), (Honeycomb_Y/2), 0.0)
  endPoint4 = WCS2Abs(endPoint4)
  rect_ref_4 = workPart.Curves.CreateLine(startPoint4, endPoint4)
  rect_ref_4.LineFont = 1
  rect_ref_4.Color = 6
  rect_ref_4.RedisplayObject
  refs_cnt = 3
  geom2_cnt = 1

  Dim QTYholesPL As PropertyList = QTYholes.GetProperties() 
  QTYholesPL.SetInteger("Value",(arcs_cnt+1).ToString())
  QTYholesPL.Dispose()
  QTYholesPL = Nothing

  needDeleteRectangular = True

  CreateRectangularHoneyCombROCEPatterns = arcs_cnt

 End Function

'---------------------------------------------------------------------

 Function CreateOvalHoneyCombROCEPatterns()

   Dim theSession As Session = Session.GetSession()
   Dim workPart As Part = theSession.Parts.Work
   Dim wcs_nxmatrix As NXMatrix = workPart.WCS.CoordinateSystem.Orientation
   Dim xlimit As Integer  
   Dim ylimit As Integer  
   Dim x As Integer  
   Dim y As Integer  
   Dim xyPt As Point3d
   Dim hole_radius As Double
   Dim arc_ref_radius As Double
   Dim a As Double
   Dim Rs As Double
   Dim XC As Double
   Dim YC As Double
   Dim Ws As Double
   Dim Hs As Double
   Dim H1 As Double
   Dim arcs_cnt As Integer
 
   a = (holesSpace + holesDia)/2
   H1 = (Honeycomb_X - Honeycomb_Y)/2
   xlimit = ( (Honeycomb_X/2)/a ) + 2
   ylimit = ( (Honeycomb_Y/2)/(a*(3^0.5)) ) + 2
   hole_radius = holesDia/2
   arc_ref_radius = Honeycomb_Y/2
   adjustment = adjustment*holesDia
   arcs_cnt = -1
   Ws = ((Honeycomb_Y/2)-hole_radius + adjustment)
   Hs = ((Honeycomb_X/2)-hole_radius + adjustment)
   Rs = (arc_ref_radius-hole_radius + adjustment)^2

  For y = -ylimit To ylimit
   For x = -xlimit To xlimit

    XC = (2*x+1)*a
    YC = (2*y+1)*a*(3^0.5)
    If ( Abs(XC) < H1 And Abs(YC) <= Ws ) Or _
       ( Abs(XC) >= H1 And ((Abs(XC)-H1)^2 + YC^2) <= Rs ) Then     
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

    XC = (2*x)*a
    YC = (2*y)*a*(3^0.5)
    If ( Abs(XC) < H1 And Abs(YC) <= Ws ) Or _
       ( Abs(XC) >= H1 And ((Abs(XC)-H1)^2 + YC^2) <= Rs ) Then     
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

   Next
  Next

  arcs(0).Color = 7
  arcs(0).RedisplayObject

  Dim startPoint1 As Point3d = New Point3d(-((Honeycomb_X-Honeycomb_Y)/2), (Honeycomb_Y/2), 0.0)
  startPoint1 = WCS2Abs(startPoint1)
  Dim endPoint1 As Point3d = New Point3d(((Honeycomb_X-Honeycomb_Y)/2), (Honeycomb_Y/2), 0.0)
  endPoint1 = WCS2Abs(endPoint1)
  oval_ref_1 = workPart.Curves.CreateLine(startPoint1, endPoint1)
  oval_ref_1.LineFont = 1
  oval_ref_1.Color = 6
  oval_ref_1.RedisplayObject

  Dim startPoint2 As Point3d = New Point3d(((Honeycomb_X-Honeycomb_Y)/2), (Honeycomb_Y/2), 0.0)
  startPoint2 = WCS2Abs(startPoint2)
  Dim pointOn2 As Point3d = New Point3d((Honeycomb_X/2), 0.0, 0.0)
  pointOn2 = WCS2Abs(pointOn2)
  Dim endPoint2 As Point3d = New Point3d(((Honeycomb_X-Honeycomb_Y)/2), (-Honeycomb_Y/2), 0.0)
  endPoint2 = WCS2Abs(endPoint2)
  oval_ref_2 = workPart.Curves.CreateArc(startPoint2, pointOn2, endPoint2, False, False)
  oval_ref_2.LineFont = 1
  oval_ref_2.Color = 6
  oval_ref_2.RedisplayObject

  Dim startPoint3 As Point3d = New Point3d(((Honeycomb_X-Honeycomb_Y)/2), (-Honeycomb_Y/2), 0.0)
  startPoint3 = WCS2Abs(startPoint3)
  Dim endPoint3 As Point3d = New Point3d(-((Honeycomb_X-Honeycomb_Y)/2), (-Honeycomb_Y/2), 0.0)
  endPoint3 = WCS2Abs(endPoint3)
  oval_ref_3 = workPart.Curves.CreateLine(startPoint3, endPoint3)
  oval_ref_3.LineFont = 1
  oval_ref_3.Color = 6
  oval_ref_3.RedisplayObject

  Dim startPoint4 As Point3d = New Point3d(-((Honeycomb_X-Honeycomb_Y)/2), (-Honeycomb_Y/2), 0.0)
  startPoint4 = WCS2Abs(startPoint4)
  Dim pointOn4 As Point3d = New Point3d(-(Honeycomb_X/2), 0.0, 0.0)
  pointOn4 = WCS2Abs(pointOn4)
  Dim endPoint4 As Point3d = New Point3d(-((Honeycomb_X-Honeycomb_Y)/2), (Honeycomb_Y/2), 0.0)
  endPoint4 = WCS2Abs(endPoint4)
  oval_ref_4 = workPart.Curves.CreateArc(startPoint4, pointOn4, endPoint4, False, False)
  oval_ref_4.LineFont = 1
  oval_ref_4.Color = 6
  oval_ref_4.RedisplayObject
  refs_cnt = 3
  geom2_cnt = 1

  Dim QTYholesPL As PropertyList = QTYholes.GetProperties() 
  QTYholesPL.SetInteger("Value",(arcs_cnt+1).ToString())
  QTYholesPL.Dispose()
  QTYholesPL = Nothing

  needDeleteOval = True

  CreateOvalHoneyCombROCEPatterns = arcs_cnt

 End Function

'---------------------------------------------------------------------

 Function CreateCircularHoneyCombROCEPatterns()

   Dim theSession As Session = Session.GetSession()
   Dim workPart As Part = theSession.Parts.Work
   Dim wcs_nxmatrix As NXMatrix = workPart.WCS.CoordinateSystem.Orientation
   Dim xlimit As Integer  
   Dim ylimit As Integer  
   Dim x As Integer  
   Dim y As Integer  
   Dim xyPt As Point3d
   Dim hole_radius As Double
   Dim arc_ref_radius As Double
   Dim a As Double
   Dim XC As Double
   Dim YC As Double
   Dim Rs As Double
   Dim arcs_cnt As Integer  

   a = (holesSpace + holesDia)/2
   xlimit = ( (Honeycomb_Y/2)/a ) + 2
   ylimit = ( (Honeycomb_Y/2)/(a*(3^0.5)) ) + 2
   hole_radius = holesDia/2
   arc_ref_radius = Honeycomb_Y/2
   adjustment = adjustment*holesDia
   arcs_cnt = -1
   Rs = (arc_ref_radius-hole_radius + adjustment)^2

  For y = -ylimit To ylimit
   For x = -xlimit To xlimit

    XC = (2*x+1)*a
    YC = (2*y+1)*a*(3^0.5)
    If (XC^2 + YC^2) <= Rs Then 
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

    XC = (2*x)*a
    YC = (2*y)*a*(3^0.5)
    If (XC^2 + YC^2) <= Rs Then 
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

   Next
  Next

  arcs(0).Color = 7
  arcs(0).RedisplayObject

  xyPt.x = 0.0
  xyPt.y = 0.0
  xyPt.z = 0.0
  xyPt = WCS2Abs(xyPt)
  arc_ref = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     arc_ref_radius,0.0,(360.0*Math.Pi/180.0))
  arc_ref.LineFont = 1
  arc_ref.Color = 6
  arc_ref.RedisplayObject
  refs_cnt = 0
  geom2_cnt = 0

  Dim QTYholesPL As PropertyList = QTYholes.GetProperties() 
  QTYholesPL.SetInteger("Value",(arcs_cnt+1).ToString())
  QTYholesPL.Dispose()
  QTYholesPL = Nothing

  needDeleteCircular = True

  CreateCircularHoneyCombROCEPatterns = arcs_cnt

 End Function

'-------------------------------------------------------------------------------

 Function CreateEllipticHoneyCombROCEPatterns()

   Dim theSession As Session = Session.GetSession()
   Dim workPart As Part = theSession.Parts.Work
   Dim wcs_nxmatrix As NXMatrix = workPart.WCS.CoordinateSystem.Orientation
   Dim xlimit As Integer  
   Dim ylimit As Integer  
   Dim x As Integer  
   Dim y As Integer  
   Dim xyPt As Point3d
   Dim hole_radius As Double
   Dim arc_ref_radius As Double
   Dim a As Double
   Dim XC As Double
   Dim YC As Double
   Dim aR As Double
   Dim bR As Double
   Dim abRs As Double
   Dim arcs_cnt As Integer  

   a = (holesSpace + holesDia)/2
   xlimit = ( (Honeycomb_X/2)/a ) + 2
   ylimit = ( (Honeycomb_Y/2)/(a*(3^0.5)) ) + 2
   hole_radius = holesDia/2
   arc_ref_radius = Honeycomb_Y/2
   adjustment = adjustment*holesDia
   arcs_cnt = -1
   aR = Honeycomb_X/2
   bR = Honeycomb_Y/2
   abRs = (aR-hole_radius + adjustment)^2*(bR-hole_radius + adjustment)^2

  For y = -ylimit To ylimit
   For x = -xlimit To xlimit

    XC = (2*x+1)*a
    YC = (2*y+1)*a*(3^0.5)
    If (bR^2*XC^2 + aR^2*YC^2) <= abRs Then 
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

    XC = (2*x)*a
    YC = (2*y)*a*(3^0.5)
    If (bR^2*XC^2 + aR^2*YC^2) <= abRs Then 
     xyPt.x = XC
     xyPt.y = YC
     xyPt.z = 0.0
     xyPt = WCS2Abs(xyPt)
     arcs_cnt = arcs_cnt + 1
     ReDim Preserve arcs(arcs_cnt)
     arcs(arcs_cnt) = workPart.Curves.CreateArc(xyPt,wcs_nxmatrix, _
                     hole_radius,0.0,(360.0*Math.Pi/180.0))
     arcs(arcs_cnt).RedisplayObject
    End If

   Next
  Next

  arcs(0).Color = 7
  arcs(0).RedisplayObject

  xyPt.x = 0.0
  xyPt.y = 0.0
  xyPt.z = 0.0
  xyPt = WCS2Abs(xyPt)

  ellipse_ref = workPart.Curves.CreateEllipse(xyPt, aR, bR, 0.0, _
                          ( 360.0 * Math.Pi/180.0 ), 0.0, wcs_nxmatrix)
  ellipse_ref.LineFont = 1
  ellipse_ref.Color = 6
  ellipse_ref.RedisplayObject
  refs_cnt = 0
  geom2_cnt = 0

  Dim QTYholesPL As PropertyList = QTYholes.GetProperties() 
  QTYholesPL.SetInteger("Value",(arcs_cnt+1).ToString())
  QTYholesPL.Dispose()
  QTYholesPL = Nothing

  needDeleteElliptic = True

  CreateEllipticHoneyCombROCEPatterns = arcs_cnt

 End Function

'-------------------------------------------------------------------------------

 Function Abs(ByVal d As Double) As Double
   If d < 0 Then
     d = -d
   End If
   Abs = d
 End Function  
'---------------------------------------------------------------------

 Function DeletHoneyComb() As Integer

  If needDeleteRectangular Then

     DeletRectangularHoneyComb()

   End If
 
  If needDeleteOval Then

     DeletOvalHoneyComb()

   End If

  If needDeleteCircular Then

     DeletCircularHoneyComb()

   End If

  If needDeleteElliptic Then

     DeleteEllipticHoneyComb()

   End If

 End Function


'---------------------------------------------------------------------

 Function DeletRectangularHoneyComb() As Integer

  needDeleteRectangular = False
  Try
 
   Dim workPart As Part = theSession.Parts.Work
   Dim del_objects(arcs_cnt+4) As NXObject
   Dim i As Integer

   For i = 0 To arcs_cnt
     del_objects(i) = arcs(i)
   Next
   del_objects(arcs_cnt+1) = rect_ref_1
   del_objects(arcs_cnt+2) = rect_ref_2
   del_objects(arcs_cnt+3) = rect_ref_3
   del_objects(arcs_cnt+4) = rect_ref_4

   Dim del_markId As Session.UndoMarkId
   del_markId = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

   Dim nErrs1 As Integer
   nErrs1 = theSession.UpdateManager.AddToDeleteList(del_objects)

   Dim notifyOnDelete2 As Boolean
   notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete
   workPart.ModelingViews.WorkView.Regenerate()

   Dim nErrs2 As Integer
   nErrs2 = theSession.UpdateManager.DoUpdate(del_markId)
   theSession.DeleteUndoMark(del_markId, Nothing)

  Catch ex As Exception        
  '---- Enter your exception handling code here -----
    'theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
    Return 0
  End Try

 End Function

'---------------------------------------------------------------------

 Function DeletOvalHoneyComb() As Integer

  needDeleteOval = False
  Try
 
   Dim workPart As Part = theSession.Parts.Work
   Dim del_objects(arcs_cnt+4) As NXObject
   Dim i As Integer
   For i = 0 To arcs_cnt
     del_objects(i) = arcs(i)
   Next
   del_objects(arcs_cnt+1) = oval_ref_1
   del_objects(arcs_cnt+2) = oval_ref_2
   del_objects(arcs_cnt+3) = oval_ref_3
   del_objects(arcs_cnt+4) = oval_ref_4

   Dim del_markId As Session.UndoMarkId
   del_markId = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

   Dim nErrs1 As Integer
   nErrs1 = theSession.UpdateManager.AddToDeleteList(del_objects)

   Dim notifyOnDelete2 As Boolean
   notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete
   workPart.ModelingViews.WorkView.Regenerate()

   Dim nErrs2 As Integer
   nErrs2 = theSession.UpdateManager.DoUpdate(del_markId)
   theSession.DeleteUndoMark(del_markId, Nothing)

  Catch ex As Exception        
  '---- Enter your exception handling code here -----
    'theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
    Return 0
  End Try

 End Function

'---------------------------------------------------------------------

 Function DeletCircularHoneyComb() As Integer

  needDeleteCircular = False
  Try
 
   Dim workPart As Part = theSession.Parts.Work
   Dim del_objects(arcs_cnt+1) As NXObject
   Dim i As Integer
   For i = 0 To arcs_cnt
     del_objects(i) = arcs(i)
   Next
   del_objects(arcs_cnt+1) = arc_ref

   Dim del_markId As Session.UndoMarkId
   del_markId = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

   Dim nErrs1 As Integer
   nErrs1 = theSession.UpdateManager.AddToDeleteList(del_objects)

   Dim notifyOnDelete2 As Boolean
   notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete
   workPart.ModelingViews.WorkView.Regenerate()

   Dim nErrs2 As Integer
   nErrs2 = theSession.UpdateManager.DoUpdate(del_markId)
   theSession.DeleteUndoMark(del_markId, Nothing)

  Catch ex As Exception        
  '---- Enter your exception handling code here -----
    'theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
    Return 0
  End Try

 End Function

'---------------------------------------------------------------------

 Function DeleteEllipticHoneyComb() As Integer

  needDeleteElliptic = False
  Try
 
   Dim workPart As Part = theSession.Parts.Work
   Dim del_objects(arcs_cnt+1) As NXObject
   Dim i As Integer
   For i = 0 To arcs_cnt
     del_objects(i) = arcs(i)
   Next
   del_objects(arcs_cnt+1) = ellipse_ref

   Dim del_markId As Session.UndoMarkId
   del_markId = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

   Dim nErrs1 As Integer
   nErrs1 = theSession.UpdateManager.AddToDeleteList(del_objects)

   Dim notifyOnDelete2 As Boolean
   notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete
   workPart.ModelingViews.WorkView.Regenerate()

   Dim nErrs2 As Integer
   nErrs2 = theSession.UpdateManager.DoUpdate(del_markId)
   theSession.DeleteUndoMark(del_markId, Nothing)

  Catch ex As Exception        
  '---- Enter your exception handling code here -----
    'theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
    Return 0
  End Try

 End Function

'---------------------------------------------------------------

 Function WCS2Abs(ByVal inPt As Point3d) As Point3d
  
  Dim ufs As UFSession = UFSession.GetUFSession()
   Dim pt1(2), pt2(2) As Double  

   pt1(0) = inPt.X  
   pt1(1) = inPt.Y  
   pt1(2) = inPt.Z  

   ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt1, UFConstants.UF_CSYS_ROOT_COORDS, pt2)  

   WCS2Abs.X = pt2(0)  
   WCS2Abs.Y = pt2(1)  
   WCS2Abs.Z = pt2(2)  

 End Function  

'---------------------------------------------------------------

 Sub GetDoublesData()

  Dim DataHoneyCombWPL As PropertyList = DataHoneyCombW.GetProperties() 
  Honeycomb_Y = DataHoneyCombwPL.GetDouble("Value")
  DataHoneyCombWPL.Dispose()
  DataHoneyCombwPL = Nothing

  Dim DataHoneyCombHPL As PropertyList = DataHoneyCombH.GetProperties() 
  Honeycomb_X = DataHoneyCombHPL.GetDouble("Value")
  DataHoneyCombHPL.Dispose()
  DataHoneyCombHPL = Nothing
            
  Dim DataHolePL As PropertyList = DataHole.GetProperties() 
  holesDia = DataHolePL.GetDouble("Value")
  DataHolePL.Dispose()
  DataHolePL = Nothing
            
  Dim DataSpacePL As PropertyList = DataSpace.GetProperties() 
  holesSpace = DataSpacePL.GetDouble("Value")
  DataSpacePL.Dispose()
  DataSpacePL = Nothing
            
  Dim DataAdjutPL As PropertyList = DataAdjut.GetProperties() 
  adjustment = DataAdjutPL.GetDouble("Value")
  DataAdjutPL.Dispose()
  DataAdjutPL = Nothing

 End Sub

'---------------------------------------------------------------

Sub CreatHoneyCombSketch()

 Dim workPart As Part = theSession.Parts.Work
 Dim j As Integer  
 Dim sketch_name As String = "HoneyComb X" & (arcs_cnt+1).ToString & " Holes"

 create_sketch_datums( )
 create_sketch( sketch_name )

 Dim curvesorpoints1(arcs_cnt) As SmartObject
 For j=0 To arcs_cnt
   curvesorpoints1(j) = arcs(j)
 Next

 theSession.ActiveSketch.AddGeometry(Sketch.InferConstraintsOption. _
          InferCoincidentConstraints, Sketch.AddEllipseOption. _
                                 TreatAsEllipse, curvesorpoints1)

 Dim curvesorpoints2(refs_cnt) As SmartObject
 If Rectangular Then
   curvesorpoints2(0) = rect_ref_1
   curvesorpoints2(1) = rect_ref_2
   curvesorpoints2(2) = rect_ref_3
   curvesorpoints2(3) = rect_ref_4
 ElseIf Oval Then
   curvesorpoints2(0) = oval_ref_1
   curvesorpoints2(1) = oval_ref_2
   curvesorpoints2(2) = oval_ref_3
   curvesorpoints2(3) = oval_ref_4
 ElseIf Circular Then
   curvesorpoints2(0) = arc_ref
 ElseIf Elliptic Then
   curvesorpoints2(0) = ellipse_ref
 End If

 theSession.ActiveSketch.AddGeometry(Sketch.InferConstraintsOption. _
                     InferCoincidentConstraints, Sketch.AddEllipseOption. _
                                             TreatAsEllipse, curvesorpoints2)
 theSession.ActiveSketch.Update()

 Dim sketchAutoConstrainBuilder1 As SketchAutoConstrainBuilder
 sketchAutoConstrainBuilder1 = workPart.Sketches.CreateAutoConstrainBuilder()
 sketchAutoConstrainBuilder1.DistanceTolerance = 0.0254
 sketchAutoConstrainBuilder1.AngleTolerance = 0.5
 sketchAutoConstrainBuilder1.Horizontal = False
 sketchAutoConstrainBuilder1.Vertical = False
 sketchAutoConstrainBuilder1.Tangent = False
 sketchAutoConstrainBuilder1.Parallel = False
 sketchAutoConstrainBuilder1.Perpendicular = False
 sketchAutoConstrainBuilder1.EqualRadius = True

 Dim objects1(arcs_cnt) As TaggedObject
 For j=0 To arcs_cnt
   objects1(j) = arcs(j)
 Next

 Dim added1 As Boolean
 added1 = sketchAutoConstrainBuilder1.CurveList.Add(objects1)
 theSession.ActiveSketch.Update()
 Dim nXObject1 As NXObject
 nXObject1 = sketchAutoConstrainBuilder1.Commit()
 sketchAutoConstrainBuilder1.Destroy()

 Dim geom1(arcs_cnt) As Sketch.ConstraintGeometry

 For j=0 to arcs_cnt
  geom1(j).Geometry = arcs(j)
  geom1(j).PointType = Sketch.ConstraintPointType.ArcCenter
  geom1(j).SplineDefiningPointIndex = 0
  Dim sketchGeometricConstraint1 As SketchGeometricConstraint
  sketchGeometricConstraint1 = theSession.ActiveSketch.CreateFixedConstraint(geom1(j))
 Next

 Dim geom2(geom2_cnt) As Sketch.ConstraintGeometry
 If Rectangular Then
   geom2(0).Geometry = rect_ref_1
   'geom2(1).Geometry = rect_ref_2
   geom2(1).Geometry = rect_ref_3
   'geom2(3).Geometry = rect_ref_4
 ElseIf Oval Then
   'geom2(0).Geometry = oval_ref_1
   geom2(0).Geometry = oval_ref_2
   'geom2(2).Geometry = oval_ref_3
   geom2(1).Geometry = oval_ref_4
 ElseIf Circular Then
   geom2(0).Geometry = arc_ref
 ElseIf Elliptic Then
   geom2(0).Geometry = ellipse_ref
 End If

   Dim constraints2() As SketchGeometricConstraint
 For k As Integer = 0 To geom2_cnt
   geom2(k).PointType = Sketch.ConstraintPointType.None
   geom2(k).SplineDefiningPointIndex = 0
   constraints2 = theSession.ActiveSketch.CreateFullyFixedConstraints(geom2(k))
 Next

 theSession.ActiveSketch.Update()

 Dim convertToFromReferenceBuilder1 As ConvertToFromReferenceBuilder
 convertToFromReferenceBuilder1 = workPart.Sketches.CreateConvertToFromReferenceBuilder()
 Dim selectNXObjectList1 As SelectNXObjectList
 selectNXObjectList1 = convertToFromReferenceBuilder1.InputObjects
 Dim added2(refs_cnt) As Boolean

 If Rectangular Then
   added2(0) = selectNXObjectList1.Add(rect_ref_1)
   added2(1) = selectNXObjectList1.Add(rect_ref_2)
   added2(2) = selectNXObjectList1.Add(rect_ref_3)
   added2(3) = selectNXObjectList1.Add(rect_ref_4)
 ElseIf Oval Then
   added2(0) = selectNXObjectList1.Add(oval_ref_1)
   added2(1) = selectNXObjectList1.Add(oval_ref_2)
   added2(2) = selectNXObjectList1.Add(oval_ref_3)
   added2(3) = selectNXObjectList1.Add(oval_ref_4)
 ElseIf Circular Then
   added2(0) = selectNXObjectList1.Add(arc_ref)
 ElseIf Elliptic Then
  added2(0) = selectNXObjectList1.Add(ellipse_ref)
 End If

 convertToFromReferenceBuilder1.OutputState = ConvertToFromReferenceBuilder.OutputType.Reference
 Dim nXObject2 As NXObject
 nXObject2 = convertToFromReferenceBuilder1.Commit()
 convertToFromReferenceBuilder1.Destroy()

 Dim dimObject1_1 As Sketch.DimensionGeometry
 dimObject1_1.Geometry = arcs(0)
 dimObject1_1.AssocType = Sketch.AssocType.Tangency
 dimObject1_1.AssocValue = 32
 dimObject1_1.HelpPoint.X = 0.0
 dimObject1_1.HelpPoint.Y = 0.0
 dimObject1_1.HelpPoint.Z = 0.0
 dimObject1_1.View = workPart.ModelingViews.WorkView
 Dim dimOrigin1 As Point3d = New Point3d(-18.2484565044161, 25.3425962369545, 0.0)
 Dim nullExpression As Expression = Nothing
 Dim sketchDimensionalConstraint1 As SketchDimensionalConstraint
 sketchDimensionalConstraint1 = theSession.ActiveSketch. _
          CreateDiameterDimension(dimObject1_1, dimOrigin1, nullExpression, _
                                      Sketch.DimensionOption.CreateAsDriving)
 Dim dimension1 As Annotations.Dimension
 dimension1 = sketchDimensionalConstraint1.AssociatedDimension
 Dim expression1 As Expression
 expression1 = sketchDimensionalConstraint1.AssociatedExpression
 theSession.ActiveSketch.Update()
 expression1.SetName("Hole_1_Of_" & (arcs_cnt+1).ToString & "_Holes")


 '   ****** Menu: Sketch->Finish Sketch ******
 theSession.ActiveSketch.Deactivate(Sketch.ViewReorient.True, _ 
                                    Sketch.UpdateLevel.Model)
 theSession.EndTaskEnvironment()
 '   ****** Menu: Tools->Journal->Stop Recording ******

End Sub

'---------------------------------------------------------------------

Sub create_sketch( ByRef sk_name As String )

  Dim theSession As Session = Session.GetSession()
  Dim workPart As Part = theSession.Parts.Work
  Dim displayPart As Part = theSession.Parts.Display
  '   ****** Menu: Insert->Sketch... ******
  Dim markId1 As Session.UndoMarkId
  markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Sketcher")
  theSession.BeginTaskEnvironment()
  Dim nullSketch As Sketch = Nothing
  Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder
  sketchInPlaceBuilder1 = workPart.Sketches.CreateSketchInPlaceBuilder(nullSketch)
  Dim nXObject1 As NXObject
  nXObject1 = sketchInPlaceBuilder1.Commit()
  Dim sketch1 As Sketch = CType(nXObject1, Sketch)
  Dim feature1 As Features.Feature
  feature1 = sketch1.Feature
  sketch1.Activate(Sketch.ViewReorient.True)
  sketchInPlaceBuilder1.Destroy()
  theSession.ActiveSketch.SetName(sk_name)

 End Sub

'---------------------------------------------------------------------

 Sub create_sketch_datums( )

  Dim theSession As Session = Session.GetSession()
  Dim ufs As UFSession = UFSession.GetUFSession()
  Dim workPart As Part = theSession.Parts.Work
  Dim displayPart As Part = theSession.Parts.Display
  Dim wcs_origin As Point3d = workPart.WCS.Origin
  Dim wcs_matrix3x3 As Matrix3x3 = workPart.WCS.CoordinateSystem.Orientation.Element
  Dim featdatum_tag As Tag
  Dim featdatum_obj As NXObject

  Dim xyplane As DatumPlane
  xyplane = workPart.Datums.CreateFixedDatumPlane(wcs_origin,wcs_matrix3x3)
  xyplane.SetName("_XY_")
  ufs.Modl.AskObjectFeat(xyplane.Tag,featdatum_tag)
  featdatum_obj = NXOpen.Utilities.NXObjectManager.Get(featdatum_tag)
  Dim xy_PlaneFeat As Features.DatumPlaneFeature = CType(featdatum_obj,Features.DatumPlaneFeature)
  xy_PlaneFeat.SetName("_XY_")

  Dim Xdir As New Point3d(1,0,0)
  Xdir = WCS2Abs(Xdir)
  Dim Xaxis As DatumAxis
  Xaxis = workPart.Datums.CreateFixedDatumAxis(wcs_origin,Xdir)
  Xaxis.SetName("_X_")
  ufs.Modl.AskObjectFeat(Xaxis.Tag,featdatum_tag)
  featdatum_obj = NXOpen.Utilities.NXObjectManager.Get(featdatum_tag)
  Dim x_AxisFeat As Features.DatumAxisFeature = CType(featdatum_obj,Features.DatumAxisFeature)
  x_AxisFeat.SetName("_X_")

  Dim Ydir As New Point3d(0,1,0)
  Ydir = WCS2Abs(Ydir)
  Dim Yaxis As DatumAxis
  Yaxis = workPart.Datums.CreateFixedDatumAxis(wcs_origin,Ydir)
  Yaxis.SetName("_Y_")
  ufs.Modl.AskObjectFeat(Yaxis.Tag,featdatum_tag)
  featdatum_obj = NXOpen.Utilities.NXObjectManager.Get(featdatum_tag)
  Dim y_AxisFeat As Features.DatumAxisFeature = CType(featdatum_obj,Features.DatumAxisFeature)
  y_AxisFeat.SetName("_Y_")

 End Sub

'---------------------------------------------------------------

 Sub Apply_Data( )

              PointOnface = False
              Manipulator = False
              SelectPoint.GetProperties.SetLogical("Enable",False)        
              SelectManip.GetProperties.SetLogical("Enable",False)        
              SelectManip.GetProperties.SetLogical("Show",False)        
              grpSpecifyOrientation.GetProperties.SetLogical("Show",False)        
              grpSpecifyPoint.GetProperties.SetLogical("Show",False)
        
              DataHoneyCombW.GetProperties.SetLogical("Enable",True)        
              DataHoneyCombH.GetProperties.SetLogical("Enable",True)        
              DataHole.GetProperties.SetLogical("Enable",True)
              DataSpace.GetProperties.SetLogical("Enable",True)
              DataAdjut.GetProperties.SetLogical("Enable",True)
              '-----------------------------------------------------------------
              GetDoublesData()
               If needDelete Then
                 DeletHoneyComb()
                 arcs_cnt = CreateHoneyCombROCEPatterns()
                 needDelete = True
               Else
                 arcs_cnt = CreateHoneyCombROCEPatterns()
                 needDelete = True
               End If
               '----------------------------------------------------------------
               Dim workPart As Part = theSession.Parts.Work
               workPart.ModelingViews.WorkView.Fit()

 End Sub

'========================================================================================
'========================================================================================

 Sub Apply_SelectOption()

            Dim opt As String = SelectOption.GetProperties.GetEnumAsString("Value")

            If opt = "XY Plane By Default WCS" Then

              PointOnface = False
              Manipulator = False
              SelectPoint.GetProperties.SetLogical("Enable",False)        
              SelectManip.GetProperties.SetLogical("Enable",False)        
              SelectManip.GetProperties.SetLogical("Show",False)        
              grpSpecifyOrientation.GetProperties.SetLogical("Show",False)        
              grpSpecifyPoint.GetProperties.SetLogical("Show",False)

              DataHoneyCombW.GetProperties.SetLogical("Enable",False)        
              DataHoneyCombH.GetProperties.SetLogical("Enable",False)        
              DataHole.GetProperties.SetLogical("Enable",False)
              DataSpace.GetProperties.SetLogical("Enable",False)
              DataAdjut.GetProperties.SetLogical("Enable",False)

              Dim workPart As Part = theSession.Parts.Work
              workPart.WCS.SetOriginAndMatrix(wp_wcs_origin, wp_wcs_matrix3x3)

            ElseIf opt = "XY Plane By PointOnface" Then

              PointOnface = True
              Manipulator = False
              SelectPoint.GetProperties.SetLogical("Enable",True)        
              SelectManip.GetProperties.SetLogical("Enable",False)        
              SelectManip.GetProperties.SetLogical("Show",False)        
              grpSpecifyOrientation.GetProperties.SetLogical("Show",False)        
              grpSpecifyPoint.GetProperties.SetLogical("Show",True)

              DataHoneyCombW.GetProperties.SetLogical("Enable",False)        
              DataHoneyCombH.GetProperties.SetLogical("Enable",False)        
              DataHole.GetProperties.SetLogical("Enable",False)
              DataSpace.GetProperties.SetLogical("Enable",False)
              DataAdjut.GetProperties.SetLogical("Enable",False)
            
            ElseIf opt =  "XY Plane By Manipulator" Then

              Manipulator = True
              PointOnface = False
              SelectPoint.GetProperties.SetLogical("Enable",False)        
              SelectManip.GetProperties.SetLogical("Enable",True)        
              SelectManip.GetProperties.SetLogical("Show",True)        
              grpSpecifyOrientation.GetProperties.SetLogical("Show",True)        
              grpSpecifyPoint.GetProperties.SetLogical("Show",False)
        
              DataHoneyCombW.GetProperties.SetLogical("Enable",False)        
              DataHoneyCombH.GetProperties.SetLogical("Enable",False)        
              DataHole.GetProperties.SetLogical("Enable",False)
              DataSpace.GetProperties.SetLogical("Enable",False)
              DataAdjut.GetProperties.SetLogical("Enable",False)

            End If

 End Sub

'---------------------------------------------------------------------------------------

 Sub Apply_SelectPatternType()

            Dim spt As String = SelectPatternType.GetProperties.GetEnumAsString("Value")

            If spt = "None" Then

              Rectangular = False
              Oval = False
              Circular = False
              Elliptic = False
              Apply_Data( )

            ElseIf spt = "Rectangular" Then

              Rectangular = True
              Oval = False
              Circular = False
              Elliptic = False
              Apply_Data( )

            ElseIf spt = "Oval" Then

              Rectangular = False
              Oval = True
              Circular = False
              Elliptic = False
              Apply_Data( )

            ElseIf spt = "Circular" Then

              Rectangular = False
              Oval = False
              Circular = True
              Elliptic = False
              Apply_Data( )

            ElseIf spt = "Elliptic" Then

              Rectangular = False
              Oval = False
              Circular = False
              Elliptic = True
              Apply_Data( )

            End If

 End Sub

'---------------------------------------------------------------------------------------

 Sub Apply_SelectPoint()

            Dim SelectPointPL As PropertyList = SelectPoint.GetProperties()
 
            Dim point1 As Point3d = SelectPointPL.GetPoint("Point")
            cp(0) = point1.X
            cp(1) = point1.Y
            cp(2) = point1.Z
            
            Dim pt As Point = CType((SelectPointPL.GetTaggedObjectVector("SelectedObjects"))(0), Point)
            myPointTag = pt.Tag 

            SelectPointPL.Dispose()
            SelectPointPL = Nothing

            facetag = (GetPointParentFace(myPointTag)).Tag
            SetWcsByFaceUAndNormalAtPoint(facetag, cp)

 End Sub

'---------------------------------------------------------------------------------------
 Sub Apply_SelectManip()

            Dim SelectManipPL As PropertyList = SelectManip.GetProperties()
 
            origin1 = SelectManipPL.GetPoint("Origin")
            Dim x_axis As Vector3d = SelectManipPL.GetVector("XAxis")
            Dim y_axis As Vector3d = SelectManipPL.GetVector("YAxis")
            SelectManipPL.Dispose()
            SelectManipPL = Nothing

            Dim ufs As UFSession = UFSession.GetUFSession()
            Dim workPart As Part = theSession.Parts.Work

            Dim xVector(2) As Double
            Dim yVector(2) As Double
            Dim mtxDoubles(8) As Double

            xVector = Vector3d2Doubles(x_axis)
            yVector = Vector3d2Doubles(y_axis)
            ufs.Mtx3.Initialize(xVector, yVector, mtxDoubles)
            matrix1 = Doubles2Matrix3x3(mtxDoubles)

            workPart.WCS.SetOriginAndMatrix(origin1, matrix1)

 End Sub

'--------------------------------------------------------------------------------------

 Sub Apply_DataAdjut()

             GetDoublesData()
             Dim DataAdjutPL As PropertyList = DataAdjut.GetProperties() 
             adjustment = DataAdjutPL.GetDouble("Value")
             DataAdjutPL.Dispose()
             DataAdjutPL = Nothing

             If Honeycomb_Y > 0 And holesDia > 0 And holesSpace > 0 Then

               If needDelete Then
                 DeletHoneyComb()
                 arcs_cnt = CreateHoneyCombROCEPatterns()
                 needDelete = True
               Else
                 arcs_cnt = CreateHoneyCombROCEPatterns()
                 needDelete = True
               End If

             End If
             Dim workPart As Part = theSession.Parts.Work
             workPart.ModelingViews.WorkView.Fit()

 End Sub

'**************************************************************************************
'---------------------------------------------------------------

 Function Vector3d2Doubles(ByVal pt As Vector3d) As Double()
  Dim da As Double() = {pt.X, pt.Y, pt.Z}
  Return da
 End Function

'---------------------------------------------------------------
   
End Class
 
And this for fun

Code:
'==============================================================================
'  WARNING!!  This file is overwritten by the Block Styler while generating
'  the automation code. Any modifications to this file will be lost after
'  generating the code again.
'
'       Filename:  C:\Sudoku.vb
'
'        This file was generated by the NX Block Styler
'        Created by: I'm
'              Version: NX 6
'              Date: 06-28-2015  (Format: mm-dd-yyyy)
'              Time: 19:14 (Format: hh-mm)
'
'==============================================================================

'==============================================================================
'  Purpose:  This TEMPLATE file contains VB.NET source to guide you in the
'  construction of your Block application dialog. The generation of your
'  dialog file (.dlx extension) is the first step towards dialog construction
'  within NX.  You must now create a NX Open application that
'  utilizes this file (.dlx).
'
'  The information in this file provides you with the following:
'
'  1.  Help on how to load and display your Block Styler dialog in NX
'      using APIs provided in NXOpen.BlockStyler namespace
'  2.  The empty callback methods (stubs) associated with your dialog items
'      have also been placed in this file. These empty methods have been
'      created simply to start you along with your coding requirements.
'      The method name, argument list and possible return values have already
'      been provided for you.
'==============================================================================

'------------------------------------------------------------------------------
'These imports are needed for the following template code
'------------------------------------------------------------------------------
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.BlockStyler
Imports NXOpen.UF

'------------------------------------------------------------------------------
'Represents Block Styler application class
'------------------------------------------------------------------------------
Public Class Sudoku
    'class members
    Private Shared theSession As Session
    Private Shared theUI As UI
    Public Shared theSudoku As Sudoku
    Private theDialogName As String
    Private theDialog As NXOpen.BlockStyler.BlockDialog
    Private type1 As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private Type As NXOpen.BlockStyler.UIBlock' Block type: Enumeration
    Private StopAt As NXOpen.BlockStyler.UIBlock' Block type: Integer
    Private matrix1 As NXOpen.BlockStyler.UIBlock' Block type: Group
    Private intTable As NXOpen.BlockStyler.UIBlock' Block type: Integer Table
    'my members
    Dim RegularType As Boolean
    Dim DiagonalType As Boolean
    Dim TimerFlag As Boolean = True
    Dim stop_at_solution As Integer = 2
    Dim a(80) as Integer
    
#Region "Block Styler Dialog Designer generator code"
    '------------------------------------------------------------------------------
    'Constructor for NX Styler class
    '------------------------------------------------------------------------------
    Public Sub New()
        Try
        
            theSession = Session.GetSession()
            theUI = UI.GetUI()
            theDialogName = "C:\sudoku9x9.dlx"
            theDialog = theUI.CreateDialog(theDialogName)
            theDialog.AddApplyHandler(AddressOf apply_cb)
            theDialog.AddOkHandler(AddressOf ok_cb)
            theDialog.AddUpdateHandler(AddressOf update_cb)
            theDialog.AddCancelHandler(AddressOf cancel_cb)
            theDialog.AddInitializeHandler(AddressOf initialize_cb)
            theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
            Throw ex
        End Try
    End Sub
#End Region
    
    '------------------------------- DIALOG LAUNCHING ---------------------------------
    '
    '    Before invoking this application one needs to open any part/empty part in NX
    '    because of the behavior of the blocks.
    '
    '    Make sure the dlx file is in one of the following locations:
    '        1.) From where NX session is launched
    '        2.) $UGII_USER_DIR/application
    '        3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
    '            recommended. This variable is set to a full directory path to a file 
    '            containing a list of root directories for all custom applications.
    '            e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
    '
    '    You can create the dialog using one of the following way:
    '
    '    1. Journal Replay
    '
    '        1) Replay this file through Tool->Journal->Play Menu.
    '
    '    2. USER EXIT
    '
    '        1) Create the Shared Library -- Refer "Block Styler programmer's guide"
    '        2) Invoke the Shared Library through File->Execute->NX Open menu.
    '
    '------------------------------------------------------------------------------
    Public Shared Sub Main()
        Try
        
            theSudoku = New Sudoku()
            ' The following method shows the dialog immediately
            theSudoku.Show()
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        Finally
            theSudoku.Dispose()
        End Try
    End Sub
    '------------------------------------------------------------------------------
    ' This method specifies how a shared image is unloaded from memory
    ' within NX. This method gives you the capability to unload an
    ' internal NX Open application or user  exit from NX. Specify any
    ' one of the three constants as a return value to determine the type
    ' of unload to perform:
    '
    '
    '    Immediately : unload the library as soon as the automation program has completed
    '    Explicitly  : unload the library from the "Unload Shared Image" dialog
    '    AtTermination : unload the library when the NX session terminates
    '
    '
    ' NOTE:  A program which associates NX Open applications with the menubar
    ' MUST NOT use this option since it will UNLOAD your NX Open application image
    ' from the menubar.
    '------------------------------------------------------------------------------
    Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
        'Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
         Return CType(Session.LibraryUnloadOption.Immediately, Integer)
        ' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
    End Function
    '------------------------------------------------------------------------------
    ' Following method cleanup any housekeeping chores that may be needed.
    ' This method is automatically called by NX.
    '------------------------------------------------------------------------------
    Public Shared Function UnloadLibrary(ByVal arg As String) As Integer
        Try
        
            Return 0
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Function
    
    '------------------------------------------------------------------------------
    'This method shows the dialog on the screen
    '------------------------------------------------------------------------------
    Public Sub Show()
        Try
        
            theDialog.Show
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub
    
    '------------------------------------------------------------------------------
    'Method Name: Dispose
    '------------------------------------------------------------------------------
    Public Sub Dispose()
        If theDialog IsNot Nothing Then 
            theDialog.Dispose()
            theDialog = Nothing
        End If
    End Sub
    
    '------------------------------------------------------------------------------
    '---------------------Block Styler Callback Functions--------------------------
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    'Callback Name: initialize_cb
    '------------------------------------------------------------------------------
    Public Sub initialize_cb()
        Try
        
            type1 = theDialog.TopBlock.FindBlock("type1")
            Type = theDialog.TopBlock.FindBlock("Type")
            StopAt = theDialog.TopBlock.FindBlock("StopAt")
            matrix1 = theDialog.TopBlock.FindBlock("matrix1")
            intTable = theDialog.TopBlock.FindBlock("intTable")
            StopAt.GetProperties.SetInteger("Value",2)

        Dim j1 As Integer
        Dim mxv(80) As Integer
        For j1 = 0 To 80
          mxv(j1) = 0
        Next
        intTable.GetProperties.SetIntegerMatrix("MinimumValues",9,9,mxv)
        For j1 = 0 To 80
          mxv(j1) = 9
        Next
        intTable.GetProperties.SetIntegerMatrix("MaximumValues",9,9,mxv)

        RegularType = True
        TimerFlag = True
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub
    
    '------------------------------------------------------------------------------
    'Callback Name: dialogShown_cb
    'This callback is executed just before the dialog launch. Thus any value set 
    'here will take precedence and dialog will be launched showing that value. 
    '------------------------------------------------------------------------------
    Public Sub dialogShown_cb()
        Try
        
            '---- Enter your callback code here -----
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub
    
    '------------------------------------------------------------------------------
    'Callback Name: apply_cb
    '------------------------------------------------------------------------------
    Public Function apply_cb() As Integer
        Try
        
            '---- Enter your callback code here -----

              a = intTable.GetProperties().GetIntegerMatrix("Values",9,9)

              GetOptions()
              GetStopNum()
              TimerFlag = True

              If RegularType = True Then
                
                RSudoku
                
              Else If DiagonalType = True Then

                DSudoku

              End If
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        apply_cb = 0
    End Function
    
    '------------------------------------------------------------------------------
    'Callback Name: update_cb
    '------------------------------------------------------------------------------
    Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
        Try
        
            If block Is Type Then
            '---- Enter your code here -----

              GetOptions()
            
            ElseIf block Is StopAt Then
            '---- Enter your code here -----

              GetStopNum()
            
            ElseIf block Is intTable Then
            '---- Enter your code here -----
            
            End If
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        update_cb = 0
    End Function
    
    '------------------------------------------------------------------------------
    'Callback Name: ok_cb
    '------------------------------------------------------------------------------
    Public Function ok_cb() As Integer
        Try
        
            '---- Enter your callback code here -----
            apply_cb()
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        ok_cb = 0
    End Function
    
    '------------------------------------------------------------------------------
    'Callback Name: cancel_cb
    '------------------------------------------------------------------------------
    Public Function cancel_cb() As Integer
        Try
        
            '---- Enter your callback code here -----
        
        Catch ex As Exception
        
            '---- Enter your exception handling code here -----
             theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
        cancel_cb = 0
    End Function


'======================================================================================
'
'======================================================================================
 Public Sub GetStopNum()

    stop_at_solution = StopAt.GetProperties.GetInteger("Value")

 End Sub

 Public Sub GetOptions()

              Dim typ As String = Type.GetProperties.GetEnumAsString("Value")

              If typ = "Regular" Then

                RegularType = True
                DiagonalType = False

              Else If typ = "Diagonal" Then

                RegularType = False
                DiagonalType = True

              End If

 End Sub

'======================================================================================
'
'======================================================================================

Public Sub RSudoku()

   Dim s As Session = Session.GetSession()
   Dim ufs As UFSession = UFSession.GetUFSession()
   Dim lw As ListingWindow = s.ListingWindow

   Dim si(8,8) As Integer
   Dim ss(8,8) As Integer
   Dim Go_up As Boolean = False
      
   Dim si00,si10,si20,si30,si40,si50,si60,si70,si80 As Integer
   Dim si01,si11,si21,si31,si41,si51,si61,si71,si81 As Integer
   Dim si02,si12,si22,si32,si42,si52,si62,si72,si82 As Integer
   Dim si03,si13,si23,si33,si43,si53,si63,si73,si83 As Integer
   Dim si04,si14,si24,si34,si44,si54,si64,si74,si84 As Integer
   Dim si05,si15,si25,si35,si45,si55,si65,si75,si85 As Integer
   Dim si06,si16,si26,si36,si46,si56,si66,si76,si86 As Integer
   Dim si07,si17,si27,si37,si47,si57,si67,si77,si87 As Integer
   Dim si08,si18,si28,si38,si48,si58,si68,si78,si88 As Integer

   Dim start As Short
   Dim tv As NXOpen.UF.TimerValues
   ufs.UF.BeginTimer(start)
 
   Dim jj As Integer


   For jj=0 To 8
     si(0,jj) = a(jj)
     ss(0,jj) = si(0,jj)
   Next

   For jj=9 To 17
     si(1,jj-9) = a(jj)
     ss(1,jj-9) = si(1,jj-9)
   Next

   For jj=18 To 26
     si(2,jj-18) = a(jj)
     ss(2,jj-18) = si(2,jj-18)
   Next

   For jj=27 To 35
     si(3,jj-27) = a(jj)
     ss(3,jj-27) = si(3,jj-27)
   Next

   For jj=36 To 44
     si(4,jj-36) = a(jj)
     ss(4,jj-36) = si(4,jj-36)
   Next

   For jj=45 To 53
     si(5,jj-45) = a(jj)
     ss(5,jj-45) = si(5,jj-45)
   Next

   For jj=54 To 62
     si(6,jj-54) = a(jj)
     ss(6,jj-54) = si(6,jj-54)
   Next

   For jj=63 To 71
     si(7,jj-63) = a(jj)
     ss(7,jj-63) = si(7,jj-63)
   Next

   For jj=72 To 80
     si(8,jj-72) = a(jj)
     ss(8,jj-72) = si(8,jj-72)
   Next

  lw.Open()

   If valid_check( ss ) = False Then
     'lw.WriteLine(" Input not valid ! ")
     msgbox(" Input not valid ! ")
     Exit Sub
   End If

  si00 = 0: si01 = 0: si02 = 0: si03 = 0: si04 = 0: si05 = 0: si06 = 0: si07 = 0: si08 = 0
  si10 = 0: si11 = 0: si12 = 0: si13 = 0: si14 = 0: si15 = 0: si16 = 0: si17 = 0: si18 = 0
  si20 = 0: si21 = 0: si22 = 0: si23 = 0: si24 = 0: si25 = 0: si26 = 0: si27 = 0: si28 = 0
  si30 = 0: si31 = 0: si32 = 0: si33 = 0: si34 = 0: si35 = 0: si36 = 0: si37 = 0: si38 = 0
  si40 = 0: si41 = 0: si42 = 0: si43 = 0: si44 = 0: si45 = 0: si46 = 0: si47 = 0: si48 = 0
  si50 = 0: si51 = 0: si52 = 0: si53 = 0: si54 = 0: si55 = 0: si56 = 0: si57 = 0: si58 = 0
  si60 = 0: si61 = 0: si62 = 0: si63 = 0: si64 = 0: si65 = 0: si66 = 0: si67 = 0: si68 = 0
  si70 = 0: si71 = 0: si72 = 0: si73 = 0: si74 = 0: si75 = 0: si76 = 0: si77 = 0: si78 = 0
  si80 = 0: si81 = 0: si82 = 0: si83 = 0: si84 = 0: si85 = 0: si86 = 0: si87 = 0: si88 = 0

  Dim cnt_stop As Integer = 0

si00:

  If si(0,0) = 0 Then

    Go_up = False
    si00 = si00 + 1
    If si00 > 9 Then
       lw.WriteLine("***  Sudoku Processing Ended ! ***")
       Exit Sub       
    End If
           
    If si00 = ss(0,1) OrElse si00 = ss(0,2) OrElse si00 = ss(0,3) OrElse si00 = ss(0,4) OrElse _
       si00 = ss(0,5) OrElse si00 = ss(0,6) OrElse si00 = ss(0,7) OrElse si00 = ss(0,8) OrElse _
       si00 = ss(1,0) OrElse si00 = ss(2,0) OrElse si00 = ss(3,0) OrElse si00 = ss(4,0) OrElse _
       si00 = ss(5,0) OrElse si00 = ss(6,0) OrElse si00 = ss(7,0) OrElse si00 = ss(8,0) OrElse _
       si00 = ss(1,1) OrElse si00 = ss(1,2) OrElse si00 = ss(2,1) OrElse si00 = ss(2,2) Then GoTo si00

    ss(0,0) = si00        
    'lw.WriteLine(" ==> si00 - Passed si00 = " & si00.ToString)

  End If


si01:

  If si(0,1) = 0 Then

  Go_up = False
  si01 = si01 + 1
  If si01 > 9 Then
     si01 = 0
     ss(0,1) = 0        
     Go_up = True
     GoTo si00
  End If
           
    If si01 = ss(0,0) OrElse si01 = ss(0,2) OrElse si01 = ss(0,3) OrElse si01 = ss(0,4) OrElse _
       si01 = ss(0,5) OrElse si01 = ss(0,6) OrElse si01 = ss(0,7) OrElse si01 = ss(0,8) OrElse _
       si01 = ss(1,1) OrElse si01 = ss(2,1) OrElse si01 = ss(3,1) OrElse si01 = ss(4,1) OrElse _
       si01 = ss(5,1) OrElse si01 = ss(6,1) OrElse si01 = ss(7,1) OrElse si01 = ss(8,1) OrElse _
       si01 = ss(1,0) OrElse si01 = ss(1,2) OrElse si01 = ss(2,0) OrElse si01 = ss(2,2) Then GoTo si01
        
    ss(0,1) = si01        
    'lw.WriteLine(" ==> si01 - Passed si01 = " & si01.ToString)
     
  Else
    If Go_up = True Then GoTo si00          
  End If


si02:

  If si(0,2) = 0 Then

  Go_up = False
  si02 = si02 + 1
  If si02 > 9 Then
     si02 = 0
     ss(0,2) = 0        
     Go_up = True
     GoTo si01
  End If
           
    If si02 = ss(0,0) OrElse si02 = ss(0,1) OrElse si02 = ss(0,3) OrElse si02 = ss(0,4) OrElse _
       si02 = ss(0,5) OrElse si02 = ss(0,6) OrElse si02 = ss(0,7) OrElse si02 = ss(0,8) OrElse _
       si02 = ss(1,2) OrElse si02 = ss(2,2) OrElse si02 = ss(3,2) OrElse si02 = ss(4,2) OrElse _
       si02 = ss(5,2) OrElse si02 = ss(6,2) OrElse si02 = ss(7,2) OrElse si02 = ss(8,2) OrElse _
       si02 = ss(1,0) OrElse si02 = ss(1,1) OrElse si02 = ss(2,0) OrElse si02 = ss(2,1) Then GoTo si02
        
    ss(0,2) = si02        
    'lw.WriteLine(" ==> si02 - Passed si02 = " & si02.ToString)
     
  Else
    If Go_up = True Then GoTo si01          
  End If


si03:

  If si(0,3) = 0 Then

  Go_up = False
  si03 = si03 + 1
  If si03 > 9 Then
     si03 = 0
     ss(0,3) = 0        
     Go_up = True
     GoTo si02
  End If
           
    If si03 = ss(0,0) OrElse si03 = ss(0,1) OrElse si03 = ss(0,2) OrElse si03 = ss(0,4) OrElse _
       si03 = ss(0,5) OrElse si03 = ss(0,6) OrElse si03 = ss(0,7) OrElse si03 = ss(0,8) OrElse _
       si03 = ss(1,3) OrElse si03 = ss(2,3) OrElse si03 = ss(3,3) OrElse si03 = ss(4,3) OrElse _
       si03 = ss(5,3) OrElse si03 = ss(6,3) OrElse si03 = ss(7,3) OrElse si03 = ss(8,3) OrElse _
       si03 = ss(1,4) OrElse si03 = ss(1,5) OrElse si03 = ss(2,4) OrElse si03 = ss(2,5) Then GoTo si03
        
    ss(0,3) = si03        
    'lw.WriteLine(" ==> si03 - Passed si03 = " & si03.ToString)
     
  Else
    If Go_up = True Then GoTo si02          
  End If


si04:

  If si(0,4) = 0 Then

  Go_up = False
  si04 = si04 + 1
  If si04 > 9 Then
     si04 = 0
     ss(0,4) = 0        
     Go_up = True
     GoTo si03
  End If
           
    If si04 = ss(0,0) OrElse si04 = ss(0,1) OrElse si04 = ss(0,2) OrElse si04 = ss(0,3) OrElse _
       si04 = ss(0,5) OrElse si04 = ss(0,6) OrElse si04 = ss(0,7) OrElse si04 = ss(0,8) OrElse _
       si04 = ss(1,4) OrElse si04 = ss(2,4) OrElse si04 = ss(3,4) OrElse si04 = ss(4,4) OrElse _
       si04 = ss(5,4) OrElse si04 = ss(6,4) OrElse si04 = ss(7,4) OrElse si04 = ss(8,4) OrElse _
       si04 = ss(1,3) OrElse si04 = ss(1,5) OrElse si04 = ss(2,3) OrElse si04 = ss(2,5) Then GoTo si04
        
    ss(0,4) = si04        
    'lw.WriteLine(" ==> si04 - Passed si04 = " & si04.ToString)
     
  Else
    If Go_up = True Then GoTo si03          
  End If


si05:

  If si(0,5) = 0 Then

  Go_up = False
  si05 = si05 + 1
  If si05 > 9 Then
     si05 = 0
     ss(0,5) = 0        
     Go_up = True
     GoTo si04
  End If
           
    If si05 = ss(0,0) OrElse si05 = ss(0,1) OrElse si05 = ss(0,2) OrElse si05 = ss(0,3) OrElse _
       si05 = ss(0,4) OrElse si05 = ss(0,6) OrElse si05 = ss(0,7) OrElse si05 = ss(0,8) OrElse _
       si05 = ss(1,5) OrElse si05 = ss(2,5) OrElse si05 = ss(3,5) OrElse si05 = ss(4,5) OrElse _
       si05 = ss(5,5) OrElse si05 = ss(6,5) OrElse si05 = ss(7,5) OrElse si05 = ss(8,5) OrElse _
       si05 = ss(1,3) OrElse si05 = ss(1,4) OrElse si05 = ss(2,3) OrElse si05 = ss(2,4) Then GoTo si05
        
    ss(0,5) = si05        
    'lw.WriteLine(" ==> si05 - Passed si05 = " & si05.ToString)
     
  Else
    If Go_up = True Then GoTo si04          
  End If


si06:

  If si(0,6) = 0 Then

  Go_up = False
  si06 = si06 + 1
  If si06 > 9 Then
     si06 = 0
     ss(0,6) = 0        
     Go_up = True
     GoTo si05
  End If
           
    If si06 = ss(0,0) OrElse si06 = ss(0,1) OrElse si06 = ss(0,2) OrElse si06 = ss(0,3) OrElse _
       si06 = ss(0,4) OrElse si06 = ss(0,5) OrElse si06 = ss(0,7) OrElse si06 = ss(0,8) OrElse _
       si06 = ss(1,6) OrElse si06 = ss(2,6) OrElse si06 = ss(3,6) OrElse si06 = ss(4,6) OrElse _
       si06 = ss(5,6) OrElse si06 = ss(6,6) OrElse si06 = ss(7,6) OrElse si06 = ss(8,6) OrElse _
       si06 = ss(1,7) OrElse si06 = ss(1,8) OrElse si06 = ss(2,7) OrElse si06 = ss(2,8) Then GoTo si06
        
    ss(0,6) = si06        
    'lw.WriteLine(" ==> si06 - Passed si06 = " & si06.ToString)
     
  Else
    If Go_up = True Then GoTo si05          
  End If


si07:

  If si(0,7) = 0 Then

  Go_up = False
  si07 = si07 + 1
  If si07 > 9 Then
     si07 = 0
     ss(0,7) = 0        
     Go_up = True
     GoTo si06
  End If
           
    If si07 = ss(0,0) OrElse si07 = ss(0,1) OrElse si07 = ss(0,2) OrElse si07 = ss(0,3) OrElse _
       si07 = ss(0,4) OrElse si07 = ss(0,5) OrElse si07 = ss(0,6) OrElse si07 = ss(0,8) OrElse _
       si07 = ss(1,7) OrElse si07 = ss(2,7) OrElse si07 = ss(3,7) OrElse si07 = ss(4,7) OrElse _
       si07 = ss(5,7) OrElse si07 = ss(6,7) OrElse si07 = ss(7,7) OrElse si07 = ss(8,7) OrElse _
       si07 = ss(1,6) OrElse si07 = ss(1,8) OrElse si07 = ss(2,6) OrElse si07 = ss(2,8) Then GoTo si07
        
    ss(0,7) = si07        
    'lw.WriteLine(" ==> si07 - Passed si07 = " & si07.ToString)
     
  Else
    If Go_up = True Then GoTo si06          
  End If


si08:

  If si(0,8) = 0 Then

  Go_up = False
  si08 = si08 + 1
  If si08 > 9 Then
     si08 = 0
     ss(0,8) = 0        
     Go_up = True
     GoTo si07
  End If
           
    If si08 = ss(0,0) OrElse si08 = ss(0,1) OrElse si08 = ss(0,2) OrElse si08 = ss(0,3) OrElse _
       si08 = ss(0,4) OrElse si08 = ss(0,5) OrElse si08 = ss(0,6) OrElse si08 = ss(0,7) OrElse _
       si08 = ss(1,8) OrElse si08 = ss(2,8) OrElse si08 = ss(3,8) OrElse si08 = ss(4,8) OrElse _
       si08 = ss(5,8) OrElse si08 = ss(6,8) OrElse si08 = ss(7,8) OrElse si08 = ss(8,8) OrElse _
       si08 = ss(1,6) OrElse si08 = ss(1,7) OrElse si08 = ss(2,6) OrElse si08 = ss(2,7) Then GoTo si08
        
    ss(0,8) = si08        
    'lw.WriteLine(" ==> si08 - Passed si08 = " & si08.ToString)
     
  Else
    If Go_up = True Then GoTo si07          
  End If


si10:

  If si(1,0) = 0 Then

  Go_up = False
  si10 = si10 + 1
  If si10 > 9 Then
     si10 = 0
     ss(1,0) = 0        
     Go_up = True
     GoTo si08
  End If
           
    If si10 = ss(1,1) OrElse si10 = ss(1,2) OrElse si10 = ss(1,3) OrElse si10 = ss(1,4) OrElse _
       si10 = ss(1,5) OrElse si10 = ss(1,6) OrElse si10 = ss(1,7) OrElse si10 = ss(1,8) OrElse _
       si10 = ss(0,0) OrElse si10 = ss(2,0) OrElse si10 = ss(3,0) OrElse si10 = ss(4,0) OrElse _
       si10 = ss(5,0) OrElse si10 = ss(6,0) OrElse si10 = ss(7,0) OrElse si10 = ss(8,0) OrElse _
       si10 = ss(0,1) OrElse si10 = ss(0,2) OrElse si10 = ss(2,1) OrElse si10 = ss(2,2) Then GoTo si10

    ss(1,0) = si10        
    'lw.WriteLine(" ==> si10 - Passed si10 = " & si10.ToString)

  Else
    If Go_up = True Then GoTo si08          
  End If


si11:

  If si(1,1) = 0 Then

  Go_up = False
  si11 = si11 + 1
  If si11 > 9 Then
     si11 = 0
     ss(1,1) = 0        
     Go_up = True
     GoTo si10
  End If
           
    If si11 = ss(1,0) OrElse si11 = ss(1,2) OrElse si11 = ss(1,3) OrElse si11 = ss(1,4) OrElse _
       si11 = ss(1,5) OrElse si11 = ss(1,6) OrElse si11 = ss(1,7) OrElse si11 = ss(1,8) OrElse _
       si11 = ss(0,1) OrElse si11 = ss(2,1) OrElse si11 = ss(3,1) OrElse si11 = ss(4,1) OrElse _
       si11 = ss(5,1) OrElse si11 = ss(6,1) OrElse si11 = ss(7,1) OrElse si11 = ss(8,1) OrElse _
       si11 = ss(0,0) OrElse si11 = ss(0,2) OrElse si11 = ss(2,0) OrElse si11 = ss(2,2) Then GoTo si11
        
    ss(1,1) = si11        
    'lw.WriteLine(" ==> si11 - Passed si11 = " & si11.ToString)
     
  Else
    If Go_up = True Then GoTo si10          
  End If


si12:

  If si(1,2) = 0 Then

  Go_up = False
  si12 = si12 + 1
  If si12 > 9 Then
     si12 = 0
     ss(1,2) = 0        
     Go_up = True
     GoTo si11
  End If
           
    If si12 = ss(1,0) OrElse si12 = ss(1,1) OrElse si12 = ss(1,3) OrElse si12 = ss(1,4) OrElse _
       si12 = ss(1,5) OrElse si12 = ss(1,6) OrElse si12 = ss(1,7) OrElse si12 = ss(1,8) OrElse _
       si12 = ss(0,2) OrElse si12 = ss(2,2) OrElse si12 = ss(3,2) OrElse si12 = ss(4,2) OrElse _
       si12 = ss(5,2) OrElse si12 = ss(6,2) OrElse si12 = ss(7,2) OrElse si12 = ss(8,2) OrElse _
       si12 = ss(0,0) OrElse si12 = ss(0,1) OrElse si12 = ss(2,0) OrElse si12 = ss(2,1) Then GoTo si12
        
    ss(1,2) = si12        
    'lw.WriteLine(" ==> si12 - Passed si12 = " & si12.ToString)
     
  Else
    If Go_up = True Then GoTo si11          
  End If


si13:

  If si(1,3) = 0 Then

  Go_up = False
  si13 = si13 + 1
  If si13 > 9 Then
     si13 = 0
     ss(1,3) = 0        
     Go_up = True
     GoTo si12
  End If
           
    If si13 = ss(1,0) OrElse si13 = ss(1,1) OrElse si13 = ss(1,2) OrElse si13 = ss(1,4) OrElse _
       si13 = ss(1,5) OrElse si13 = ss(1,6) OrElse si13 = ss(1,7) OrElse si13 = ss(1,8) OrElse _
       si13 = ss(0,3) OrElse si13 = ss(2,3) OrElse si13 = ss(3,3) OrElse si13 = ss(4,3) OrElse _
       si13 = ss(5,3) OrElse si13 = ss(6,3) OrElse si13 = ss(7,3) OrElse si13 = ss(8,3) OrElse _
       si13 = ss(0,4) OrElse si13 = ss(0,5) OrElse si13 = ss(2,4) OrElse si13 = ss(2,5) Then GoTo si13
        
    ss(1,3) = si13        
    'lw.WriteLine(" ==> si13 - Passed si13 = " & si13.ToString)
     
  Else
    If Go_up = True Then GoTo si12          
  End If


si14:

  If si(1,4) = 0 Then

  Go_up = False
  si14 = si14 + 1
  If si14 > 9 Then
     si14 = 0
     ss(1,4) = 0        
     Go_up = True
     GoTo si13
  End If
           
    If si14 = ss(1,0) OrElse si14 = ss(1,1) OrElse si14 = ss(1,2) OrElse si14 = ss(1,3) OrElse _
       si14 = ss(1,5) OrElse si14 = ss(1,6) OrElse si14 = ss(1,7) OrElse si14 = ss(1,8) OrElse _
       si14 = ss(0,4) OrElse si14 = ss(2,4) OrElse si14 = ss(3,4) OrElse si14 = ss(4,4) OrElse _
       si14 = ss(5,4) OrElse si14 = ss(6,4) OrElse si14 = ss(7,4) OrElse si14 = ss(8,4) OrElse _
       si14 = ss(0,3) OrElse si14 = ss(0,5) OrElse si14 = ss(2,3) OrElse si14 = ss(2,5) Then GoTo si14
        
    ss(1,4) = si14        
    'lw.WriteLine(" ==> si14 - Passed si14 = " & si14.ToString)
     
  Else
    If Go_up = True Then GoTo si13          
  End If


si15:

  If si(1,5) = 0 Then

  Go_up = False
  si15 = si15 + 1
  If si15 > 9 Then
     si15 = 0
     ss(1,5) = 0        
     Go_up = True
     GoTo si14
  End If
           
    If si15 = ss(1,0) OrElse si15 = ss(1,1) OrElse si15 = ss(1,2) OrElse si15 = ss(1,3) OrElse _
       si15 = ss(1,4) OrElse si15 = ss(1,6) OrElse si15 = ss(1,7) OrElse si15 = ss(1,8) OrElse _
       si15 = ss(0,5) OrElse si15 = ss(2,5) OrElse si15 = ss(3,5) OrElse si15 = ss(4,5) OrElse _
       si15 = ss(5,5) OrElse si15 = ss(6,5) OrElse si15 = ss(7,5) OrElse si15 = ss(8,5) OrElse _
       si15 = ss(0,3) OrElse si15 = ss(0,4) OrElse si15 = ss(2,3) OrElse si15 = ss(2,4) Then GoTo si15
        
    ss(1,5) = si15        
    'lw.WriteLine(" ==> si15 - Passed si15 = " & si15.ToString)
     
  Else
    If Go_up = True Then GoTo si14          
  End If


si16:

  If si(1,6) = 0 Then

  Go_up = False
  si16 = si16 + 1
  If si16 > 9 Then
     si16 = 0
     ss(1,6) = 0        
     Go_up = True
     GoTo si15
  End If
           
    If si16 = ss(1,0) OrElse si16 = ss(1,1) OrElse si16 = ss(1,2) OrElse si16 = ss(1,3) OrElse _
       si16 = ss(1,4) OrElse si16 = ss(1,5) OrElse si16 = ss(1,7) OrElse si16 = ss(1,8) OrElse _
       si16 = ss(0,6) OrElse si16 = ss(2,6) OrElse si16 = ss(3,6) OrElse si16 = ss(4,6) OrElse _
       si16 = ss(5,6) OrElse si16 = ss(6,6) OrElse si16 = ss(7,6) OrElse si16 = ss(8,6) OrElse _
       si16 = ss(0,7) OrElse si16 = ss(0,8) OrElse si16 = ss(2,7) OrElse si16 = ss(2,8) Then GoTo si16
        
    ss(1,6) = si16        
    'lw.WriteLine(" ==> si16 - Passed si16 = " & si16.ToString)
     
  Else
    If Go_up = True Then GoTo si15          
  End If


si17:

  If si(1,7) = 0 Then

  Go_up = False
  si17 = si17 + 1
  If si17 > 9 Then
     si17 = 0
     ss(1,7) = 0        
     Go_up = True
     GoTo si16
  End If
           
    If si17 = ss(1,0) OrElse si17 = ss(1,1) OrElse si17 = ss(1,2) OrElse si17 = ss(1,3) OrElse _
       si17 = ss(1,4) OrElse si17 = ss(1,5) OrElse si17 = ss(1,6) OrElse si17 = ss(1,8) OrElse _
       si17 = ss(0,7) OrElse si17 = ss(2,7) OrElse si17 = ss(3,7) OrElse si17 = ss(4,7) OrElse _
       si17 = ss(5,7) OrElse si17 = ss(6,7) OrElse si17 = ss(7,7) OrElse si17 = ss(8,7) OrElse _
       si17 = ss(0,6) OrElse si17 = ss(0,8) OrElse si17 = ss(2,6) OrElse si17 = ss(2,8) Then GoTo si17
        
    ss(1,7) = si17        
    'lw.WriteLine(" ==> si17 - Passed si17 = " & si17.ToString)
     
  Else
    If Go_up = True Then GoTo si16          
  End If

si18:

  If si(1,8) = 0 Then

  Go_up = False
  si18 = si18 + 1
  If si18 > 9 Then
     si18 = 0
     ss(1,8) = 0        
     Go_up = True
     GoTo si17
  End If
           
    If si18 = ss(1,0) OrElse si18 = ss(1,1) OrElse si18 = ss(1,2) OrElse si18 = ss(1,3) OrElse _
       si18 = ss(1,4) OrElse si18 = ss(1,5) OrElse si18 = ss(1,6) OrElse si18 = ss(1,7) OrElse _
       si18 = ss(0,8) OrElse si18 = ss(2,8) OrElse si18 = ss(3,8) OrElse si18 = ss(4,8) OrElse _
       si18 = ss(5,8) OrElse si18 = ss(6,8) OrElse si18 = ss(7,8) OrElse si18 = ss(8,8) OrElse _
       si18 = ss(0,6) OrElse si18 = ss(0,7) OrElse si18 = ss(2,6) OrElse si18 = ss(2,7) Then GoTo si18
        
    ss(1,8) = si18        
    'lw.WriteLine(" ==> si18 - Passed si18 = " & si18.ToString)
     
  Else
    If Go_up = True Then GoTo si17          
  End If


si20:

  If si(2,0) = 0 Then

  Go_up = False
  si20 = si20 + 1
  If si20 > 9 Then
     si20 = 0
     ss(2,0) = 0        
     Go_up = True
     GoTo si18
  End If
           
    If si20 = ss(2,1) OrElse si20 = ss(2,2) OrElse si20 = ss(2,3) OrElse si20 = ss(2,4) OrElse _
       si20 = ss(2,5) OrElse si20 = ss(2,6) OrElse si20 = ss(2,7) OrElse si20 = ss(2,8) OrElse _
       si20 = ss(0,0) OrElse si20 = ss(1,0) OrElse si20 = ss(3,0) OrElse si20 = ss(4,0) OrElse _
       si20 = ss(5,0) OrElse si20 = ss(6,0) OrElse si20 = ss(7,0) OrElse si20 = ss(8,0) OrElse _
       si20 = ss(0,1) OrElse si20 = ss(0,2) OrElse si20 = ss(1,1) OrElse si20 = ss(1,2) Then GoTo si20

    ss(2,0) = si20        
    'lw.WriteLine(" ==> si20 - Passed si20 = " & si20.ToString)

  Else
    If Go_up = True Then GoTo si18          
  End If


si21:

  If si(2,1) = 0 Then

  Go_up = False
  si21 = si21 + 1
  If si21 > 9 Then
     si21 = 0
     ss(2,1) = 0        
     Go_up = True
     GoTo si20
  End If
           
    If si21 = ss(2,0) OrElse si21 = ss(2,2) OrElse si21 = ss(2,3) OrElse si21 = ss(2,4) OrElse _
       si21 = ss(2,5) OrElse si21 = ss(2,6) OrElse si21 = ss(2,7) OrElse si21 = ss(2,8) OrElse _
       si21 = ss(0,1) OrElse si21 = ss(1,1) OrElse si21 = ss(3,1) OrElse si21 = ss(4,1) OrElse _
       si21 = ss(5,1) OrElse si21 = ss(6,1) OrElse si21 = ss(7,1) OrElse si21 = ss(8,1) OrElse _
       si21 = ss(0,0) OrElse si21 = ss(0,2) OrElse si21 = ss(1,0) OrElse si21 = ss(1,2) Then GoTo si21

    ss(2,1) = si21        
    'lw.WriteLine(" ==> si21 - Passed si21 = " & si21.ToString)

  Else
    If Go_up = True Then GoTo si20          
  End If


si22:

  If si(2,2) = 0 Then

  Go_up = False
  si22 = si22 + 1
  If si22 > 9 Then
     si22 = 0
     ss(2,2) = 0        
     Go_up = True
     GoTo si21
  End If
           
    If si22 = ss(2,0) OrElse si22 = ss(2,1) OrElse si22 = ss(2,3) OrElse si22 = ss(2,4) OrElse _
       si22 = ss(2,5) OrElse si22 = ss(2,6) OrElse si22 = ss(2,7) OrElse si22 = ss(2,8) OrElse _
       si22 = ss(0,2) OrElse si22 = ss(1,2) OrElse si22 = ss(3,2) OrElse si22 = ss(4,2) OrElse _
       si22 = ss(5,2) OrElse si22 = ss(6,2) OrElse si22 = ss(7,2) OrElse si22 = ss(8,2) OrElse _
       si22 = ss(0,0) OrElse si22 = ss(0,1) OrElse si22 = ss(1,0) OrElse si22 = ss(1,1) Then GoTo si22

    ss(2,2) = si22        
    'lw.WriteLine(" ==> si22 - Passed si22 = " & si22.ToString)

  Else
    If Go_up = True Then GoTo si21          
  End If


si23:

  If si(2,3) = 0 Then

  Go_up = False
  si23 = si23 + 1
  If si23 > 9 Then
     si23 = 0
     ss(2,3) = 0        
     Go_up = True
     GoTo si22
  End If
           
    If si23 = ss(2,0) OrElse si23 = ss(2,1) OrElse si23 = ss(2,2) OrElse si23 = ss(2,4) OrElse _
       si23 = ss(2,5) OrElse si23 = ss(2,6) OrElse si23 = ss(2,7) OrElse si23 = ss(2,8) OrElse _
       si23 = ss(0,3) OrElse si23 = ss(1,3) OrElse si23 = ss(3,3) OrElse si23 = ss(4,3) OrElse _
       si23 = ss(5,3) OrElse si23 = ss(6,3) OrElse si23 = ss(7,3) OrElse si23 = ss(8,3) OrElse _
       si23 = ss(0,4) OrElse si23 = ss(0,5) OrElse si23 = ss(1,4) OrElse si23 = ss(1,5) Then GoTo si23

    ss(2,3) = si23        
    'lw.WriteLine(" ==> si23 - Passed si23 = " & si23.ToString)

  Else
    If Go_up = True Then GoTo si22          
  End If


si24:

  If si(2,4) = 0 Then

  Go_up = False
  si24 = si24 + 1
  If si24 > 9 Then
     si24 = 0
     ss(2,4) = 0        
     Go_up = True
     GoTo si23
  End If
           
    If si24 = ss(2,0) OrElse si24 = ss(2,1) OrElse si24 = ss(2,2) OrElse si24 = ss(2,3) OrElse _
       si24 = ss(2,5) OrElse si24 = ss(2,6) OrElse si24 = ss(2,7) OrElse si24 = ss(2,8) OrElse _
       si24 = ss(0,4) OrElse si24 = ss(1,4) OrElse si24 = ss(3,4) OrElse si24 = ss(4,4) OrElse _
       si24 = ss(5,4) OrElse si24 = ss(6,4) OrElse si24 = ss(7,4) OrElse si24 = ss(8,4) OrElse _
       si24 = ss(0,3) OrElse si24 = ss(0,5) OrElse si24 = ss(1,3) OrElse si24 = ss(1,5) Then GoTo si24

    ss(2,4) = si24        
    'lw.WriteLine(" ==> si24 - Passed si24 = " & si22.ToString)

  Else
    If Go_up = True Then GoTo si23          
  End If


si25:

  If si(2,5) = 0 Then

  Go_up = False
  si25 = si25 + 1
  If si25 > 9 Then
     si25 = 0
     ss(2,5) = 0        
     Go_up = True
     GoTo si24
  End If
           
    If si25 = ss(2,0) OrElse si25 = ss(2,1) OrElse si25 = ss(2,2) OrElse si25 = ss(2,3) OrElse _
       si25 = ss(2,4) OrElse si25 = ss(2,6) OrElse si25 = ss(2,7) OrElse si25 = ss(2,8) OrElse _
       si25 = ss(0,5) OrElse si25 = ss(1,5) OrElse si25 = ss(3,5) OrElse si25 = ss(4,5) OrElse _
       si25 = ss(5,5) OrElse si25 = ss(6,5) OrElse si25 = ss(7,5) OrElse si25 = ss(8,5) OrElse _
       si25 = ss(0,3) OrElse si25 = ss(0,4) OrElse si25 = ss(1,3) OrElse si25 = ss(1,4) Then GoTo si25

    ss(2,5) = si25        
    'lw.WriteLine(" ==> si25 - Passed si25 = " & si25.ToString)

  Else
    If Go_up = True Then GoTo si24          
  End If


si26:

  If si(2,6) = 0 Then

  Go_up = False
  si26 = si26 + 1
  If si26 > 9 Then
     si26 = 0
     ss(2,6) = 0        
     Go_up = True
     GoTo si25
  End If
           
    If si26 = ss(2,0) OrElse si26 = ss(2,1) OrElse si26 = ss(2,2) OrElse si26 = ss(2,3) OrElse _
       si26 = ss(2,4) OrElse si26 = ss(2,5) OrElse si26 = ss(2,7) OrElse si26 = ss(2,8) OrElse _
       si26 = ss(0,6) OrElse si26 = ss(1,6) OrElse si26 = ss(3,6) OrElse si26 = ss(4,6) OrElse _
       si26 = ss(5,6) OrElse si26 = ss(6,6) OrElse si26 = ss(7,6) OrElse si26 = ss(8,6) OrElse _
       si26 = ss(0,7) OrElse si26 = ss(0,8) OrElse si26 = ss(1,7) OrElse si26 = ss(1,8) Then GoTo si26

    ss(2,6) = si26        
    'lw.WriteLine(" ==> si26 - Passed si26 = " & si26.ToString)

  Else
    If Go_up = True Then GoTo si25          
  End If


si27:

  If si(2,7) = 0 Then

  Go_up = False
  si27 = si27 + 1
  If si27 > 9 Then
     si27 = 0
     ss(2,7) = 0        
     Go_up = True
     GoTo si26
  End If
           
    If si27 = ss(2,0) OrElse si27 = ss(2,1) OrElse si27 = ss(2,2) OrElse si27 = ss(2,3) OrElse _
       si27 = ss(2,4) OrElse si27 = ss(2,5) OrElse si27 = ss(2,6) OrElse si27 = ss(2,8) OrElse _
       si27 = ss(0,7) OrElse si27 = ss(1,7) OrElse si27 = ss(3,7) OrElse si27 = ss(4,7) OrElse _
       si27 = ss(5,7) OrElse si27 = ss(6,7) OrElse si27 = ss(7,7) OrElse si27 = ss(8,7) OrElse _
       si27 = ss(0,6) OrElse si27 = ss(0,8) OrElse si27 = ss(1,6) OrElse si27 = ss(1,8) Then GoTo si27

    ss(2,7) = si27        
    'lw.WriteLine(" ==> si27 - Passed si27 = " & si27.ToString)

  Else
    If Go_up = True Then GoTo si26          
  End If


si28:

  If si(2,8) = 0 Then

  Go_up = False
  si28 = si28 + 1
  If si28 > 9 Then
     si28 = 0
     ss(2,8) = 0        
     Go_up = True
     GoTo si27
  End If
           
    If si28 = ss(2,0) OrElse si28 = ss(2,1) OrElse si28 = ss(2,2) OrElse si28 = ss(2,3) OrElse _
       si28 = ss(2,4) OrElse si28 = ss(2,5) OrElse si28 = ss(2,6) OrElse si28 = ss(2,7) OrElse _
       si28 = ss(0,8) OrElse si28 = ss(1,8) OrElse si28 = ss(3,8) OrElse si28 = ss(4,8) OrElse _
       si28 = ss(5,8) OrElse si28 = ss(6,8) OrElse si28 = ss(7,8) OrElse si28 = ss(8,8) OrElse _
       si28 = ss(0,6) OrElse si28 = ss(0,7) OrElse si28 = ss(1,6) OrElse si28 = ss(1,7) Then GoTo si28

    ss(2,8) = si28        
    'lw.WriteLine(" ==> si28 - Passed si28 = " & si28.ToString)

  Else
    If Go_up = True Then GoTo si27          
  End If


si30:

  If si(3,0) = 0 Then

  Go_up = False
  si30 = si30 + 1
  If si30 > 9 Then
     si30 = 0
     ss(3,0) = 0        
     Go_up = True
     GoTo si28
  End If
           
    If si30 = ss(3,1) OrElse si30 = ss(3,2) OrElse si30 = ss(3,3) OrElse si30 = ss(3,4) OrElse _
       si30 = ss(3,5) OrElse si30 = ss(3,6) OrElse si30 = ss(3,7) OrElse si30 = ss(3,8) OrElse _
       si30 = ss(0,0) OrElse si30 = ss(1,0) OrElse si30 = ss(2,0) OrElse si30 = ss(4,0) OrElse _
       si30 = ss(5,0) OrElse si30 = ss(6,0) OrElse si30 = ss(7,0) OrElse si30 = ss(8,0) OrElse _
       si30 = ss(4,1) OrElse si30 = ss(4,2) OrElse si30 = ss(5,1) OrElse si30 = ss(5,2) Then GoTo si30

    ss(3,0) = si30        
    'lw.WriteLine(" ==> si30 - Passed si30 = " & si30.ToString)

  Else
    If Go_up = True Then GoTo si28          
  End If


si31:

  If si(3,1) = 0 Then

  Go_up = False
  si31 = si31 + 1
  If si31 > 9 Then
     si31 = 0
     ss(3,1) = 0        
     Go_up = True
     GoTo si30
  End If
           
    If si31 = ss(3,0) OrElse si31 = ss(3,2) OrElse si31 = ss(3,3) OrElse si31 = ss(3,4) OrElse _
       si31 = ss(3,5) OrElse si31 = ss(3,6) OrElse si31 = ss(3,7) OrElse si31 = ss(3,8) OrElse _
       si31 = ss(0,1) OrElse si31 = ss(1,1) OrElse si31 = ss(2,1) OrElse si31 = ss(4,1) OrElse _
       si31 = ss(5,1) OrElse si31 = ss(6,1) OrElse si31 = ss(7,1) OrElse si31 = ss(8,1) OrElse _
       si31 = ss(4,0) OrElse si31 = ss(4,2) OrElse si31 = ss(5,0) OrElse si31 = ss(5,2) Then GoTo si31

    ss(3,1) = si31        
    'lw.WriteLine(" ==> si31 - Passed si31 = " & si31.ToString)

  Else
    If Go_up = True Then GoTo si30          
  End If


si32:

  If si(3,2) = 0 Then

  Go_up = False
  si32 = si32 + 1
  If si32 > 9 Then
     si32 = 0
     ss(3,2) = 0        
     Go_up = True
     GoTo si31
  End If
           
    If si32 = ss(3,0) OrElse si32 = ss(3,1) OrElse si32 = ss(3,3) OrElse si32 = ss(3,4) OrElse _
       si32 = ss(3,5) OrElse si32 = ss(3,6) OrElse si32 = ss(3,7) OrElse si32 = ss(3,8) OrElse _
       si32 = ss(0,2) OrElse si32 = ss(1,2) OrElse si32 = ss(2,2) OrElse si32 = ss(4,2) OrElse _
       si32 = ss(5,2) OrElse si32 = ss(6,2) OrElse si32 = ss(7,2) OrElse si32 = ss(8,2) OrElse _
       si32 = ss(4,0) OrElse si32 = ss(4,1) OrElse si32 = ss(5,0) OrElse si32 = ss(5,1) Then GoTo si32

    ss(3,2) = si32        
    'lw.WriteLine(" ==> si32 - Passed si32 = " & si32.ToString)

  Else
    If Go_up = True Then GoTo si31          
  End If


si33:

  If si(3,3) = 0 Then

  Go_up = False
  si33 = si33 + 1
  If si33 > 9 Then
     si33 = 0
     ss(3,3) = 0        
     Go_up = True
     GoTo si32
  End If
           
    If si33 = ss(3,0) OrElse si33 = ss(3,1) OrElse si33 = ss(3,2) OrElse si33 = ss(3,4) OrElse _
       si33 = ss(3,5) OrElse si33 = ss(3,6) OrElse si33 = ss(3,7) OrElse si33 = ss(3,8) OrElse _
       si33 = ss(0,3) OrElse si33 = ss(1,3) OrElse si33 = ss(2,3) OrElse si33 = ss(4,3) OrElse _
       si33 = ss(5,3) OrElse si33 = ss(6,3) OrElse si33 = ss(7,3) OrElse si33 = ss(8,3) OrElse _
       si33 = ss(4,4) OrElse si33 = ss(4,5) OrElse si33 = ss(5,4) OrElse si33 = ss(5,5) Then GoTo si33

    ss(3,3) = si33        
    'lw.WriteLine(" ==> si33 - Passed si33 = " & si33.ToString)

  Else
    If Go_up = True Then GoTo si32          
  End If


si34:

  If si(3,4) = 0 Then

  Go_up = False
  si34 = si34 + 1
  If si34 > 9 Then
     si34 = 0
     ss(3,4) = 0        
     Go_up = True
     GoTo si33
  End If
           
    If si34 = ss(3,0) OrElse si34 = ss(3,1) OrElse si34 = ss(3,2) OrElse si34 = ss(3,3) OrElse _
       si34 = ss(3,5) OrElse si34 = ss(3,6) OrElse si34 = ss(3,7) OrElse si34 = ss(3,8) OrElse _
       si34 = ss(0,4) OrElse si34 = ss(1,4) OrElse si34 = ss(2,4) OrElse si34 = ss(4,4) OrElse _
       si34 = ss(5,4) OrElse si34 = ss(6,4) OrElse si34 = ss(7,4) OrElse si34 = ss(8,4) OrElse _
       si34 = ss(4,3) OrElse si34 = ss(4,5) OrElse si34 = ss(5,3) OrElse si34 = ss(5,5) Then GoTo si34

    ss(3,4) = si34        
    'lw.WriteLine(" ==> si34 - Passed si34 = " & si34.ToString)

  Else
    If Go_up = True Then GoTo si33          
  End If


si35:

  If si(3,5) = 0 Then

  Go_up = False
  si35 = si35 + 1
  If si35 > 9 Then
     si35 = 0
     ss(3,5) = 0        
     Go_up = True
     GoTo si34
  End If
           
    If si35 = ss(3,0) OrElse si35 = ss(3,1) OrElse si35 = ss(3,2) OrElse si35 = ss(3,3) OrElse _
       si35 = ss(3,4) OrElse si35 = ss(3,6) OrElse si35 = ss(3,7) OrElse si35 = ss(3,8) OrElse _
       si35 = ss(0,5) OrElse si35 = ss(1,5) OrElse si35 = ss(2,5) OrElse si35 = ss(4,5) OrElse _
       si35 = ss(5,5) OrElse si35 = ss(6,5) OrElse si35 = ss(7,5) OrElse si35 = ss(8,5) OrElse _
       si35 = ss(4,3) OrElse si35 = ss(4,4) OrElse si35 = ss(5,3) OrElse si35 = ss(5,4) Then GoTo si35

    ss(3,5) = si35        
    'lw.WriteLine(" ==> si35 - Passed si35 = " & si35.ToString)

  Else
    If Go_up = True Then GoTo si34          
  End If


si36:

  If si(3,6) = 0 Then

  Go_up = False
  si36 = si36 + 1
  If si36 > 9 Then
     si36 = 0
     ss(3,6) = 0        
     Go_up = True
     GoTo si35
  End If
           
    If si36 = ss(3,0) OrElse si36 = ss(3,1) OrElse si36 = ss(3,2) OrElse si36 = ss(3,3) OrElse _
       si36 = ss(3,4) OrElse si36 = ss(3,5) OrElse si36 = ss(3,7) OrElse si36 = ss(3,8) OrElse _
       si36 = ss(0,6) OrElse si36 = ss(1,6) OrElse si36 = ss(2,6) OrElse si36 = ss(4,6) OrElse _
       si36 = ss(5,6) OrElse si36 = ss(6,6) OrElse si36 = ss(7,6) OrElse si36 = ss(8,6) OrElse _
       si36 = ss(4,7) OrElse si36 = ss(4,8) OrElse si36 = ss(5,7) OrElse si36 = ss(5,8) Then GoTo si36

    ss(3,6) = si36        
    'lw.WriteLine(" ==> si36 - Passed si36 = " & si36.ToString)

  Else
    If Go_up = True Then GoTo si35          
  End If


si37:

  If si(3,7) = 0 Then

  Go_up = False
  si37 = si37 + 1
  If si37 > 9 Then
     si37 = 0
     ss(3,7) = 0        
     Go_up = True
     GoTo si36
  End If
           
    If si37 = ss(3,0) OrElse si37 = ss(3,1) OrElse si37 = ss(3,2) OrElse si37 = ss(3,3) OrElse _
       si37 = ss(3,4) OrElse si37 = ss(3,5) OrElse si37 = ss(3,6) OrElse si37 = ss(3,8) OrElse _
       si37 = ss(0,7) OrElse si37 = ss(1,7) OrElse si37 = ss(2,7) OrElse si37 = ss(4,7) OrElse _
       si37 = ss(5,7) OrElse si37 = ss(6,7) OrElse si37 = ss(7,7) OrElse si37 = ss(8,7) OrElse _
       si37 = ss(4,6) OrElse si37 = ss(4,8) OrElse si37 = ss(5,6) OrElse si37 = ss(5,8) Then GoTo si37

    ss(3,7) = si37        
    'lw.WriteLine(" ==> si37 - Passed si37 = " & si37.ToString)

  Else
    If Go_up = True Then GoTo si36          
  End If


si38:

  If si(3,8) = 0 Then

  Go_up = False
  si38 = si38 + 1
  If si38 > 9 Then
     si38 = 0
     ss(3,8) = 0        
     Go_up = True
     GoTo si37
  End If
           
    If si38 = ss(3,0) OrElse si38 = ss(3,1) OrElse si38 = ss(3,2) OrElse si38 = ss(3,3) OrElse _
       si38 = ss(3,4) OrElse si38 = ss(3,5) OrElse si38 = ss(3,6) OrElse si38 = ss(3,7) OrElse _
       si38 = ss(0,8) OrElse si38 = ss(1,8) OrElse si38 = ss(2,8) OrElse si38 = ss(4,8) OrElse _
       si38 = ss(5,8) OrElse si38 = ss(6,8) OrElse si38 = ss(7,8) OrElse si38 = ss(8,8) OrElse _
       si38 = ss(4,6) OrElse si38 = ss(4,7) OrElse si38 = ss(5,6) OrElse si38 = ss(5,7) Then GoTo si38

    ss(3,8) = si38        
    'lw.WriteLine(" ==> si38 - Passed si38 = " & si38.ToString)

  Else
    If Go_up = True Then GoTo si37          
  End If


si40:

  If si(4,0) = 0 Then

  Go_up = False
  si40 = si40 + 1
  If si40 > 9 Then
     si40 = 0
     ss(4,0) = 0        
     Go_up = True
     GoTo si38
  End If
           
    If si40 = ss(4,1) OrElse si40 = ss(4,2) OrElse si40 = ss(4,3) OrElse si40 = ss(4,4) OrElse _
       si40 = ss(4,5) OrElse si40 = ss(4,6) OrElse si40 = ss(4,7) OrElse si40 = ss(4,8) OrElse _
       si40 = ss(0,0) OrElse si40 = ss(1,0) OrElse si40 = ss(2,0) OrElse si40 = ss(3,0) OrElse _
       si40 = ss(5,0) OrElse si40 = ss(6,0) OrElse si40 = ss(7,0) OrElse si40 = ss(8,0) OrElse _
       si40 = ss(3,1) OrElse si40 = ss(3,2) OrElse si40 = ss(5,1) OrElse si40 = ss(5,2) Then GoTo si40

    ss(4,0) = si40        
    'lw.WriteLine(" ==> si40 - Passed si40 = " & si40.ToString)

  Else
    If Go_up = True Then GoTo si38          
  End If


si41:

  If si(4,1) = 0 Then

  Go_up = False
  si41 = si41 + 1
  If si41 > 9 Then
     si41 = 0
     ss(4,1) = 0        
     Go_up = True
     GoTo si40
  End If
           
    If si41 = ss(4,0) OrElse si41 = ss(4,2) OrElse si41 = ss(4,3) OrElse si41 = ss(4,4) OrElse _
       si41 = ss(4,5) OrElse si41 = ss(4,6) OrElse si41 = ss(4,7) OrElse si41 = ss(4,8) OrElse _
       si41 = ss(0,1) OrElse si41 = ss(1,1) OrElse si41 = ss(2,1) OrElse si41 = ss(3,1) OrElse _
       si41 = ss(5,1) OrElse si41 = ss(6,1) OrElse si41 = ss(7,1) OrElse si41 = ss(8,1) OrElse _
       si41 = ss(3,0) OrElse si41 = ss(3,2) OrElse si41 = ss(5,0) OrElse si41 = ss(5,2) Then GoTo si41

    ss(4,1) = si41        
    'lw.WriteLine(" ==> si41 - Passed si41 = " & si41.ToString)

  Else
    If Go_up = True Then GoTo si40          
  End If


si42:

  If si(4,2) = 0 Then

  Go_up = False
  si42 = si42 + 1
  If si42 > 9 Then
     si42 = 0
     ss(4,2) = 0        
     Go_up = True
     GoTo si41
  End If
           
    If si42 = ss(4,0) OrElse si42 = ss(4,1) OrElse si42 = ss(4,3) OrElse si42 = ss(4,4) OrElse _
       si42 = ss(4,5) OrElse si42 = ss(4,6) OrElse si42 = ss(4,7) OrElse si42 = ss(4,8) OrElse _
       si42 = ss(0,2) OrElse si42 = ss(1,2) OrElse si42 = ss(2,2) OrElse si42 = ss(3,2) OrElse _
       si42 = ss(5,2) OrElse si42 = ss(6,2) OrElse si42 = ss(7,2) OrElse si42 = ss(8,2) OrElse _
       si42 = ss(3,0) OrElse si42 = ss(3,1) OrElse si42 = ss(5,0) OrElse si42 = ss(5,1) Then GoTo si42

    ss(4,2) = si42        
    'lw.WriteLine(" ==> si42 - Passed si42 = " & si42.ToString)

  Else
    If Go_up = True Then GoTo si41          
  End If


si43:

  If si(4,3) = 0 Then

  Go_up = False
  si43 = si43 + 1
  If si43 > 9 Then
     si43 = 0
     ss(4,3) = 0        
     Go_up = True
     GoTo si42
  End If
           
    If si43 = ss(4,0) OrElse si43 = ss(4,1) OrElse si43 = ss(4,2) OrElse si43 = ss(4,4) OrElse _
       si43 = ss(4,5) OrElse si43 = ss(4,6) OrElse si43 = ss(4,7) OrElse si43 = ss(4,8) OrElse _
       si43 = ss(0,3) OrElse si43 = ss(1,3) OrElse si43 = ss(2,3) OrElse si43 = ss(3,3) OrElse _
       si43 = ss(5,3) OrElse si43 = ss(6,3) OrElse si43 = ss(7,3) OrElse si43 = ss(8,3) OrElse _
       si43 = ss(3,4) OrElse si43 = ss(3,5) OrElse si43 = ss(5,4) OrElse si43 = ss(5,5) Then GoTo si43

    ss(4,3) = si43        
    'lw.WriteLine(" ==> si43 - Passed si43 = " & si43.ToString)

  Else
    If Go_up = True Then GoTo si42          
  End If


si44:

  If si(4,4) = 0 Then

  Go_up = False
  si44 = si44 + 1
  If si44 > 9 Then
     si44 = 0
     ss(4,4) = 0        
     Go_up = True
     GoTo si43
  End If
           
    If si44 = ss(4,0) OrElse si44 = ss(4,1) OrElse si44 = ss(4,2) OrElse si44 = ss(4,3) OrElse _
       si44 = ss(4,5) OrElse si44 = ss(4,6) OrElse si44 = ss(4,7) OrElse si44 = ss(4,8) OrElse _
       si44 = ss(0,4) OrElse si44 = ss(1,4) OrElse si44 = ss(2,4) OrElse si44 = ss(3,4) OrElse _
       si44 = ss(5,4) OrElse si44 = ss(6,4) OrElse si44 = ss(7,4) OrElse si44 = ss(8,4) OrElse _
       si44 = ss(3,3) OrElse si44 = ss(3,5) OrElse si44 = ss(5,3) OrElse si44 = ss(5,5) Then GoTo si44

    ss(4,4) = si44        
    'lw.WriteLine(" ==> si44 - Passed si44 = " & si44.ToString)

  Else
    If Go_up = True Then GoTo si43          
  End If


si45:

  If si(4,5) = 0 Then

  Go_up = False
  si45 = si45 + 1
  If si45 > 9 Then
     si45 = 0
     ss(4,5) = 0        
     Go_up = True
     GoTo si44
  End If
           
    If si45 = ss(4,0) OrElse si45 = ss(4,1) OrElse si45 = ss(4,2) OrElse si45 = ss(4,3) OrElse _
       si45 = ss(4,4) OrElse si45 = ss(4,6) OrElse si45 = ss(4,7) OrElse si45 = ss(4,8) OrElse _
       si45 = ss(0,5) OrElse si45 = ss(1,5) OrElse si45 = ss(2,5) OrElse si45 = ss(3,5) OrElse _
       si45 = ss(5,5) OrElse si45 = ss(6,5) OrElse si45 = ss(7,5) OrElse si45 = ss(8,5) OrElse _
       si45 = ss(3,3) OrElse si45 = ss(3,4) OrElse si45 = ss(5,3) OrElse si45 = ss(5,4) Then GoTo si45

    ss(4,5) = si45        
    'lw.WriteLine(" ==> si45 - Passed si45 = " & si45.ToString)

  Else
    If Go_up = True Then GoTo si44          
  End If


si46:

  If si(4,6) = 0 Then

  Go_up = False
  si46 = si46 + 1
  If si46 > 9 Then
     si46 = 0
     ss(4,6) = 0        
     Go_up = True
     GoTo si45
  End If
           
    If si46 = ss(4,0) OrElse si46 = ss(4,1) OrElse si46 = ss(4,2) OrElse si46 = ss(4,3) OrElse _
       si46 = ss(4,4) OrElse si46 = ss(4,5) OrElse si46 = ss(4,7) OrElse si46 = ss(4,8) OrElse _
       si46 = ss(0,6) OrElse si46 = ss(1,6) OrElse si46 = ss(2,6) OrElse si46 = ss(3,6) OrElse _
       si46 = ss(5,6) OrElse si46 = ss(6,6) OrElse si46 = ss(7,6) OrElse si46 = ss(8,6) OrElse _
       si46 = ss(3,7) OrElse si46 = ss(3,8) OrElse si46 = ss(5,7) OrElse si46 = ss(5,8) Then GoTo si46

    ss(4,6) = si46        
    'lw.WriteLine(" ==> si46 - Passed si46 = " & si46.ToString)

  Else
    If Go_up = True Then GoTo si45          
  End If


si47:

  If si(4,7) = 0 Then

  Go_up = False
  si47 = si47 + 1
  If si47 > 9 Then
     si47 = 0
     ss(4,7) = 0        
     Go_up = True
     GoTo si46
  End If
           
    If si47 = ss(4,0) OrElse si47 = ss(4,1) OrElse si47 = ss(4,2) OrElse si47 = ss(4,3) OrElse _
       si47 = ss(4,4) OrElse si47 = ss(4,5) OrElse si47 = ss(4,6) OrElse si47 = ss(4,8) OrElse _
       si47 = ss(0,7) OrElse si47 = ss(1,7) OrElse si47 = ss(2,7) OrElse si47 = ss(3,7) OrElse _
       si47 = ss(5,7) OrElse si47 = ss(6,7) OrElse si47 = ss(7,7) OrElse si47 = ss(8,7) OrElse _
       si47 = ss(3,6) OrElse si47 = ss(3,8) OrElse si47 = ss(5,6) OrElse si47 = ss(5,8) Then GoTo si47

    ss(4,7) = si47        
    'lw.WriteLine(" ==> si47 - Passed si47 = " & si47.ToString)

  Else
    If Go_up = True Then GoTo si46          
  End If


si48:

  If si(4,8) = 0 Then

  Go_up = False
  si48 = si48 + 1
  If si48 > 9 Then
     si48 = 0
     ss(4,8) = 0        
     Go_up = True
     GoTo si47
  End If
           
    If si48 = ss(4,0) OrElse si48 = ss(4,1) OrElse si48 = ss(4,2) OrElse si48 = ss(4,3) OrElse _
       si48 = ss(4,4) OrElse si48 = ss(4,5) OrElse si48 = ss(4,6) OrElse si48 = ss(4,7) OrElse _
       si48 = ss(0,8) OrElse si48 = ss(1,8) OrElse si48 = ss(2,8) OrElse si48 = ss(3,8) OrElse _
       si48 = ss(5,8) OrElse si48 = ss(6,8) OrElse si48 = ss(7,8) OrElse si48 = ss(8,8) OrElse _
       si48 = ss(3,6) OrElse si48 = ss(3,7) OrElse si48 = ss(5,6) OrElse si48 = ss(5,7) Then GoTo si48

    ss(4,8) = si48        
    'lw.WriteLine(" ==> si48 - Passed si48 = " & si48.ToString)

  Else
    If Go_up = True Then GoTo si47          
  End If


si50:

  If si(5,0) = 0 Then

  Go_up = False
  si50 = si50 + 1
  If si50 > 9 Then
     si50 = 0
     ss(5,0) = 0        
     Go_up = True
     GoTo si48
  End If
           
    If si50 = ss(5,1) OrElse si50 = ss(5,2) OrElse si50 = ss(5,3) OrElse si50 = ss(5,4) OrElse _
       si50 = ss(5,5) OrElse si50 = ss(5,6) OrElse si50 = ss(5,7) OrElse si50 = ss(5,8) OrElse _
       si50 = ss(0,0) OrElse si50 = ss(1,0) OrElse si50 = ss(2,0) OrElse si50 = ss(3,0) OrElse _
       si50 = ss(4,0) OrElse si50 = ss(6,0) OrElse si50 = ss(7,0) OrElse si50 = ss(8,0) OrElse _
       si50 = ss(3,1) OrElse si50 = ss(3,2) OrElse si50 = ss(4,1) OrElse si50 = ss(4,2) Then GoTo si50

    ss(5,0) = si50        
    'lw.WriteLine(" ==> si50 - Passed si50 = " & si50.ToString)

  Else
    If Go_up = True Then GoTo si48          
  End If


si51:

  If si(5,1) = 0 Then

  Go_up = False
  si51 = si51 + 1
  If si51 > 9 Then
     si51 = 0
     ss(5,1) = 0        
     Go_up = True
     GoTo si50
  End If
           
    If si51 = ss(5,0) OrElse si51 = ss(5,2) OrElse si51 = ss(5,3) OrElse si51 = ss(5,4) OrElse _
       si51 = ss(5,5) OrElse si51 = ss(5,6) OrElse si51 = ss(5,7) OrElse si51 = ss(5,8) OrElse _
       si51 = ss(0,1) OrElse si51 = ss(1,1) OrElse si51 = ss(2,1) OrElse si51 = ss(3,1) OrElse _
       si51 = ss(4,1) OrElse si51 = ss(6,1) OrElse si51 = ss(7,1) OrElse si51 = ss(8,1) OrElse _
       si51 = ss(3,0) OrElse si51 = ss(3,2) OrElse si51 = ss(4,0) OrElse si51 = ss(4,2) Then GoTo si51

    ss(5,1) = si51        
    'lw.WriteLine(" ==> si51 - Passed si51 = " & si51.ToString)

  Else
    If Go_up = True Then GoTo si50          
  End If


si52:

  If si(5,2) = 0 Then

  Go_up = False
  si52 = si52 + 1
  If si52 > 9 Then
     si52 = 0
     ss(5,2) = 0        
     Go_up = True
     GoTo si51
  End If
           
    If si52 = ss(5,0) OrElse si52 = ss(5,1) OrElse si52 = ss(5,3) OrElse si52 = ss(5,4) OrElse _
       si52 = ss(5,5) OrElse si52 = ss(5,6) OrElse si52 = ss(5,7) OrElse si52 = ss(5,8) OrElse _
       si52 = ss(0,2) OrElse si52 = ss(1,2) OrElse si52 = ss(2,2) OrElse si52 = ss(3,2) OrElse _
       si52 = ss(4,2) OrElse si52 = ss(6,2) OrElse si52 = ss(7,2) OrElse si52 = ss(8,2) OrElse _
       si52 = ss(3,0) OrElse si52 = ss(3,1) OrElse si52 = ss(4,0) OrElse si52 = ss(4,1) Then GoTo si52

    ss(5,2) = si52        
    'lw.WriteLine(" ==> si52 - Passed si52 = " & si52.ToString)

  Else
    If Go_up = True Then GoTo si51          
  End If


si53:

  If si(5,3) = 0 Then

  Go_up = False
  si53 = si53 + 1
  If si53 > 9 Then
     si53 = 0
     ss(5,3) = 0        
     Go_up = True
     GoTo si52
  End If
           
    If si53 = ss(5,0) OrElse si53 = ss(5,1) OrElse si53 = ss(5,2) OrElse si53 = ss(5,4) OrElse _
       si53 = ss(5,5) OrElse si53 = ss(5,6) OrElse si53 = ss(5,7) OrElse si53 = ss(5,8) OrElse _
       si53 = ss(0,3) OrElse si53 = ss(1,3) OrElse si53 = ss(2,3) OrElse si53 = ss(3,3) OrElse _
       si53 = ss(4,3) OrElse si53 = ss(6,3) OrElse si53 = ss(7,3) OrElse si53 = ss(8,3) OrElse _
       si53 = ss(3,4) OrElse si53 = ss(3,5) OrElse si53 = ss(4,4) OrElse si53 = ss(4,5) Then GoTo si53

    ss(5,3) = si53        
    'lw.WriteLine(" ==> si53 - Passed si53 = " & si53.ToString)

  Else
    If Go_up = True Then GoTo si52          
  End If


si54:

  If si(5,4) = 0 Then

  Go_up = False
  si54 = si54 + 1
  If si54 > 9 Then
     si54 = 0
     ss(5,4) = 0        
     Go_up = True
     GoTo si53
  End If
           
    If si54 = ss(5,0) OrElse si54 = ss(5,1) OrElse si54 = ss(5,2) OrElse si54 = ss(5,3) OrElse _
       si54 = ss(5,5) OrElse si54 = ss(5,6) OrElse si54 = ss(5,7) OrElse si54 = ss(5,8) OrElse _
       si54 = ss(0,4) OrElse si54 = ss(1,4) OrElse si54 = ss(2,4) OrElse si54 = ss(3,4) OrElse _
       si54 = ss(4,4) OrElse si54 = ss(6,4) OrElse si54 = ss(7,4) OrElse si54 = ss(8,4) OrElse _
       si54 = ss(3,3) OrElse si54 = ss(3,5) OrElse si54 = ss(4,3) OrElse si54 = ss(4,5) Then GoTo si54

    ss(5,4) = si54        
    'lw.WriteLine(" ==> si54 - Passed si54 = " & si54.ToString)

  Else
    If Go_up = True Then GoTo si53          
  End If


si55:

  If si(5,5) = 0 Then

  Go_up = False
  si55 = si55 + 1
  If si55 > 9 Then
     si55 = 0
     ss(5,5) = 0        
     Go_up = True
     GoTo si54
  End If
           
    If si55 = ss(5,0) OrElse si55 = ss(5,1) OrElse si55 = ss(5,2) OrElse si55 = ss(5,3) OrElse _
       si55 = ss(5,4) OrElse si55 = ss(5,6) OrElse si55 = ss(5,7) OrElse si55 = ss(5,8) OrElse _
       si55 = ss(0,5) OrElse si55 = ss(1,5) OrElse si55 = ss(2,5) OrElse si55 = ss(3,5) OrElse _
       si55 = ss(4,5) OrElse si55 = ss(6,5) OrElse si55 = ss(7,5) OrElse si55 = ss(8,5) OrElse _
       si55 = ss(3,3) OrElse si55 = ss(3,4) OrElse si55 = ss(4,3) OrElse si55 = ss(4,4) Then GoTo si55

    ss(5,5) = si55        
    'lw.WriteLine(" ==> si55 - Passed si55 = " & si55.ToString)

  Else
    If Go_up = True Then GoTo si54          
  End If


si56:

  If si(5,6) = 0 Then

  Go_up = False
  si56 = si56 + 1
  If si56 > 9 Then
     si56 = 0
     ss(5,6) = 0        
     Go_up = True
     GoTo si55
  End If
           
    If si56 = ss(5,0) OrElse si56 = ss(5,1) OrElse si56 = ss(5,2) OrElse si56 = ss(5,3) OrElse _
       si56 = ss(5,4) OrElse si56 = ss(5,5) OrElse si56 = ss(5,7) OrElse si56 = ss(5,8) OrElse _
       si56 = ss(0,6) OrElse si56 = ss(1,6) OrElse si56 = ss(2,6) OrElse si56 = ss(3,6) OrElse _
       si56 = ss(4,6) OrElse si56 = ss(6,6) OrElse si56 = ss(7,6) OrElse si56 = ss(8,6) OrElse _
       si56 = ss(3,7) OrElse si56 = ss(3,8) OrElse si56 = ss(4,7) OrElse si56 = ss(4,8) Then GoTo si56

    ss(5,6) = si56        
    'lw.WriteLine(" ==> si56 - Passed si56 = " & si56.ToString)

  Else
    If Go_up = True Then GoTo si55          
  End If


si57:

  If si(5,7) = 0 Then

  Go_up = False
  si57 = si57 + 1
  If si57 > 9 Then
     si57 = 0
     ss(5,7) = 0        
     Go_up = True
     GoTo si56
  End If
           
    If si57 = ss(5,0) OrElse si57 = ss(5,1) OrElse si57 = ss(5,2) OrElse si57 = ss(5,3) OrElse _
       si57 = ss(5,4) OrElse si57 = ss(5,5) OrElse si57 = ss(5,6) OrElse si57 = ss(5,8) OrElse _
       si57 = ss(0,7) OrElse si57 = ss(1,7) OrElse si57 = ss(2,7) OrElse si57 = ss(3,7) OrElse _
       si57 = ss(4,7) OrElse si57 = ss(6,7) OrElse si57 = ss(7,7) OrElse si57 = ss(8,7) OrElse _
       si57 = ss(3,6) OrElse si57 = ss(3,8) OrElse si57 = ss(4,6) OrElse si57 = ss(4,8) Then GoTo si57

    ss(5,7) = si57        
    'lw.WriteLine(" ==> si57 - Passed si57 = " & si57.ToString)

  Else
    If Go_up = True Then GoTo si56          
  End If


si58:

  If si(5,8) = 0 Then

  Go_up = False
  si58 = si58 + 1
  If si58 > 9 Then
     si58 = 0
     ss(5,8) = 0        
     Go_up = True
     GoTo si57
  End If
           
    If si58 = ss(5,0) OrElse si58 = ss(5,1) OrElse si58 = ss(5,2) OrElse si58 = ss(5,3) OrElse _
       si58 = ss(5,4) OrElse si58 = ss(5,5) OrElse si58 = ss(5,6) OrElse si58 = ss(5,7) OrElse _
       si58 = ss(0,8) OrElse si58 = ss(1,8) OrElse si58 = ss(2,8) OrElse si58 = ss(3,8) OrElse _
       si58 = ss(4,8) OrElse si58 = ss(6,8) OrElse si58 = ss(7,8) OrElse si58 = ss(8,8) OrElse _
       si58 = ss(3,6) OrElse si58 = ss(3,7) OrElse si58 = ss(4,6) OrElse si58 = ss(4,7) Then GoTo si58

    ss(5,8) = si58        
    'lw.WriteLine(" ==> si58 - Passed si58 = " & si58.ToString)

  Else
    If Go_up = True Then GoTo si57          
  End If


si60:

  If si(6,0) = 0 Then

  Go_up = False
  si60 = si60 + 1
  If si60 > 9 Then
     si60 = 0
     ss(6,0) = 0        
     Go_up = True
     GoTo si58
  End If
           
    If si60 = ss(6,1) OrElse si60 = ss(6,2) OrElse si60 = ss(6,3) OrElse si60 = ss(6,4) OrElse _
       si60 = ss(6,5) OrElse si60 = ss(6,6) OrElse si60 = ss(6,7) OrElse si60 = ss(6,8) OrElse _
       si60 = ss(0,0) OrElse si60 = ss(1,0) OrElse si60 = ss(2,0) OrElse si60 = ss(3,0) OrElse _
       si60 = ss(4,0) OrElse si60 = ss(6,0) OrElse si60 = ss(7,0) OrElse si60 = ss(8,0) OrElse _
       si60 = ss(7,1) OrElse si60 = ss(7,2) OrElse si60 = ss(8,1) OrElse si60 = ss(8,2) Then GoTo si60

    ss(6,0) = si60        
    'lw.WriteLine(" ==> si60 - Passed si60 = " & si60.ToString)

  Else
    If Go_up = True Then GoTo si58          
  End If


si61:

  If si(6,1) = 0 Then

  Go_up = False
  si61 = si61 + 1
  If si61 > 9 Then
     si61 = 0
     ss(6,1) = 0        
     Go_up = True
     GoTo si60
  End If
           
    If si61 = ss(6,0) OrElse si61 = ss(6,2) OrElse si61 = ss(6,3) OrElse si61 = ss(6,4) OrElse _
       si61 = ss(6,5) OrElse si61 = ss(6,6) OrElse si61 = ss(6,7) OrElse si61 = ss(6,8) OrElse _
       si61 = ss(0,1) OrElse si61 = ss(1,1) OrElse si61 = ss(2,1) OrElse si61 = ss(3,1) OrElse _
       si61 = ss(4,1) OrElse si61 = ss(5,1) OrElse si61 = ss(7,1) OrElse si61 = ss(8,1) OrElse _
       si61 = ss(7,0) OrElse si61 = ss(7,2) OrElse si61 = ss(8,0) OrElse si61 = ss(8,2) Then GoTo si61

    ss(6,1) = si61        
    'lw.WriteLine(" ==> si61 - Passed si61 = " & si61.ToString)

  Else
    If Go_up = True Then GoTo si60          
  End If


si62:

  If si(6,2) = 0 Then

  Go_up = False
  si62 = si62 + 1
  If si62 > 9 Then
     si62 = 0
     ss(6,2) = 0        
     Go_up = Tru
 
Hi, thank you both for the reply.

Your block styler code which was given is greatly appreciated.

I've come up with the following code :

//==============================================================================
// WARNING!! This file is overwritten by the Block UI Styler while generating
// the automation code. Any modifications to this file will be lost after
// generating the code again.
//
// Filename: C:\Users\MTS PG 6\Desktop\BlockDialog2.cs
//
// This file was generated by the NX Block UI Styler
// Created by: MTS PG 6
// Version: NX 10
// Date: 04-21-2017 (Format: mm-dd-yyyy)
// Time: 11:20 (Format: hh-mm)
//
//==============================================================================

//==============================================================================
// Purpose: This TEMPLATE file contains C# source to guide you in the
// construction of your Block application dialog. The generation of your
// dialog file (.dlx extension) is the first step towards dialog construction
// within NX. You must now create a NX Open application that
// utilizes this file (.dlx).
//
// The information in this file provides you with the following:
//
// 1. Help on how to load and display your Block UI Styler dialog in NX
// using APIs provided in NXOpen.BlockStyler namespace
// 2. The empty callback methods (stubs) associated with your dialog items
// have also been placed in this file. These empty methods have been
// created simply to start you along with your coding requirements.
// The method name, argument list and possible return values have already
// been provided for you.
//==============================================================================

//------------------------------------------------------------------------------
//These imports are needed for the following template code
//------------------------------------------------------------------------------
using System;
using NXOpen;
using NXOpen.BlockStyler;

//------------------------------------------------------------------------------
//Represents Block Styler application class
//------------------------------------------------------------------------------
public class BlockDialog2
{
//class members
private static Session theSession = null;
private static UI theUI = null;
private string theDlxFileName;
private NXOpen.BlockStyler.BlockDialog theDialog;
private NXOpen.BlockStyler.Group group0;// Block type: Group
private NXOpen.BlockStyler.IntegerBlock integer0;// Block type: Integer
private NXOpen.BlockStyler.IntegerBlock integer01;// Block type: Integer
private NXOpen.BlockStyler.IntegerBlock integer02;// Block type: Integer
private NXOpen.BlockStyler.Group group01;// Block type: Group
private NXOpen.BlockStyler.LinearDimension linear_dim0;// Block type: Linear Dim
private NXOpen.BlockStyler.LinearDimension linear_dim01;// Block type: Linear Dim
private NXOpen.BlockStyler.LinearDimension linear_dim02;// Block type: Linear Dim
//------------------------------------------------------------------------------
//Bit Option for Property: SnapPointTypesOnByDefault
//------------------------------------------------------------------------------
public static readonly int SnapPointTypesOnByDefault_UserDefined = (1 << 0);
public static readonly int SnapPointTypesOnByDefault_Inferred = (1 << 1);
public static readonly int SnapPointTypesOnByDefault_ScreenPosition = (1 << 2);
public static readonly int SnapPointTypesOnByDefault_EndPoint = (1 << 3);
public static readonly int SnapPointTypesOnByDefault_MidPoint = (1 << 4);
public static readonly int SnapPointTypesOnByDefault_ControlPoint = (1 << 5);
public static readonly int SnapPointTypesOnByDefault_Intersection = (1 << 6);
public static readonly int SnapPointTypesOnByDefault_ArcCenter = (1 << 7);
public static readonly int SnapPointTypesOnByDefault_QuadrantPoint = (1 << 8);
public static readonly int SnapPointTypesOnByDefault_ExistingPoint = (1 << 9);
public static readonly int SnapPointTypesOnByDefault_PointonCurve = (1 <<10);
public static readonly int SnapPointTypesOnByDefault_PointonSurface = (1 <<11);
public static readonly int SnapPointTypesOnByDefault_PointConstructor = (1 <<12);
public static readonly int SnapPointTypesOnByDefault_TwocurveIntersection = (1 <<13);
public static readonly int SnapPointTypesOnByDefault_TangentPoint = (1 <<14);
public static readonly int SnapPointTypesOnByDefault_Poles = (1 <<15);
public static readonly int SnapPointTypesOnByDefault_BoundedGridPoint = (1 <<16);
public static readonly int SnapPointTypesOnByDefault_FacetVertexPoint = (1 <<17);

//------------------------------------------------------------------------------
//Constructor for NX Styler class
//------------------------------------------------------------------------------
public BlockDialog2()
{
try
{
theSession = Session.GetSession();
theUI = UI.GetUI();
theDlxFileName = "BlockDialog2.dlx";
theDialog = theUI.CreateDialog(theDlxFileName);
theDialog.AddApplyHandler(new NXOpen.BlockStyler.BlockDialog.Apply(apply_cb));
theDialog.AddOkHandler(new NXOpen.BlockStyler.BlockDialog.Ok(ok_cb));
theDialog.AddUpdateHandler(new NXOpen.BlockStyler.BlockDialog.Update(update_cb));
theDialog.AddInitializeHandler(new NXOpen.BlockStyler.BlockDialog.Initialize(initialize_cb));
theDialog.AddDialogShownHandler(new NXOpen.BlockStyler.BlockDialog.DialogShown(dialogShown_cb));
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
throw ex;
}
}
//------------------------------- DIALOG LAUNCHING ---------------------------------
//
// Before invoking this application one needs to open any part/empty part in NX
// because of the behavior of the blocks.
//
// Make sure the dlx file is in one of the following locations:
// 1.) From where NX session is launched
// 2.) $UGII_USER_DIR/application
// 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
// recommended. This variable is set to a full directory path to a file
// containing a list of root directories for all custom applications.
// e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
//
// You can create the dialog using one of the following way:
//
// 1. Journal Replay
//
// 1) Replay this file through Tool->Journal->Play Menu.
//
// 2. USER EXIT
//
// 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
// 2) Invoke the Shared Library through File->Execute->NX Open menu.
//
//------------------------------------------------------------------------------
public static void Main()
{
BlockDialog2 theBlockDialog2 = null;
try
{
theBlockDialog2 = new BlockDialog2();
// The following method shows the dialog immediately
theBlockDialog2.Show();
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
finally
{
if(theBlockDialog2 != null)
theBlockDialog2.Dispose();
theBlockDialog2 = null;
}
}
//------------------------------------------------------------------------------
// This method specifies how a shared image is unloaded from memory
// within NX. This method gives you the capability to unload an
// internal NX Open application or user exit from NX. Specify any
// one of the three constants as a return value to determine the type
// of unload to perform:
//
//
// Immediately : unload the library as soon as the automation program has completed
// Explicitly : unload the library from the "Unload Shared Image" dialog
// AtTermination : unload the library when the NX session terminates
//
//
// NOTE: A program which associates NX Open applications with the menubar
// MUST NOT use this option since it will UNLOAD your NX Open application image
// from the menubar.
//------------------------------------------------------------------------------
public static int GetUnloadOption(string arg)
{
//return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);
return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
// return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
}

//------------------------------------------------------------------------------
// Following method cleanup any housekeeping chores that may be needed.
// This method is automatically called by NX.
//------------------------------------------------------------------------------
public static void UnloadLibrary(string arg)
{
try
{
//---- Enter your code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//This method shows the dialog on the screen
//------------------------------------------------------------------------------
public NXOpen.UIStyler.DialogResponse Show()
{
try
{
theDialog.Show();
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}

//------------------------------------------------------------------------------
//Method Name: Dispose
//------------------------------------------------------------------------------
public void Dispose()
{
if(theDialog != null)
{
theDialog.Dispose();
theDialog = null;
}
}

//------------------------------------------------------------------------------
//---------------------Block UI Styler Callback Functions--------------------------
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//Callback Name: initialize_cb
//------------------------------------------------------------------------------
public void initialize_cb()
{
try
{
group0 = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("group0");
integer0 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer0");
integer01 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer01");
integer02 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer02");
group01 = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("group01");
linear_dim0 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim0");
linear_dim01 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim01");
linear_dim02 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim02");
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//Callback Name: dialogShown_cb
//This callback is executed just before the dialog launch. Thus any value set
//here will take precedence and dialog will be launched showing that value.
//------------------------------------------------------------------------------
public void dialogShown_cb()
{
try
{

}
catch (Exception ex)
{

theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//Callback Name: apply_cb
//------------------------------------------------------------------------------
public int apply_cb()
{
int errorCode = 0;
try
{
string[] coOrds = new string[3];


coOrds[0] = linear_dim0.ToString(); // Dimension Values
coOrds[1] = linear_dim01.ToString(); // Dimension Values
coOrds[2] = linear_dim02.ToString(); // Dimension Values


CreateBlock(coOrds);

//double[] dimension = new string[3];

//dimension[0] = (string)linear_dim0.ToString(); // attempt fail
//dimension[1] = (string)linear_dim01.ToString(); // attempt fail
//dimension[2] = (string)linear_dim02.ToString(); // attempt fail


//dimension[0] = (string)linear_dim0.Value(); // attempt fail
//dimension[1] = (string)linear_dim01.Value(); // attempt fail
//dimension[2] = (string)linear_dim01.Value(); // attempt fail

//string expression = dimension[0].ToString(); // attempt fail
//string expression = dimension[1].ToString(); // attempt fail
//string expression = dimension[2].ToString(); // attempt fail

}
catch (Exception ex)
{

errorCode = 1;
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return errorCode;
}

//------------------------------------------------------------------------------
//Callback Name: update_cb
//------------------------------------------------------------------------------
public int update_cb( NXOpen.BlockStyler.UIBlock block)
{
try
{
if(block == integer0)
{

}
else if(block == integer01)
{

}
else if(block == integer02)
{

}
else if(block == linear_dim0)
{

}
else if(block == linear_dim01)
{

}
else if(block == linear_dim02)
{

}
}
catch (Exception ex)
{

theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}

//------------------------------------------------------------------------------
//Callback Name: ok_cb
//------------------------------------------------------------------------------
public int ok_cb()
{
int errorCode = 0;
try
{
errorCode = apply_cb();
//---- Enter your callback code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
errorCode = 1;
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return errorCode;
}

//------------------------------------------------------------------------------
//Function Name: GetBlockProperties
//Returns the propertylist of the specified BlockID
//------------------------------------------------------------------------------
public PropertyList GetBlockProperties(string blockID)
{
PropertyList plist =null;
try
{
plist = theDialog.GetBlockProperties(blockID);
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return plist;
}

public void CreateBlock(string[] coOrds)
{
NXOpen.Session theSession = NXOpen.Session.GetSession();
NXOpen.Part workPart = theSession.Parts.Work;
NXOpen.Part displayPart = theSession.Parts.Display;

NXOpen.Features.Feature nullNXOpen_Features_Feature = null;

NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1;
blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullNXOpen_Features_Feature);

NXOpen.Point3d originPoint1 = new NXOpen.Point3d(0, 0, 0);

// blockFeatureBuilder1.SetOriginAndLengths(originPoint1, "100", "100", "100"); // old code
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, coOrds[0], coOrds[1], coOrds[2]);

NXOpen.Features.Feature feature1;
feature1 = blockFeatureBuilder1.CommitFeature();
}

}
//==============================================================================
// WARNING!! This file is overwritten by the Block UI Styler while generating
// the automation code. Any modifications to this file will be lost after
// generating the code again.
//
// Filename: C:\Users\MTS PG 6\Desktop\BlockDialog2.cs
//
// This file was generated by the NX Block UI Styler
// Created by: MTS PG 6
// Version: NX 10
// Date: 04-21-2017 (Format: mm-dd-yyyy)
// Time: 11:20 (Format: hh-mm)
//
//==============================================================================

//==============================================================================
// Purpose: This TEMPLATE file contains C# source to guide you in the
// construction of your Block application dialog. The generation of your
// dialog file (.dlx extension) is the first step towards dialog construction
// within NX. You must now create a NX Open application that
// utilizes this file (.dlx).
//
// The information in this file provides you with the following:
//
// 1. Help on how to load and display your Block UI Styler dialog in NX
// using APIs provided in NXOpen.BlockStyler namespace
// 2. The empty callback methods (stubs) associated with your dialog items
// have also been placed in this file. These empty methods have been
// created simply to start you along with your coding requirements.
// The method name, argument list and possible return values have already
// been provided for you.
//==============================================================================

//------------------------------------------------------------------------------
//These imports are needed for the following template code
//------------------------------------------------------------------------------
using System;
using NXOpen;
using NXOpen.BlockStyler;

//------------------------------------------------------------------------------
//Represents Block Styler application class
//------------------------------------------------------------------------------
public class BlockDialog2
{
//class members
private static Session theSession = null;
private static UI theUI = null;
private string theDlxFileName;
private NXOpen.BlockStyler.BlockDialog theDialog;
private NXOpen.BlockStyler.Group group0;// Block type: Group
private NXOpen.BlockStyler.IntegerBlock integer0;// Block type: Integer
private NXOpen.BlockStyler.IntegerBlock integer01;// Block type: Integer
private NXOpen.BlockStyler.IntegerBlock integer02;// Block type: Integer
private NXOpen.BlockStyler.Group group01;// Block type: Group
private NXOpen.BlockStyler.LinearDimension linear_dim0;// Block type: Linear Dim
private NXOpen.BlockStyler.LinearDimension linear_dim01;// Block type: Linear Dim
private NXOpen.BlockStyler.LinearDimension linear_dim02;// Block type: Linear Dim
//------------------------------------------------------------------------------
//Bit Option for Property: SnapPointTypesOnByDefault
//------------------------------------------------------------------------------
public static readonly int SnapPointTypesOnByDefault_UserDefined = (1 << 0);
public static readonly int SnapPointTypesOnByDefault_Inferred = (1 << 1);
public static readonly int SnapPointTypesOnByDefault_ScreenPosition = (1 << 2);
public static readonly int SnapPointTypesOnByDefault_EndPoint = (1 << 3);
public static readonly int SnapPointTypesOnByDefault_MidPoint = (1 << 4);
public static readonly int SnapPointTypesOnByDefault_ControlPoint = (1 << 5);
public static readonly int SnapPointTypesOnByDefault_Intersection = (1 << 6);
public static readonly int SnapPointTypesOnByDefault_ArcCenter = (1 << 7);
public static readonly int SnapPointTypesOnByDefault_QuadrantPoint = (1 << 8);
public static readonly int SnapPointTypesOnByDefault_ExistingPoint = (1 << 9);
public static readonly int SnapPointTypesOnByDefault_PointonCurve = (1 <<10);
public static readonly int SnapPointTypesOnByDefault_PointonSurface = (1 <<11);
public static readonly int SnapPointTypesOnByDefault_PointConstructor = (1 <<12);
public static readonly int SnapPointTypesOnByDefault_TwocurveIntersection = (1 <<13);
public static readonly int SnapPointTypesOnByDefault_TangentPoint = (1 <<14);
public static readonly int SnapPointTypesOnByDefault_Poles = (1 <<15);
public static readonly int SnapPointTypesOnByDefault_BoundedGridPoint = (1 <<16);
public static readonly int SnapPointTypesOnByDefault_FacetVertexPoint = (1 <<17);

//------------------------------------------------------------------------------
//Constructor for NX Styler class
//------------------------------------------------------------------------------
public BlockDialog2()
{
try
{
theSession = Session.GetSession();
theUI = UI.GetUI();
theDlxFileName = "BlockDialog2.dlx";
theDialog = theUI.CreateDialog(theDlxFileName);
theDialog.AddApplyHandler(new NXOpen.BlockStyler.BlockDialog.Apply(apply_cb));
theDialog.AddOkHandler(new NXOpen.BlockStyler.BlockDialog.Ok(ok_cb));
theDialog.AddUpdateHandler(new NXOpen.BlockStyler.BlockDialog.Update(update_cb));
theDialog.AddInitializeHandler(new NXOpen.BlockStyler.BlockDialog.Initialize(initialize_cb));
theDialog.AddDialogShownHandler(new NXOpen.BlockStyler.BlockDialog.DialogShown(dialogShown_cb));
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
throw ex;
}
}
//------------------------------- DIALOG LAUNCHING ---------------------------------
//
// Before invoking this application one needs to open any part/empty part in NX
// because of the behavior of the blocks.
//
// Make sure the dlx file is in one of the following locations:
// 1.) From where NX session is launched
// 2.) $UGII_USER_DIR/application
// 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
// recommended. This variable is set to a full directory path to a file
// containing a list of root directories for all custom applications.
// e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
//
// You can create the dialog using one of the following way:
//
// 1. Journal Replay
//
// 1) Replay this file through Tool->Journal->Play Menu.
//
// 2. USER EXIT
//
// 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
// 2) Invoke the Shared Library through File->Execute->NX Open menu.
//
//------------------------------------------------------------------------------
public static void Main()
{
BlockDialog2 theBlockDialog2 = null;
try
{
theBlockDialog2 = new BlockDialog2();
// The following method shows the dialog immediately
theBlockDialog2.Show();
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
finally
{
if(theBlockDialog2 != null)
theBlockDialog2.Dispose();
theBlockDialog2 = null;
}
}
//------------------------------------------------------------------------------
// This method specifies how a shared image is unloaded from memory
// within NX. This method gives you the capability to unload an
// internal NX Open application or user exit from NX. Specify any
// one of the three constants as a return value to determine the type
// of unload to perform:
//
//
// Immediately : unload the library as soon as the automation program has completed
// Explicitly : unload the library from the "Unload Shared Image" dialog
// AtTermination : unload the library when the NX session terminates
//
//
// NOTE: A program which associates NX Open applications with the menubar
// MUST NOT use this option since it will UNLOAD your NX Open application image
// from the menubar.
//------------------------------------------------------------------------------
public static int GetUnloadOption(string arg)
{
//return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);
return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
// return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
}

//------------------------------------------------------------------------------
// Following method cleanup any housekeeping chores that may be needed.
// This method is automatically called by NX.
//------------------------------------------------------------------------------
public static void UnloadLibrary(string arg)
{
try
{
//---- Enter your code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//This method shows the dialog on the screen
//------------------------------------------------------------------------------
public NXOpen.UIStyler.DialogResponse Show()
{
try
{
theDialog.Show();
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}

//------------------------------------------------------------------------------
//Method Name: Dispose
//------------------------------------------------------------------------------
public void Dispose()
{
if(theDialog != null)
{
theDialog.Dispose();
theDialog = null;
}
}

//------------------------------------------------------------------------------
//---------------------Block UI Styler Callback Functions--------------------------
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//Callback Name: initialize_cb
//------------------------------------------------------------------------------
public void initialize_cb()
{
try
{
group0 = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("group0");
integer0 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer0");
integer01 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer01");
integer02 = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("integer02");
group01 = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("group01");
linear_dim0 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim0");
linear_dim01 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim01");
linear_dim02 = (NXOpen.BlockStyler.LinearDimension)theDialog.TopBlock.FindBlock("linear_dim02");
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//Callback Name: dialogShown_cb
//This callback is executed just before the dialog launch. Thus any value set
//here will take precedence and dialog will be launched showing that value.
//------------------------------------------------------------------------------
public void dialogShown_cb()
{
try
{

}
catch (Exception ex)
{

theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}

//------------------------------------------------------------------------------
//Callback Name: apply_cb
//------------------------------------------------------------------------------
public int apply_cb()
{
int errorCode = 0;
try
{
string[] coOrds = new string[3];


coOrds[0] = linear_dim0.ToString(); // Dimension Values
coOrds[1] = linear_dim01.ToString(); // Dimension Values
coOrds[2] = linear_dim02.ToString(); // Dimension Values


CreateBlock(coOrds);

//double[] dimension = new string[3];

//dimension[0] = (string)linear_dim0.ToString(); // attempt fail
//dimension[1] = (string)linear_dim01.ToString(); // attempt fail
//dimension[2] = (string)linear_dim02.ToString(); // attempt fail


//dimension[0] = (string)linear_dim0.Value(); // attempt fail
//dimension[1] = (string)linear_dim01.Value(); // attempt fail
//dimension[2] = (string)linear_dim01.Value(); // attempt fail

//string expression = dimension[0].ToString(); // attempt fail
//string expression = dimension[1].ToString(); // attempt fail
//string expression = dimension[2].ToString(); // attempt fail

}
catch (Exception ex)
{

errorCode = 1;
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return errorCode;
}

//------------------------------------------------------------------------------
//Callback Name: update_cb
//------------------------------------------------------------------------------
public int update_cb( NXOpen.BlockStyler.UIBlock block)
{
try
{
if(block == integer0)
{

}
else if(block == integer01)
{

}
else if(block == integer02)
{

}
else if(block == linear_dim0)
{

}
else if(block == linear_dim01)
{

}
else if(block == linear_dim02)
{

}
}
catch (Exception ex)
{

theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return 0;
}

//------------------------------------------------------------------------------
//Callback Name: ok_cb
//------------------------------------------------------------------------------
public int ok_cb()
{
int errorCode = 0;
try
{
errorCode = apply_cb();
//---- Enter your callback code here -----
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
errorCode = 1;
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return errorCode;
}

//------------------------------------------------------------------------------
//Function Name: GetBlockProperties
//Returns the propertylist of the specified BlockID
//------------------------------------------------------------------------------
public PropertyList GetBlockProperties(string blockID)
{
PropertyList plist =null;
try
{
plist = theDialog.GetBlockProperties(blockID);
}
catch (Exception ex)
{
//---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
return plist;
}

public void CreateBlock(string[] coOrds)
{
NXOpen.Session theSession = NXOpen.Session.GetSession();
NXOpen.Part workPart = theSession.Parts.Work;
NXOpen.Part displayPart = theSession.Parts.Display;

NXOpen.Features.Feature nullNXOpen_Features_Feature = null;

NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1;
blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullNXOpen_Features_Feature);

NXOpen.Point3d originPoint1 = new NXOpen.Point3d(0, 0, 0);

// blockFeatureBuilder1.SetOriginAndLengths(originPoint1, "100", "100", "100"); // old code
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, coOrds[0], coOrds[1], coOrds[2]);

NXOpen.Features.Feature feature1;
feature1 = blockFeatureBuilder1.CommitFeature();
}

}


However, it tells me that block length must be greater then zero, meaning it is not recording and using the value that i've input from the block styler.. what am i doing wrong here?

Thanks in advance !

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor