RhinoCommon and InstanceDefinition : missing summaries

Hi @osuire ,

I’ve added a tracking item to make sure to add comments to these properties.

https://mcneel.myjetbrains.com/youtrack/issue/RH-62600

The InstanceDefinition.IsDeleted property indicates whether or not the object is deleted. When you delete objects in Rhino, they are not really deleted. They are just tagged as such. When Rhino saves a 3dm file, items tagged as deleted are not saved.

Most Rhino document objects have a IsDeleted property.

Yes. Now, if you iterate the document you might find instance references that use the deleted definition. But those references will also be tagged as deleted.

Hope this helps.

– Dale

Thanks Dale.

Blocks are tough. They deserve to be fully documented.
More code examples welcome :slight_smile:

Hi @osuire,

Feel free to request anything specific that you’d find helpful.

– Dale

OK ; about the following Python example :
-First, I wonder why it doesn’t contain the Method it’s supposed to illustrate.
-Second, I wonder why there is absolutely no “Syntax” examples for Python whatsoever in the documentation, but there’s still code examples in Python…

Comedy! I wonder what the comment and the example will show in the next releases… Let me guess: “Returns true, when this instance definition has been deleted”. Really I’m not against filling up missing comments or extending examples, but this is bourgeois. But okay critismn to this insults me as narrowminding and indoctrinated by communism (while I never lived in a communist state bytheway). **** *** !

Your remarks reveal either contempt for beginners or weak self-esteem.
In general, I view them as totally useless.

Follow-up about instance counts HERE.

Hi @osuire,

Attached is a Python script that is functionally equivalent to the C# code in the help documentation you’ve referenced.

test_rename_block.py (2.0 KB)

Hope this helps.

– Dale

1 Like

Thanks Dale,

Any Instance count example ? :grimacing:
I want to input definition names and output the total number of instances found in the model, including as sub-blocks.

For now, the only solution that works is through Elefront’s “Reference blocks By Name” but that guy is voracious in RAM and execution time !

Hi @osuire,

Not that I know of. Give me a few and I’ll see what I can some up with.

– Dale

1 Like

Hi @osuire,

How about this?

import Rhino
import scriptcontext as sc
import System

def block_count(idef_name):
    if System.String.IsNullOrWhiteSpace(idef_name):
        return 0
    idef = sc.doc.InstanceDefinitions.Find(idef_name, True)
    if not idef:
        return 0
    references = idef.GetReferences(1)
    if not references:
        return 0
    return len(references)

if __name__ == "__main__":
    idef_name = ""
    rc, idef_name = Rhino.Input.RhinoGet.GetString("Name of block to count references", True, idef_name)
    if rc == Rhino.Commands.Result.Success: 
        count = block_count(idef_name)
        Rhino.RhinoApp.WriteLine("Block references: {0}".format(count))

– Dale

Hi Dale, thank you for your script.
I realize it is not meant for Grasshopper.
I need to pass a list of names to a GH component and retrieve a list of integers (instance counts).

Here is the right thread with the proper context.

There seems to be a bug in Rhino with instance counts.

This is what makes the multiple attempts at making a script moot.

Hi @osuire,

I’ve replied to the thread you’ve referenced.

– Dale

1 Like

RH-62600 is fixed in the latest Rhino 7 Service Release Candidate

1 Like