Hi, I'm a beginner in blockstyler
where must I place the my instructions in the blockstyler.
Using the update or apply callback in the blockstyler generated code, will force instructions on ok + apply. But where must I place the instruction that the instructions execute while selection?
There is no callback that gets called specifically when the user makes a selection.
However, your Update callback will be called whenever the user does anything significant in any block in the dialog. And, when NX calls your Update callback, it will tell you which block the user touched. So, if you want to do something in response to a selection, you put code in your Update callback, and you execute it only when the user interacts with a selection block.
An Update callback typically has a sequence of "IF" statements that check which block was touched, and then execute the appropriate code.
Here's an example of a typical Update callback. It's from chapter 13 of the SNAP Getting Started Guide. It uses a BlockForm, rather than a BlockDialog, but the principle is the same.
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General) Dim myLine As NX.Line If changedBlock = thinDashedButton myLine = CreateLine() myLine.LineWidth = Globals.Width.Thin myLine.LineFont = Globals.Font.Dashed End If If changedBlock = thickSolidButton myLine = CreateLine() myLine.LineWidth = Globals.Width.Thick myLine.LineFont = Globals.Font.Solid End If End Sub
thank you on reply,
hm, yes, I did that you have discribed...
I select an object and the code should do something with this object.
update_cb requires still an apply...
> update_cb requires still an apply
Generally, that's not true. The Update callback will get called whenever the user modifies some block in the dialog. For example, the Update callback will get called if the user clicks an action button or a radio button, or enters a number or a text string. This all happens without the user clicking Apply. In the particular case of a Selection block, I'm not sure what actions trigger the Update callback.
For Selection block, update_cb is triggered when user is done with selecting all objects, it is not triggered for every single selection. This means in NX when you open your cunstom dialog which has selection block, object selection dialog gets opened which allows user to select objects, once user selects objects and clicks apply/ok button of selection dialog(not your custom dialog) the update_cb of selection block gets triggered.
I don't think thats quite right.
When you use selection blocks on a Blockstyler dialog, no other dialog gets opened. The selection is done using your dialog.
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX126.96.36.199 MP11 64bit Testing: NX188.8.131.52
Yes, I was wrong.
Actually I got confused between two different methods I used in my projects to select objects using custom dialog box.
In one method I used selection block to select objects in which no other dialog box is displayed but selection is done using your custom dialog. In this method the update_cb should get triggered as user selects object but I am not sure as I did not executed any code on selection using this method.
In other method where there was a requirement to execute a code after user selects all objects, I created a dialog box which has a button. When user clicks this button, it triggers update_cb and in this callback I first execute a code "UI.GetUI().SelectionManager.SelectTaggedObjects( )" which opens selection dialog box, where user selects all objects and once he clicks apply/ok I get all selected objects. Then I execute my further code to complete the requirement.