Hi everyone,
Iām experiencing a frustrating problem with the context bake function in my Grasshopper script. Hereās a detailed of the issue:
Problem:
When I input the result of my GH script into the context bake, most of the meshes are missing after being handed over to Viktor.
Troubleshooting Steps Taken:
- Direct Connection:
- I tried connecting only the meshes that were missing.
- This resulted in an error message: āThe loaded geometry is missing a meshā.
- Internalizing Meshes:
- I internalized all the meshes before connecting them to the context bake.
- Interestingly, all meshes are displayed correctly within Viktor when internalized, suggesting the issue is not with the meshes themselves?
The meshes are correctly generated by the script but seem to fail during the bake process.
Has anyone encountered a similar issue with context bake in Grasshopper?
Are there known bugs or limitations with the context bake function that could be causing this?
Could there be a specific setup or process required to ensure all meshes are correctly handed over to Viktor?
Any insights, suggestions, or workarounds would be greatly appreciated. Thank you!
Best,
Max
The Meshes i hand over to Context Bake
Result in Viktor:
Hi @Mulimark ,
Nice to see you working with Grasshopper! Welcome to this forum!
There are 2 solutions to this issue:
- The simple solution: Join all meshes together into 1 and add that mesh to your Context Bake.
- The complete solution: Iām quite sure the encoded meshes will all be in your output dict. You will have to dive into the output dict, locate your āContext Bakeā output and loop through all the encoded meshes in the list. You can run
obj = rhino3dm.CommonObject.Decode(json.loads(output_geometry))
file3dm.Objects.Add(obj)
to decode and add the meshes to your 3dm file.
Last tip to add; to add color to the mesh use the Mesh Colours
-Grasshopper component! These colors will be loaded into the Viktor view (unfortunately opacity doesnāt work yet).
Hopefully that helps, otherwise let me know!
Rick
Hi Rick,
Thanks for your response and warm welcome!
I tried your suggested solutions, but Iām still facing some issues. Hereās an update on what Iāve done:
I attempted to join all the meshes into one and add that single mesh to the Context Bake. Unfortunately, or interestingly the same meshes (wall, roof, etc.) are missing after the bake.
I think I am already iterating through the entire output, different meshes are already displayed (e.g. window and floor). But if not then the solution above with the single mesh should still work.
Here is my current code:
file3dm = rhino3dm.File3dm()
inner_tree = output["values"][0]["InnerTree"]
for key in inner_tree:
for data_item in inner_tree[key]:
obj = rhino3dm.CommonObject.Decode(json.loads(data_item["data"]))
file3dm.Objects.Add(obj)
Signgular Meshes still missing with joined output:
Thanks for the extensive look into your project! For now I donāt see anything weird.
Just to check; if you inspect the mesh list, does it contain Invalid Meshes? Invalid meshes cannot be loaded into the view.
To further check whatās going on, you could try baking everything and then try to upload the 3dm file to a FileField
manually. Does that show your missing walls?
class Parametrization(ViktorParametrization):
model = FileField('Model', file_types=['.3dm'])
class Controller(ViktorController):
label = 'My Entity Type'
parametrization = Parametrization(width=30)
@GeometryView("Show Geometry", duration_guess=0, x_axis_to_right=True)
def show_3dm(self, params, **kwargs):
return GeometryResult(geometry=params.Model.file, geometry_type="3dm")
Hi Rick,
Thanks again for your previous suggestions. After further testing, Iāve identified that the issue seems to be related to certain Grasshopper plugins. For example, meshes generated using ArqiSharp3D for modeling the roof do not transfer into Viktor. The roof mesh, as you can see in the attatched Pictures, fails to appear.
Without altering the script significantly, could saving the geometry to a temporary file in the folder of the app and then accessing that file in Viktor be a viable solution? This approach seems promising since internalizing the meshes within Grasshopper itself worked as expected. If so, could you provide any tips or guidance on how to implement this?
Thank you very much for the time you are dedicating to me!
Best regards,
Max
Hi @Mulimark,
I have tried out ArqiSharp and can confirm the plugin is indeed not compatible with Rhino.Compute. To my knowledge, there is no list of plugins which are not compatible, but I do know the list is very small (seems you are unlucky here ).
The VIKTOR <> Grasshopper integration is using Rhino.Compute. This means that if we canāt run a plugin, you will not be able to run ArqiSharp in any Rhino cloud solution unfortunately. This is due to the fact that Rhino.Compute runs headless, it has no active Rhino document, and some plugins use that active Rhino Document. Andy Payne explaining this issue.
As the plugin is still actively maintained, you could try to reach out to the developer on the McNeel forum, and ask if they could look into solving this.
Hopefully, that sheds a bit more light.
Rick