User attributes advanced plugin

Hello,

I have something on my mind and i would like to eventually develop it.

It would be a plugin handling user attributes of objects in advanced fashion since rhinos native functionality is very limited.

I would like it to be separate plugin which would use extra file for storing special data related to plugin operations.

I want to achieve advanced functionality - text values from picklists, special formulas, for example if there is block inside block and the parent block could obtain information about objects inside of it, user would be able to pick subobjects and calculate their properties and similar operations to create true information database model.

I wanna ask few question how things work in principal so i can start thinking of plugins logic architecture:

  1. there seems to be problem with blocks because objects inside a block change their id when block is exploded or created - i want to workaround this using extra GUID as key/value generated by plugin so the identification is retained even when objects inside blocks are exploded. The question is how to access objects inside a block since when selecting using key/value, which i tested, omits objects inside blocks.

  2. for special attribute types i am thinking of “AreaOfSubFaces” and “LenghtOfSubEdges” i will need to define these so that the information for every object is stored in the plugin file. I can see namedselection function in rhino can store information even for selection of subobjects. My question is how are these subobjects uniquely indentified in rhino and what is the relation to the parent object. I wanna store the info about subfaces for brep in this fashion -> value of the attribute = for this object guid XYZ calculate area of these faces 1,2,3 -> i wonder how this 1,2,3 info is stored inside rhino and how 1,2,3 knows it belongs to XYZ object.

This plugin will be kind of hybrid it will store its own data based on generated guids and it will work with rhinos document user attributes as well. It will access the data in the document and based on assigned Guids do some operations with that data and write it back to document. For this purpose I have to be able to access objects inside blocks, be able to determine which objects belong to which block, be able to uniquely identify subobjects of objects and retreive information. Rest will be up on the plugin.

Thank you for the answer. This is first time i am trying to develop something and i need to dive a bit into logics of the program…

Hi Ivan,

If you’re into using Grasshopper, there is a plugin called Elefront which is similar in nature - inside the Grasshopper environment. As for your questions, I do not know much about Rhino, so I’ll let the other’s answer those for you.

Also, just a personal suggestion, if I may: if this is really the first time you’re developing something - it is my suggestion that you make a rough overall plan, but start with the smallest and simplest of tasks, release the ver1.0, and then iterate from there. Also be aware of scope-creep!

Good Luck!

~ ~ ~ ~ ~ ~ ~ ~
Kaushik LS
Chennai, IN

2 Likes

Hi, before you try going this way, did you know that there is a UserData base class in Rhinocommon? You can create own derivatives of this and even persist anything in the 3dm by overriding the correct methods. You should try if your questions already disappear when using this approach , since you use the inbuild mechanisms. Having a common base class is even a flexibe and elegant way of doing things, so I’m not quite sure what would be more flexible.

Of course writing to the derived UserData might be a problem. But you can think of creating a specialized command for this.

In case UserData objects are not maintained when exploding a block, you can use an hash of the geometric properties, instead of using an GUID to identify.

1 Like

Hello thanks for navigation. I am aware of elefront its a great plugin to handle attributes i am using it and it actually contributed to my thinking about extended functionality. Problem is that for elefront you need to access grasshopper environment which is not for every user and some operations ale not elegant to handle from gh. For example when i want to classify an object in rhino its easier to just click on object and eventually pick value from rolldown picklist. For dependent hierarchical classification it is even more complicated because level 2 dropdown list values are dependent on what you have picked in level 1. Imagine I classify object on level 1 = foundations on level 2 i will only get options like footing strip pile etc . If i classify object on level 1 as superstructure i will get options in level 2 like pier slab etc. This is not trivially achievable in any convential means in rhino or gh. My inspiration how the plugin should look is app TagSpaces for managing tags on files in windows.

This rhinocommon method sounds like exactly what is needed. To access userdata and even override processes. I will have a look into it. Thank you. I was aware of this rhino api but i have no knowledge whatsoever.

please have a look at attached document. i tried to sketch my mind about the plugin functionality. i hope it is self explaining.attribute plugin.3dm (916.4 KB)

1 Like

I agree, GH is at-times taxing to use. I think I understand what you mean. One possible (and a long) way that I can think of right away is to create a Windows Forms (or Eto Forms, if you want it to be cross platform) to create the entire app. And, If I’m not wrong, the TreeGridView is something similar to what you describe. Ofcourse, you’ll be using RhinoCommon for actual calculations.

I see you’ve attached a sketch/idea file. I’ll take a look after work.

~ ~ ~ ~ ~ ~ ~ ~
Kaushik LS
Chennai, IN

1 Like

Basic Gui development is not hard and essentially easier than to workaround Grasshopper logic. The more freedom you have, the easier it is. Essentially its like arranging “controls” (or “widgets”) on a window. You even have layout objects helping you with that. A TreeGridView is a special layout control, because it acts like a grid with the ability to add rows dynamically acting like a list view. Essentially its a listview with a grid layout, which also has the ability to group things (like tree view).
So its a combination of 3 ideas into one single control.

In Visual Studio there is even a GUI designer which lets you drag and drop it together (although I prefer doing it by text or code).

You only need to know two things. How to inject the Gui from a custom command and how to encapsulate it correctly. A gui is just there to tweak settings, it should not contain “model (=command) logic”. This is why usually on bigger projects you have 3 layers. The View (“the arrangement of GUI elements”), the ViewModel (“the layer of dealing with user interaction”) and the model layer (“The actual computation of whatever the purpose of your programm is”) . This MVVM pattern is whats difficult to implement, but you don’t have to do this on small apps.

Rhino is supposed to run on two platforms, so if you want to create multiplatform solutions you need to use a GUI wrapper, which targets platform specific technologies. Rhino uses Eto for that.The problem its a niche technology. Documentation and discussions on StackOverflow are minimal. I believe using Eto, should require to know one target framework like Forms, WPF (both Windows) or Cocoa (Mac), since its only a wrapper around it.

If you just target a Windows audience begin using WPF. Look into basic example which are not related to MVVM and create the GUI first in a seperate VS project. Make sure that your framework version matches to the required one of Rhino.

If you directly want to start with Eto, check the Rhino documentation about it. Hope this clarifies it a bit.

2 Likes

And if you are only looking for in-house use, you can still go with WinForms which is easier and has a lot of ressources (aka answered SO questions) available.