Notifications
Clear all

[Closed] contour generator

 lo1

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

13 Replies
1 Reply
(@denist)
Joined: 2 years ago

Posts: 0

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 cool, thanks for sharing!

An older version of Contour Creator by Rab Gordon.

 lo1

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

every new slice resets edge selection…

 lo1

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…

1 Reply
(@denist)
Joined: 2 years ago

Posts: 0

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.

 lo1

I assume it does and is additive, because the final spline is correct. Can you show a case in which it doesn’t?

1 Reply
(@denist)
Joined: 2 years ago

Posts: 0

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.

 lo1

why not just deselect all edges before starting the loop?

3 Replies
(@denist)
Joined: 2 years ago

Posts: 0

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.

 lo1
(@lo1)
Joined: 2 years ago

Posts: 0

I agree. Do you mind if I use your code sample as a basis for a different version of the tool?

(@denist)
Joined: 2 years ago

Posts: 0

sure. no problem.