Translate function

Hi,

I want translate a list of breps objects when the user move a determinate element.

I handle the event when the element is moved, and I propagate the new object’s position for translate my breps to the same position.

The translation works fine the first time, but after the translations is wrong.

For example

  1. Element is in 0,0,0

  1. The user move the element to 1000, 0,0. All Ok

  1. The user move the element to 1000, 1000, 0. KO. The Breps is moved to 2000, 1000, 0 not at 1000, 1000,0

The code for the translation is

Plugin.PuleCantos.ListaBrepContorno.ForEach(c => c.Translate(e.PosicionActual.X, e.PosicionActual.Y, e.PosicionActual.Z));

Where PosicionActual is the lower left corner of the element

I’m working with RhinoCommon and c#

HI Manolo

are you by any chance directly manipulating those Breps in the document? If so, this is probably the origin of the issue. Rhino likes to keep track of undo’s, redo’s, and similar edits to the document, so one needs to ensure to have a private copy and then post/commit that edited copy to the document.

Does that help?

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Piac,

No, the Breps are hidden. I show it in the images only for the visualization. So, the user can’t move the breps.

If I look at the image your math is doing something like this:

  • Stands on 0,0,0
  • Move X=1000, So you get 1000,0,0
  • Now Move Y=1000, so you think you would get 1000,1000,0 but your calculation is doing The X=1000 Extra and not calculating from your brep position.

So the new calculation = X = 1000 + 1000 = 2000 any Y = 0 + 1000 = 1000,
XYZ = 2000, 1000, 0.

Its adding the extra 1000 from last time instead of calculating it from 0.

Hope you can understand my explanation :slight_smile:

Cheers.

Yes, the function translate add X, Y, Z to the brep’s position, but I think that this function must translate to the point, not add…

I can’t find documentacion about this function works

I can solve the problem translating only one time when the user start the one process, but I like understand what is it wrong

So if I read correctly e.PosicionActual.X, e.PosicionActual.Y is the NEW position. Then you need to make a change in your Transform.

(I’m not very good in C++ or C# only decent with VB.net)

But you need to - current postion.

Plugin.PuleCantos.ListaBrepContorno.ForEach(c => c.Translate(e.PosicionActual.X - Currentpostion.X, e.PosicionActual.Y - CurrentPostion.Y, e.PosicionActual.Z - Currentpostion.Z));

So if you now have (1000,0,0) and move Y 1000 then X stays on the same postion.

(1000-1000, 1000-0, 0-0) Because the transform calculates from his CURRENT postion. Not from its original.
So you get:
(0,1000,0), Means.
move X nothing, because it didnt change so it gets 0
Move Y 1000, because you moved it.
move Z nothing. and z 0 because it didnt change.

Pictues make stuff clear they say. Hope mine also xD

1 Like

Thank you very much

It works perfectly

Great :slight_smile:
No problem :slight_smile: