Hellomanos wrote: ↑Wed Sep 21, 2022 7:14 pmopenBrain wrote: ↑Mon Nov 29, 2021 5:15 pm ......To me your request makes sense, as I understand it as "set object placement so it maps to a vertex, both potentially being in different CS".
This is just a few calculus. Lets consider :
* obj : the object to move
* sk : the object owning the target vertex (called 'sk' because you said its a sketch, but can virtually be anything)
* id : the id of the target vertex in 'sk' shape ('id' is basically 'name-1', for example "Vertex3" has id = 2)
As you're targeting a vertex, there's no way to define a particular rotation for the object so I'll leave it unchangedCode: Select all
skOffset = sk.getGlobalPlacement().multiply(sk.Placement.inverse()) # get sk root in GCS targetPos = skOffset.multVec(sk.Shape.Vertexes[id].Point) # get target point coordinates in GCS objOffset = obj.getGlobalPlacement().multiply(obj.Placement.inverse()) # get obj root in GCS obj.Placement.Base = objOffset.inverse().multVec(targetPos) # move obj origin to sk.id
There is a term "root" in the line :" skOffset = sk.getGlobalPlacement().multiply(sk.Placement.inverse()) # get sk root in GCS".
There is a same - root- at: https://forum.freecadweb.org/viewtopic.php?f=22&t=64608 but its meaning is not clear to me so please explain.
At the above code snippet there is the attribute inverse.
Also at the @edwilliams16 Sandbox there is the command :pli = box.Placement.inverse()
Also delta_part001 = container_global_placement.inverse() * delta_global * container_global_placement
What is the purpose of " Placement.inverse" command ?
Thanks in advance.