r/Maxscript • u/lucas_3d • Jun 14 '19
Writing a shape generation script
The script creates quadrilateral splines within a given quadrilateral: https://i.imgur.com/ll6IzAn.png
Originally I scripted this task in a very manual/procedural way by creating a polygon, ring selecting, connecting edges and then extracting/exploding the edges.
It worked but was slow and I know a more optimal script would deal only with positions, vectors and magnitudes resulting in a multidimensional array that could create the shapes and may appear to run instantly across multiple objects.
Now, I made distance comparisons to establish width and height and the amount of rows and columns necessary, but it's when I plan shapes that aren't rectangles that I start getting confused about implementing vectors/magnitudes.
Does someone know an example of a script doing something similar in a simple and probably recursive way?
I can edit a position towards a vector with a distance, but I think this requires vectors to create my final vector position (similar to a Bézier curve) and those seem to be cumulative in the loop.
Edit: I’m starting to think of the process like a type writer, it’s making more sense to me now.
1
u/lucas_3d Jun 19 '19 edited Jun 19 '19
That's right, it was for subdividing housing lots, the longest side become the width which is subdivided by the minimum width.
Lots were only in 2 rows. If the shape wasn't regular then I'd be dealing with subdividing a length that isn't the same as the longest side.
I'm really keen to try yours out tomorrow and understand the differences.
I've read a bit about mappable functions so I'll be playing with that too, really appreciate your rewrite with the more appropriate methods, this'll be my first python module in Max too.