Notifications
Clear all
[Closed] How to crete a box along an edge ?
Nov 21, 2005 3:20 pm
Hi,
Basically, I would like to place a box along one edge of a mesh.
I have tried different ways with no luck
i can get the position, by using the vertices,
but can’t align the rotation …
Could anyone help me out ?
thanks in advance.
3 Replies
2 Replies
Every node has a .DIR property which is coincident with its positive Z axis.
So you can place the box at the first vertex and set the .DIR property to the vector defined by the second vertex minus the first vertex. Voila!
(
fn createBox v1 v2 theName =
(
b = box width:1 length:1 height:(distance v1 v2) name:("Edge_"+theName)
b.dir = v2 - v1
b.pos = v1
b
)
fn createEdgeBoxes theObj =
(
theMesh = snapshotasmesh theObj
edgesDone = #()
for f = 1 to theMesh.numfaces do
(
theFace = getFace theMesh f
theVert1 = getVert theMesh theFace.x
theVert2 = getVert theMesh theFace.y
theVert3 = getVert theMesh theFace.z
if (getEdgeVis theMesh f 1) AND findItem edgesDone (theFace.x as string + "_" + theFace.y as string) == 0 do
(
createBox theVert1 theVert2 (theFace.x as string + "_" + theFace.y as string)
append edgesDone (theFace.x as string + "_" + theFace.y as string)
append edgesDone (theFace.y as string + "_" + theFace.x as string)
)
if (getEdgeVis theMesh f 2) AND findItem edgesDone (theFace.y as string + "_" + theFace.z as string) == 0 do
(
createBox theVert2 theVert3 (theFace.y as string + "_" + theFace.z as string)
append edgesDone (theFace.y as string + "_" + theFace.z as string)
append edgesDone (theFace.z as string + "_" + theFace.y as string)
)
if (getEdgeVis theMesh f 3) AND findItem edgesDone (theFace.x as string + "_" + theFace.z as string)== 0 do
(
createBox theVert1 theVert3 (theFace.x as string + "_" + theFace.z as string)
append edgesDone (theFace.x as string + "_" + theFace.z as string)
append edgesDone (theFace.z as string + "_" + theFace.x as string)
)
)--end f loop
)--end script
for o in selection where superclassof o == GeometryClass and classof o != TargetObject do createEdgeBoxes o
)--end script
Nov 21, 2005 3:20 pm
That’s bobo ! you made my day,
This .DIR properties, i didn’t know of !
That will be really usefull !
Thanks a million time