Block name conflict detection

Hi,
I have a block with a certain name in my file. I am trying to import another file which has similar block name. Now because of this, i get “Block name conflict” prompt, which makes sense because there are two blocks with same name.

When I import the file, is there any way I could know that this prompt is going to show up? Probably some changes happening in InstanceDefinitionTable Class, or ObjectTable Class ?

I am trying to use RhinoApp.Idle event handler, so I could detect the conflict just before the “block name conflict” prompt is going to show up, but Im not sure where exaclty to look for.

Hi Darryl

What language are you developing in?
You could load the file with rhinocommon Rhino.FileIO
You can than read the instance definitions from that file and anticipate on name conflicts.

Does that make sense?

-Willem

@Willem I am using c#.
Yes, i am using Rhino.FileIO to read names of InstanceDefinitions first. But the thing is, there is a probability that there is no conflict even if the block names are same (for example the blocks are linked to same file, which I cannot check using FileIO). So this is why I am importing them,first.

Most of the times the conflict doesnt occur. But in some cases, it does, and when it does, i have no control over it from Rhinocommon, and I have to click using mouse manually. So i was thinking, if at all there is a change in property in one of the Rhino.DocObjects.Tables just before the Conflict occurs, I could probably change the block name temporarily, so as to avoid the prompt

Hi Darryl,

I see your point. Did you try to find a way to compare linked blocks.
There is https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_ModelComponent_ReferenceModelSerialNumber.htm

And

https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_ModelComponent_ModelSerialNumber.htm

I’m just browsing the API doc so maybe I’m sending you on a wild goose chase…

-Willem

@Willem Thanks for your suggestion. I have tried this as well. These values are not saved in 3dm archives. When I access them from FileIO, they always return 0.

Another thing is, even if the blocks are linked to same file path, there could still be conflicts (if someone has changed the block in file), so knowing their link paths is not a good option.

I have been trying for a long time to find out if I can anticipate this popup somehow, but not successful so far. It just shows up even before I know it, and then I have to use the mouse.

I suppose @dale might be the go to developer to help out in finding a way to catch these conflicts before they occur.

good luck!
-Willem

1 Like

Hi @Darryl_Menezes,

I’m not sure I can give you any rules to follow, expecially in C#. What problem are you trying to solve?

– Dale

Hi @dale,
I have a huge file with a lot of linked blocks (also nested links). I want to insert another block, which is linked to a particular filepath. I do this using Rhinocommon as follows:

  • I Add an InstanceDefinition with the required name to the InstanceDefinitionTable class using InstanceDefinitionTable.Add() method, with a random GeometryBase (Eg. Point at the origin)

  • Then I use InstanceDefinitionTable.ModifySourceArchive() method to link the InstanceDefinition to a specified path

Lets say the linked filepath has 10 blocks with similar names as the ones in current document. And for one of those blocks, the “Block name conflict prompt” is going to show up (because rhino thinks it is a different block). I want to know beforehand that this prompt is going to show up, and if so, for which block it is going to show up. Is there a way to do this?
How does Rhino compare if two blocks (with same name, and linked to the same file path) are similar or not?

Hi @Darryl_Menezes,

If it possible I can get those files (or something similar) and some sample code that repeats the problem?

– Dale

Hi @dale,
I have attached the rar file with blocks, and their respective links, and also the sample command.
I have linked the blocks to the ‘Public Documents’ folder, so it is better to extract the BlockTest.rar file in the Public Documents folder.
There is a file called BLockTest.3dm, and when you run the command in this file, the prompt shows up. I want to know if there is a way to find this out using RhinoCommon

BlockTest.rar (58.8 KB) BlockTestCommand.txt (3.1 KB)