intersect edge with object

hello

I try to make a script :
I have an object with selected edges, and clic an object, I want to create lines extending selected edges to the clicked object. (to the intersections)
....don't work :-(
(
obj = $
rollout pick_box_test "Target surface"
(
pickbutton chooseit "Intersect me" width:140
on chooseit picked targ do
(
for i in ((polyop.getedgeSelection obj) as array) do
(
pta = (polyop.getVert obj (((polyop.getVertsUsingEdge obj i ) as array)[1])) as Point3
--Point pos:pta
ptb = (polyop.getVert obj (((polyop.getVertsUsingEdge obj i ) as array)[2])) as Point3
--Point pos:ptb
RRay = ray pta ptb
PPos = (intersectRay targ RRay).pos

Point pos:PPos
new_spline = splineShape ()
addNewSpline new_spline

addKnot new_spline 1 #corner #curve [pta.x,pta.y,pta.z]
addKnot new_spline 1 #corner #curve [PPos.x,PPos.y,PPos.z]
updateshape new_spline
new_spline.wirecolor = red
new_spline.vertexTicks = on
)
destroyDialog pick_box_test
)
)
createDialog pick_box_test
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Hey Titane, you may simplify

Hey Titane,
you may simplify this task with vol_select.
Just suggestion.

my recent MAXScripts RSS (archive here)

Garp's picture

A couple of things:

1. For each selected edge, you need two rays: one from A to B, the other from B to A.
2. You then build a new spline only if the value returned by intersetRay() is not undefined.

And also, since you're creating straight lines, setting the new knots to #line instead of #curve is 'lighter'.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.