[Closed] contour generator
Hi
This is a small toy that expands one of the examples from the maxscript help file, used to generate contour splines of objects using the section shape. I needed to use this functionality for a small task, and took the time to build a UI for it.
Enjoy
i would do it by slicing poly copy of the node with slice planes and creating shapes from edge selection.
like:
fn sliceAndShape node:selection[1] slices:1 curved:off dir:#z = if canconvertto node Editable_Poly do
(
temp = converttopoly (copy node)
bbox = nodeGetBoundingBox temp temp.transform
step = (bbox[2] - bbox[1])/(slices+1)
vec = case dir of
(
#x: [1,0,0]
#y: [0,1,0]
default: [0,0,1]
)
sp = #()
for k=1 to slices do
(
temp.slice vec (bbox[1] + vec*step*k)
if (temp.createShape ("sp_" + k as string) curved node) do
(
append sp shapes[shapes.count]
shapes[shapes.count].parent = node
)
)
delete temp
sp
)
/*
(
gc()
delete objects
teapot isselected:on
sliceAndShape slices:20 dir:#x
)
*/
very nice, denis. seems faster.
There is also no need to create the spline every step of the way, you can substitute with:
if [B]k == slices[/B] and (temp.createShape ("sp_" + k as string) curved node) do
I am not sure what you mean exactly, but your code generates a redundant spline for every iteration, and the line I changed only creates the spline on the last iteration… in your example teapot it seems to work fine…
with your correction the code has to make the shape for the last slice only.
maybe the method doesn’t update selection on every slice. if so it’s better to do it forcing update node.
I assume it does and is additive, because the final spline is correct. Can you show a case in which it doesn’t?
if it’s additive it’s a bug. i need to deselect all edges before every iteration. or update mesh after an iteration. updating is definitely slower.
i think the better solution is to have an option – combine. if combine is true we will go your way: deselect edges, make all slices without mesh update, and make a shape; if combine is false (to have a shape per slice) we will go my way: deselect edges before every slice, make slice, and make shape on every iteration.
I agree. Do you mind if I use your code sample as a basis for a different version of the tool?