[RhinoPyhon] Dynamic Draw for Inserting objects

Hello, I’m new to python and to rhino as well, but have managed to make some simple scripts.

I’ve made a script that works similar to Rhino’s Orient command, but uses a second target point as a first target point for next object. It works fine for me, but I wonder if somebody could help me make a predraw for objects that I’m inserting. I read some articles on the Dynamic Draw, but did not manage to implement that.

OrientObjects.py (729 Bytes)

Orient uses a plane to plane rotation transformation to orient objects to a new location. This will be helpful when calculating the transformation for some kind of dynamic draw operation.

The following is a sample Move command that does some dynamic drawing. You can sue this as a starting point for an Orient clone.

1 Like

Thanks for your replay, but I could not get this to work.
It says:
Message: ‘GetTranslation’ object has no attribute ‘AddObject’ after I “Select objects to move” and “Point to move from”

I get the same error.
So I don’t know who wrote that script :wink:

Hi Dale
The same error here
Ciao Vittorio

Whoops, sorry about that. Not sure how that got committed.

Anyway, here is a C# sample that dynamically draws objects being oriented perpendicular to a curve. You should be albe to port this to Python. Let me know if you can’t…

Hello dale

This sample was very useful for me.

I have a small question.
I am making a similar script and I would like the dynamic draw to be displayed in the active viewport display or in « shaded «
Not in wires.

Do you have an exemple for this ?

Thank’s

Sylvain

Hi @kieffer,

I don’t believe there is a sample for that. But drawing stuff dynamically and shaded will take some effort.

Dynamic drawing is designed to be fast. Thus, it doesn’t support any depth buffering (what makes shaded things drawing in front or behind other object), or shadows.

But if you don’t care this, then all you really need to do is this:

...
e.Display.PushDepthTesting(true);
e.Display.PushDepthWriting(true);
e.Display.DrawMeshShaded(mesh, material)
e.Display.PopDepthWriting();
e.Display.PopDepthTesting();
...

To really draw shaded object properly, you’ll need to write a custom display conduit.

– Dale

2 Likes

Thanks Dale

here is my script for the moment,and what i’am tryng to achieve.(work in progress)
He is made from parts of script i found in the forum and in samples(thank’s to everybody) and a 3dm test file.
DynamicDrawSrf_Exemple.py (3.4 KB) dynamic draw.3dm (221.9 KB)

I will try it thank’s again

I tried to place the different options you indicate me but i am new in scripting and not very good with rhino common.
i post what i tried, do you know what am i doing wrong ?

Sylvain
DynamicDrawSrf_Exemple2py.py (3.1 KB)