Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

How to get property of a Block Styler Block if I do not know the name.

Hello,

 

I am trying to use the update or apply event to first trigger a simple messagebox which shows me the value

of the block. I understand that this is its property. So I am meant to use "GetProperties".

 

Following is what I tried to do so far.

 

//------------------------------------------------------------------------------
    //Callback Name: update_cb
    //------------------------------------------------------------------------------
    public int update_cb( NXOpen.BlockStyler.UIBlock block)
    {
        try
        {
            if(block == Block1)
            {
                int Stufenzahl = Block1.GetProperties().GetInteger("Value");
                MessageBox.Show(Stufenzahl.ToString());
                //MessageBox.Show(block.ToString() + " " + Block1.ToString());//---------Enter your code here-----------
                //MessageBox.Show(group0.GetProperties().GetInteger("value"));
            }
        }
        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
    //----------------------------

There was always Errors. I am hardly able to send them as they are in German.

 

So anyone please can read this code and let me know how to get hold of the value

of this block.

 

Thank you / Regards

Timo

13 REPLIES

Re: How to get property of a Block Styler Block if I do not know the name.

Without the error message its hard to say whats going wrong.

We can always "Google tranlsate"Smiley Wink

Or you could try the direct method to get the value:

int Stufenzahl = Block1.Value();
Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: How to get property of a Block Styler Block if I do not know the name.

What kind of block is Block1, is it really an integer block?

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: How to get property of a Block Styler Block if I do not know the name.

Hello and thank you for the Answers ,

 

Actually I do not know if it is integer Box or string. I can't get hold of the originaly build Dialog.

I tried several options with string and integer and get somhow always the message.

 

Bad property used for property name.

 

for both types of code.

                string StrStufenzahl = Block1.GetProperties().GetString("Value");
                MessageBox.Show(StrStufenzahl);

                int IntStufenzahl = Block1.GetProperties().GetInteger("Value");
                MessageBox.Show(IntStufenzahl.ToString());

Thank you For your support

 

Timo

 

 

Re: How to get property of a Block Styler Block if I do not know the name.

If I use following code

 

 string StrStufenzahl = Block1.GetProperties().GetString("Index");
 MessageBox.Show(StrStufenzahl);

I get following Error :

 

Invalid property name for the data block

 

Regards Timo

Re: How to get property of a Block Styler Block if I do not know the name.

If you don't even know the type of the block you can ask for it's type:

String blockType = Block1.type();

Once you know the block type, you should know what properties are available for that block.

I've had to do some work interrogating BlockDialog blocks before and created a bunch of constants to define the string names. Note that this is Java, but it does show you the names the type() method will return:

public static final String ButtonName = "Button";
public static final String NativeFileBrowserName = "NativeFileBrowser";
public static final String NativeFolderBrowserName = "NativeFolderBrowser";
public static final String ColorPickerName = "Color Picker";
public static final String RGBColorPickerName = "RGB Color Picker";
public static final String AngularDimName = "Angular Dim";
public static final String LinearDimName = "Linear Dim";
public static final String OnPathDimName = "On Path Dim";
public static final String RadiusDimName = "Radius Dim";
public static final String LabelName = "Label";
public static final String SeparatorName = "Separator";
public static final String ExpressionName = "Expression";
public static final String DrawingAreaName = "Drawing Area";
public static final String GroupName = "Group";
public static final String ScrolledWindowName = "Scrolled Window";
public static final String SelectExpressionName = "Select Expression";
public static final String EnumerationName = "Enumeration";
public static final String ListBoxName = "List Box";
public static final String MultilineStringName = "Multiline String";
public static final String StringValueName = "String";
public static final String ToggleName = "Toggle";
public static final String DoubleValueName = "Double";
public static final String IntegerValueName = "Integer";
public static final String OrientXpressName = "OrientXpress";
public static final String ReverseDirectionName = "Reverse Direction";
public static final String SelectPartName = "Select Part";
public static final String SelectionName = "Selection";
public static final String SelectObjectName = "Select Object";
public static final String CurveCollectorName = "Curve Collector";
public static final String FaceCollectorName = "Face Collector";
public static final String SectionBuilderName = "Section Builder";
public static final String SelectFeatureName = "Select Feature";
public static final String SuperSectionName = "Super Section";
public static final String SpecifyAxisName = "Specify Axis";
public static final String SpecifyPointName = "Specify Point";
public static final String SpecifyVectorName = "Specify Vector";
public static final String SpecifyCsysName = "Specify Csys";
public static final String SpecifyCursorLocationName = "Specify Cursor Location";
public static final String SpecifyOrientationName = "Specify Orientation";
public static final String SpecifyPlaneName = "Specify Plane";
public static final String TabsPageName = "Tabs Page";
public static final String DoubleTableName = "Double Table";
public static final String IntegerTableName = "Integer Table";
public static final String TableLayoutName = "TableLayout";
public static final String SetListName = "Set List";
public static final String BodyCollectorName = "Body Collector";
public static final String LineWidthName = "LineWidth";
public static final String TreeListName = "Tree Control";
public static final String WizardName = "Wizard";
public static final String SelectElementName = "Select Elements";

 

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: How to get property of a Block Styler Block if I do not know the name.

[ Edited ]

If you can run the application, why you can't just open the dlx file with block styler and look at the block type?

 

If you don't know the block type you can check the type in your code

int wert = 0;
if (Block1 is NXOpen.BlockStyler.IntegerBlock) {
   wert = ((NXOpen.BlockStyler.IntegerBlock)Block1).Value;
}
else if (Block1 is NXOpen.BlockStyler.StringBlock) {
   wert = int.Parse(((NXOpen.BlockStyler.StringBlock)Block1).Value);
}

As long as the dialog is alive (as it is in cb_update) you can use the direct method

 

Regards

Jan

Jan Böttcher

Re: How to get property of a Block Styler Block if I do not know the name.

Dim Block1 As ...

This block in your source code should tell you what kind of block it is.

In addition even if you don't have a block styler license you are able to open DLX files in the block styler in NX, but you are not allowed to save them.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: How to get property of a Block Styler Block if I do not know the name.


Stefan_Pendl schrieb:
Dim Block1 As ...

This block in your source code should tell you what kind of block it is.

Only if "Generate Block Specific Code" has been set to "True" in BlockStyler at save time.

Jan Böttcher

Re: How to get property of a Block Styler Block if I do not know the name.

If you're feeling brave, you could even open it up in an editor, it's basically XML...

I used to have an XML viewer but I replaced my laptop this year and its gone. But a quick Google turned up this: FOXE I just installed and it looks pretty good...

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5