PDA

View Full Version : contour generator


lo
05-24-2011, 05:47 PM
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

plastic
05-24-2011, 06:10 PM
very cool, thanks for sharing!

denisT
05-24-2011, 10:33 PM
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
)
*/

miauu
05-24-2011, 11:40 PM
An older version of Contour Creator (http://www.cnc-toolkit.com/maxscript.html) by Rab Gordon.

lo
05-25-2011, 07:20 AM
very nice, denis. seems faster.
There is also no need to create the spline every step of the way, you can substitute with:
if k == slices and (temp.createShape ("sp_" + k as string) curved node) do

denisT
05-25-2011, 09:14 AM
very nice, denis. seems faster.
There is also no need to create the spline every step of the way, you can substitute with:
if k == slices and (temp.createShape ("sp_" + k as string) curved node) do
every new slice resets edge selection...

lo
05-25-2011, 09:34 AM
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...

denisT
05-25-2011, 09:47 AM
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.

lo
05-25-2011, 11:36 AM
maybe the method doesn't update selection on every slice.
I assume it does and is additive, because the final spline is correct. Can you show a case in which it doesn't?

denisT
05-25-2011, 01:40 PM
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.

lo
05-25-2011, 01:56 PM
why not just deselect all edges before starting the loop?

denisT
05-25-2011, 02:11 PM
why not just deselect all edges before starting the loop?

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.

lo
05-25-2011, 02:39 PM
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?

denisT
05-25-2011, 02:48 PM
I agree. Do you mind if I use your code sample as a basis for a different version of the tool?
sure. no problem.

CGTalk Moderation
05-25-2011, 02:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.