Insert Block by 3 Points with "live preview" like "Orient3Pt" possible?

Hi,

I was asking myself if it was possible to create a command to insert a block more conveniently.
I wanna pick 3 points and they should define the plane the block gets inserted on.
So far I am capeable of this.

But in my eyes it would be very much more convenient if I could see how the position of the block looked like while inserting it. This would be equivalent to the way Orient3Pt works, where it’s super nice to be able to see the result while executing it and being able to correct the action possibly.

So far I think I understood how the Orient3Pt command works.
I guess everytime the position of the cursor get’s changed the view gets redrawn and the position of the cursor is evaulated, right? The plane at the at current position is evaluated and the objects are placed (“physically” in the model) and if this is not okay they get deleted or replaced with the new position chosen.

Is this assumption correct, or is there a better, maybe easier approach?
Thanks,
T.

1 Like

Hi @tobias.stoltmann,

Orient3Pt uses custom GetPoint-inherited classes that draw the transformed geometry dynamically. This is the recommended pattern, rather than the clunky delete/replace/redraw method.

For dynamically drawing instance definition, I’ve exposed a new DisplayPipeline.DrawInstanceDefinition that should make the dynamic drawing of blocks, during insertion, much easier. This new function will appears in SR15 (in a few weeks).

For an example of it’s usage, see this:

https://mcneel.myjetbrains.com/youtrack/issue/RH-66855

– Dale

4 Likes

Hi @dale,
sounds very good to me. :slight_smile:
So I will wait a few weeks, give it a try then and give you an update.
Thanks a lot (as always).

T.

RH-66855 is fixed in Rhino 7 Service Release 15

@brian
May I ask (as I am not super profound in C#) what this would have to look like in C#?`
I am having trouble with the input parameter e.

    def CalculateTransform(self, e):
        xform = Rhino.Geometry.Transform.Identity
        dir = e.Point - Rhino.Geometry.Point3d.Origin
        if (not dir.IsTiny()):
            xform = Rhino.Geometry.Transform.Translation(dir)
        return xform

Thanks,
T.

I suppose it’s GetPoint or EventArgs

@gankeyu
Tried it. In both cases it says

Operator ‘operator’ cannot be applied to operands of type ‘method group’ and ‘Point3d’

It’s probably Point()

@brian @dale
I work on Rhino 7 SR15 2022-2-8 (Rhino 7, 7.15.22039.13001), but I am not able to run this.
It simply inserts the block on the chosen insert point, but gives no option to orient the block.

What am I missing?

Hi @tobias.stoltmann,

I’ve attached a sample C# command for you to review.

TestTobias.cs (1.8 KB)

The issue resolved here (https://mcneel.myjetbrains.com/youtrack/issue/RH-66855) is to allow developers to dynamically draw instance definitions. It’s up to you to come up with the rest of the UI. So if you want to show an instance definition orienting, then you’ll need to compute the proper transformation and then pass this transform to DisplayPipeline.DrawInstanceDefinition.

– Dale

1 Like