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.
@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
The DirectShape type in a Directshape wrapped in a Type. It is covered in the guide above.
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.
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.
Of course creating a standard Component Family and driving the parameters from Grasshopper works too.
Creating new System Families using Grasshopper. A guide is here.
As you can see the specific problems/situations help make solutions easier to explain.
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.
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
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.