Filters in blender

Hello,

How does the “Filter” option work in the Blender add-on or in other words what is the syntax?
image

For example, if I wanted to pull only the geometry of “Rooms” that were uploaded into Speckle from Revit, how would I specify this filter?

Thanks

1 Like

hiya!

unfortunately, the filtering option has not been fully implemented yet :see_no_evil:

for now, a workaround would be to utilise the send / receive functions. essentially, you can add a python function that runs one either send or receive that takes the scene and each object as the argument.

for example, let’s say i am receiving this stream

if I wanted to filter out everything from the receive that isn’t a floor (my example here doesn’t have any rooms :sweat_smile: ), I could do something like the following:

import bpy

def execute(scene, obj):
    print(obj.name)
    if "Objects.BuiltElements.Floor" not in obj.name:
        bpy.data.objects.remove(obj, do_unlink=True)
        return None
    else:
        return obj

and select it as the receive function:

1 Like

Cool, that’s exactly what I want to achieve. The issue I’m running into now is that the obj.name for a Room coming from Revit is the Room’s name (ex.: “A101”), and not the “Objects.BuiltElements.Room” I was hoping for.

Is the “Category” of the object available somewhere in the Speckle data in Blender?

Thanks!

1 Like

ah, good point! that’s what I get for just using the first revit stream I could find and not going and creating a rooms example :sweat_smile:

this is a bit funny as in blender we only care about the geometry, so the objects you see are the display meshes within revit objects meaning they’re one level down and don’t have any info about the parent. I can see how this could be annoying if you’re wanting to work with revit stuff a bit more thoroughly in blender.

I think this is part of a larger issue I’ll need to think about, but for now I’ve made a quick fix of adding the parent_speckle_type as a custom property so at lest you know where the display mesh came from.

v2.2.8 of the connector is building now, so once it’s on manager and you are able to install it, you should be able to do something like this:

import bpy

FILTER = "Objects.BuiltElements.Wall"

def execute(scene, obj):
    parent_type = obj.get("parent_speckle_type")
    
    if parent_type and FILTER in parent_type:
        return obj
    else:
        bpy.data.objects.remove(obj, do_unlink=True)
        return None

hope that’s a good enough solution for now!

1 Like

Thank you so much for looking into this.

That property “parent_speckle_type” appears on “normal” objects such as Duct, Fittings, etc (although for fittings, air terminals, etc it shows “Objects.BuiltElements.Revit.FamilyInstance” which is very generic, but that’s not the point of this thread…)

Here a duct is selected:
image

For rooms however, I do not see that property:
image

So the filtering works for Ducts, Walls and probably other categories but not for Rooms at this point.

Re the type being “generic” - there’s nothing I can really do about that as it’s just pulling whatever speckle_type the parent is and attaching it to the display mesh that you see in blender. If it was a family instance, then that’s the type that gets attached. We don’t have speckle models for stuff as specific as fittings and air terminals so they get converted to speckle as family instances.

Re the rooms, I’m afraid I can’t replicate this. Here is a commit I just received where I am just pulling the room volumes:

If you’re not seeing a parent_speckle_type there, then what you’re looking at isn’t the display mesh for any parent object - it’s simply a root object. It sounds like you’re trying to filter for something that isn’t actually a room. If you’re able to share more info about the objects you’re trying to pull (a direct link to the object would be fab!), then we can investigate.

This is the specific commit (same stream where I added you as a collaborator): Speckle

From what I can see, they are indeed Rooms:

But when I pull it into Blender and select it:
image

hmmm something fishy is going on… I just received the commit in question and everything looks as expected. weird that the name is showing up for you as a custom prop though - it’s part of the Room model so shouldn’t be added there

I’ll have another look in the morn, but I’m guessing it must be something in your environment as I can’t reproduce the issue. perhaps a debug call is in order!

Hi,

So I think the property thing was “user error” :sweat_smile: since I tried it again and it’s working. I may have been pulling a commit that was generated in Blender and not Revit and that’s why I wasn’t seeing the properties.

In any case, the filtering method works! Although a little slow since from my understanding we are removing elements from the model after downloading everything and not filtering at the server query level.

Thanks again!

2 Likes

yes, you’re correct - this is a workaround for now as filters are still to be implemented!

I’m very glad to hear it’s all working for you now though! happy I could help :sparkles:

1 Like