I need to generate an object, and when I save the file this object is not save with the file.
It is possible to do this in Pythonscript??
I need to generate an object, and when I save the file this object is not save with the file.
It is possible to do this in Pythonscript??
Definitely possible, although if you use rhinoscriptsyntax it will be a bit hacky i guess depending on the type of object.
It’s super easy in rhinocommon since nothing gets added to the file unless you say so.
What kind of pythonscripting are you using?
With a Python script you can create objects which are not displayed. These objects will not be saved. For example, I use a Python script to create a copy of the geometry of a mesh. Then I modify this geometry object by trimming away the parts outside of a curve. Then for the trimmed mesh geometry I compute the area and annotate this back on the original mesh. When this file is saved, the original mesh and its annotated text is saved but the trimmed mesh geometry object is not.
Is this the type of operation you want to perform?
Thanks Terry.
But no, that’s not it.
I have surfaces objects and I add a Thickness value as UserText inside the surface.
What I want is to display this surface as a solid with the corresponding thickness value, but only for visualization purposes, I don’t want the solid to be saved with the file.
Lando, I’m using python rhinoscript, but I think that there is not possible to do this using inly rhinoscript, and I also know that I can acces some rhinocommon commands through python.
Is using Grasshopper an option? If so, you could read the object attributes and use GH to preview the result?
In this example, the user text key and value needs to be attached to the attributes, not the object).
Can you tell us more about what you are doing and why? What kind object? Is it selectable and modifiable by the user?
– Dale
Hi Dale, (s)he already has
Thanks @Dancergraham for pointing this out.
My guess his this could be done with a DisplayConduit
.
– Dale
Thanks @dale
Can you give more details as how to use DisplyConduit ( I asume it’s not DisplayCondout )
But I think it’s not what I’m looking for. For what I could understand about DisplayConduit, It changes the way an object is visualized.
What I need is to create a virtual object, thaat is there during the working session and when I close rhino, that object vanish for ever.
It can. But it can also draw "stuff’ not in the Rhino document. For example, when you run Loft command and see the preview surface, that is drawing with a display conduit.
If you browse the code in the RhinoPython samples repo on GitHub, you will see a couple of display conduit examples.
I’ve also attached a sample script that allows you to select planar curve. It then extrudes the curves some fixed distance and displays them in a conduit.
SampleDrawExtrudedCurves.py (2.3 KB)
Enjoy!
– Dale
Thank you, very much, it works and is going to be very useful. Definitely I’m going to try to learn more about Display Conduits
But now I understand what where you thinking when you asked:
Is it selectable and modifiable by the user?
And the answer is yes, I need something a little more permanent, a solid that can be selected, can be intersected and used for clash detection with other solid created in the same way.
At least it has to be selectable, not modiafiable, since it is a “representation” of the original surface.
The main reason is why I’m asking this is to avoid to store the solids, since some of the solids that I’ve created are very dense and the final size of the rhino file increase exponentially.
Again, thank you very much for your answers
Save the guid of that solid in a variable and delete it before exiting your command? Maybe that is a viable approach.
Hi @cokepe,
If you dont’ mind a bit of a hack, then you might consider creating event watchers to handle Command.BeginCommand
and Command.EndCommand
events.
When a Command.BeginCommand
event occurs, look for commands like Save
, SaveAs
, and Export
. If this is the case, delete your objects. Then when the subsequent Command.EndCommand
event occurs, re-add your objects.
Maintaining the life of events watchers in Python is a bit of a challenge, because script begin and end. This you end up need to to store persistent stuff in the document’s sticky dictionary.
This is probably easier to to in a plug-in…
– Dale