RiR - New Direct Shape using old Geometry, retain props & material

I’m aware that Direct Shapes cannot be meaningfully modified after creation. I use Direct Shapes on categories with category assigned materials for a lot of imported geometry. I have a lot of Direct Shapes which have been assigned the incorrect category. I’ve tried a few times to build a script that rebuilds direct shapes on a specified category. Something like…

Get one or multiple Model Elements
Read all their properties (Workset, Phase, Parameters, Material, Geometry)
Create a new BRep-based or Mesh-based Direct Shape on the correct category
Assign all previous properties to this new element
If element creation is success, delete the old element.

Has anyone else tried tackling this problem? Any advice on alternatives? My script is not in a state to share at the moment, but my issues tend to be…

  • Material retrieval sometimes fails on Direct Shapes. Haven’t found a root cause
  • Parameters must be managed carefully, since the new category may not have the same parameters available
  • Direct Shape meshes that are valid in the Document are sometimes rejected as invalid when creating a new Direct Shape

I guess my only specific question: Is this as hard as I’m making it out to be? Is there some other way to hot-swap the category of a Direct Shape? Using Families is not an option for this scope. I’m using Families elsewhere with better success.

Hi @Alexander_Kaplan ,

I have created this step by step workflow for DirectShapes.

If you still face the issue Feel free to post on this thread

@Muhammad_Saqlain_Awa this is an excellent script you’ve shared in the other thread and it demonstrates some new functionality I wasn’t aware of.

Where I am stuck is if you wanted to update your foundations without deleting them. I believe you would face the same issue I do now. I do not believe the script addresses that, although it’s certainly worthy of being pinned or otherwise promoted in this forum. Very comprehensive approach

1 Like

It really is that difficult. But, in the same breath there knowing the full set of tools available is key to under standing what is possible.

Revit’s options can change within Categories. Here is a spreadsheet showing what is possible in each Category.

Generally any common or custom parameter must be made as a Shared Parameter and then integrated into Schedules and tables with some tricks. This way Parameters can be normalized across Families if needed.

There are generally 4 main object types that Grasshopper can control in Revit:

  1. The Directshape. Boring and many times not super useful. But easy. Here is a guide about them.
  2. The DirectShape type in a Directshape wrapped in a Type. It is covered in the guide above.
  3. The Family instance Form based. This is the hidden secret. Create a Family that contains a NURBS Form. These can be placed in Sub-categories also. A guide about creating those is here.
  4. Family Forms in System Categories. Some categories do no always have templates to create new Component Families in them. There is a trick to do this allowing to use a wider array fo family types for Component Families: Here is a Guide.
  5. Of course creating a standard Component Family and driving the parameters from Grasshopper works too.
  6. Creating new System Families using Grasshopper. A guide is here.

As you can see the specific problems/situations help make solutions easier to explain.

1 Like

Thank you for the thorough response, hopefully others will find this useful too. Can you add the link to the Family instance - Form Based object? The renaming trick for creating an RTF is also new to me. That will be useful for sure. Other workflows I do involve creating families directly and the limited templates were a problem.

Yeah the RTF rename is really quite a hack, but it works!

This is a tutorial that looks at loadable families. One of my favorite ways to doing it.

1 Like

Maybe you meant this link?

Yes, thank you updated.

I’ve made some good progress and have a decent working script. I’m not able to share the script, but some advice to others building similar:

Disable tracking on the Direct Shape node. You’ll need to rely on Revit’s undo for any mistakes. You’re also liable to create duplicates if you’re haphazard.
Use two triggers, one for element creation, one for deletion. Use List lengths of your created element to verify a successful re-work before hitting the delete trigger

I am still not able to figure out why some Direct Shapes fail to report a material through the Material node

1 Like

For what it’s worth, the cross bracing in this file fails to extract a material, although I’m able to see it through the Snoop / Revit Lookup tool.

Hi @Alexander_Kaplan
You can use Element Preview component

1 Like

Reassign DirectShape Category.gh (25.7 KB)

Here is my working script. Pretty reliable for my purposes. You still need to be on the lookout for Bad Objects coming from the Document, since they will get ingested into Grasshopper but then fail on Direct Shape creation. There are some panels to help keep an eye on # of created vs # of expected elements.

For the google SEO I’ll mention I am managing Generic Model Category Elements created from IFC imports.

1 Like