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 !
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 !