Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Linked Lists

Linked Lists

Anonymous
Not applicable
382 Views
4 Replies
Message 1 of 5

Linked Lists

Anonymous
Not applicable
Does anyone know of a way to implement Linked Lists in maxscript? I don't ever remember seeing a way to link to an item in an array and have it update if the array is changed (eg. sorting, inserting or removing items, etc) I have found an algorithm I'd like to try to recreate in max, but it uses these Linked Lists to manage data and their associations and I'm not sure how to do it. Specifically, the algorithm calls for a double linked circular list. Anyone ever try something like this?

http://en.wikipedia.org/wiki/Linked_list

-Ray
0 Likes
383 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Never try this, so take this code just as idea

woops, 1st code i posted was too far away from 'linked', maybe this is more closer
fn newLinearLinkedList inArray = (
top = DataPair inArray null
prev = top
for i = 2 to inArray.count do (
next = DataPair inArray null
prev.v2 = next
prev = next
)
top
)

testArray = #("A","B","C")
newLList = newLinearLinkedList testArray

-- result:
(DataPair "A" (DataPair "B" (DataPair "C" undefined)))
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks for the suggestions. My script is still in progress, but I solved the linked list issue using a custom struct that manages the array. I do like using the dataPair() element, I had never really used it until now. Basically, I assign a unique ID code to each item in the array, and then assign a dataPair to each item with the preceding and following items ID code. Then I wrote functions within that struct that allow me to easily insert or delete items from the list, query items X distance up or down the list, automatically update the ID references anytime there is a change. It's actually quite fun.

I also ended up needing a Priority List array, one that auto sorted its self every time an element was added or deleted. I used many of the same techniques from the linked list system above to automate the sorting of the list.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Out of curiosity, for what purpose do you need a linked list in maxscript?
0 Likes
Message 5 of 5

Anonymous
Not applicable
Writing a Straight Skeleton routine, following this paper's workflow.

http://www.dma.fi.upm.es/mabellanas/tfcs/skeleton/html/documentacion/Straight%20Skeletons%20Implemen...

Got it working flawless for convex shapes, now working on the concave.

Who knew coding could be this fun!
0 Likes