Store data about boolean difference

I have a plug-in for Rhino 5 written part in VB Net 2005 and part in RhinoScript. As shown in the image below we have a box where we insert a cilynder. By using the _booleandifference command in Rhinoscript I get a hole in the box. I should store some informations in the box about the hole, in particular the hole’s position, diameter, depth and other data. How is it possible to do this? By using VB net can I override a function (the function wich I should get the boolean difference intead of using the Rhinoscript command) in order to store my informations in the geometry or other place of the box?
Any help will be very appreciated. Thanks.


The geometry’s UserDictionary or UserString is maybe a good place to store some data?

I think that both should be a good place, but I need to know the name of the function that I have to use or to override for storing the data in that place. Please, can you give me some idea or, better, an example?
Tkanks a lot Menno, ciao.

GeometryBase geometry; // any geometry, in your case probably Brep

double depth; // these should be known
Point3d position;

// setting values in the dictionary:
geometry.UserDictionary.Set("DEPTH", depth);
geometry.UserDictionary.Set("POSITION", position);

// retrieving values from the dictionary:
Point3d p;
double dep;
if (geometry.UserDictionary.TryGetPoint3d("POSITION", out p))
// point found with key "POSITION"
if (geometry.UserDictionary.TryGetDouble("DEPTH", out dep))
// value found with key "DEPTH"

Hi Menno,
tkank you for your fast response to my question.
Sorry if I insist. In wich function have I to put the routine that write data on the UserDictionary? I think it should be the function of the boolean difference, that’s the “RhinoBooleanDifference” by overwritting it. Is it correct what I say? Or there is another function that I have to use?
Another question: is it possible to store the result of the boolean difference, that’s the hole, in a different layer about the object that get the difference boolean? In my example is it possible to store the hole in another layer about the box?
Many thanks, ciao.

I don’t think i can help you further, unless you can post some code.

Here you see the actual routine with wich i get the boolean differences. With a previous routine a put the cylinder in the objects and then, with this routine, I get the boolean difference.

Public Sub Diff_Bool(Rhs As Object)
’ Receive: RhinoScript.
On Error GoTo Errore

Dim ArrLay As Variant, StrLay As Variant, ArrEle As Variant, ArrFer As Variant

' Make the boolean difference only for objects that are in some layers
ArrFer = Rhs.ObjectsByLayer("RI_LayFer")
ArrLay = Rhs.LayerNames
If IsArray(ArrLay) Then
    For Each StrLay In ArrLay
        If UCase(Left(StrLay, 9)) = "RI_LAYTIP" Then
            Rhs.Command "-_booleandifference '-_sellayer " & StrLay & " _enter _deleteinput=no '-_sellayer RI_LayFer '_enter", False
        End If
End If

' Delete all the cilynders
ArrFer = Rhs.ObjectsByLayer("RI_LayFer")
If IsArray(ArrLay) Then
    For Each StrLay In ArrFer
        Rhs.DeleteObject StrLay
End If
Exit Sub

As I told you in the first post, this is a routine that works in RhinoScript under a VB6 application, but, in this way I can’t write my data about boolean difference because I can’t get access to the user dictionary of the object.
I need a .net function and, in your previous post, you gave me a good example. The problem is that I don’t know where I have tu put that function, so as I told you in my previous post, I ask to you if it is correct to create a new function that owerwrite the boolean difference function that Rhino uses natively.
Always in the previous post I asked you if it’s possible to store the result of the boolean difference, that’s the hole in my case, in a different layer about the object that get the difference boolean (the box in may case).
I hope this can help you to understand my problem. Anyway, thanks for the time you are devoting to me. Ciao.

Ah, I see. My bad for not reading your message about scripting :blush:
You can’t “overwrite” the Rhino function with your own I’m afraid.

I don’t think you can store extra information this way. You would need to emulate the boolean difference command from code, not by scripting. Then it is possible to store extra information.

Ok Menno, I’m very happy: now you understand my problem.
In your post you say: “You would need to emulate the boolean difference command from code, not by scripting. Then it is possible to store extra information”. I know, I understand that I have to do this but I don’t know how, so this is the reason for wich I’m asking help. In other words can you tell me how can I emulate the boolean difference from code, what’s the function I have to overwrite for storing my extra information?
Can you tell me something about this?
Many thanks, bye.

To create a boolean union you would use this function

You need to get the input values from the user, typically by having the user select the part(s) they want to boolean. More info on that can be found here in an example showing how to do boolean difference:

The following links may also be of interest

Thank you Menno for the links you gave me. I think they are very useful for me, if I’ll have further question I’ll contact you. Have a nice WE. Ciao.