[Closed] Hashtable in maxscript
Hi!
I’m not able to find anything about Hash tables in max script, do you know anything about?
Thanks!
Alex
[left]meshop.divideFace <Mesh mesh> <int faceIndex> baryCoord:<point3=unsupplied>[/left]
[left] [/left]
[left]polyOp.divideFace <Poly poly> <int face> <point3 pos> node:<node=unsupplied>[/left]
[left][font=Courier New] [/left]
[left]meshop.divideFaces <Mesh mesh> <facelist>[/left]
meshop.divideFaceByEdges <Mesh mesh> <int faceIndex> <int edge1Index> <float edge1f> <int edge2Index> <float edge2f> fixNeighbors:<boolean=true> split:<boolean=false>
[/font][left][left][/left]
[/left]
I guess you are refering to this kind of hastables?
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Hashtable.html
No, I haven’t seen them in maxscript.
There are ‘only’ arrays.
I you can fake them with two-dimensional arrays like:
hashfake = #(#(“two”, 2), #(“three”), 3)
But you will need to write your own function to get the same behaviour.
I think this will be slower than having just arrays.
Georg
I think I have done this in the past using 2 arrays. One array contains instances of the data structure the other array contains the ‘keys’:
struct objInfo ( name, numVerts, numfaces )
objArray= #()
objIndex = #()
for i = 1 to selection.count do
(
curObj = selection[i]
append objArray (objInfo name:curObj.name numVerts:curObj.numVerts numFaces:curObj.numFaces)
append objIndex curObj.name
)
theObj = objArray[(findItem objIndex "Object27")]
if theObj != undefined do
(
format "Obj name: %
numVerts: %
numFaces: %
" theObj.name theObj.numVerts theObj.numFaces
)
I’ve done it in the same way, thanks
It is a nice idea, but I have noticed a dramatic performance drop when the hashtable gets large
What sort of size are you talking? I’ve used this method to store up to 2000 or so elements with no noticable drop in performance…
Under the hood in the SDK, maxscript uses hash tables. However don’t ask me why it wasn’t exposed to the scripter. See hashtab.h in the maxscript sdk.
However I’ll be the first to admit the header file has ZERO documentation. A big negative in my opinion. That will have to be addressed.
Chris J.