Can I create an object that doesn't get saved with python

python

(Cokepe) #1

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??


(Lando Schumpich) #2

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?


#3

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?


(Cokepe) #4

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.


(Chris Hanley) #5

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).


(Dale Fugier) #6

Can you tell us more about what you are doing and why? What kind object? Is it selectable and modifiable by the user?

– Dale


(Graham) #7

Hi Dale, (s)he already has :slight_smile:

Can I create an object that doesn't get saved with python


(Dale Fugier) #8

Thanks @Dancergraham for pointing this out.

My guess his this could be done with a DisplayConduit.

– Dale


(Cokepe) #9

Thanks @dale
Can you give more details as how to use DisplyConduit ( I asume it’s not DisplayCondout :wink: )

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.


(Dale Fugier) #10

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


(Cokepe) #11

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


#12

Save the guid of that solid in a variable and delete it before exiting your command? Maybe that is a viable approach.


(Dale Fugier) #13

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