Jump to content


  • Content count

  • Donations

    0.00 CAD 
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ingersoll

  • Rank

Personal Information

  • Name
    Evan Ingersoll
  • Location
    Colorado, USA
  1. array amnesia -- losing values or my mind

    Thanks for the sample file! It looks like it's not the code, it's my data -- if I load my point data into your file and pipe it through your code, it fails the same way my code fails. I think that qualifies as "garbage in..." -- I'll see if I can clean the data or change my initial processing steps. Thanks again!
  2. array amnesia -- losing values or my mind

    Thanks Atom! The syntax of the docs was confusing to me there. If I modify my foreach section to create a success variable and test for it, it runs without errors ... and still gives the same result, as does append. It still seems likely I'm flubbing the code somehow, as there's limited example code to crib from. What I've got now is: foreach (int myndx; myprims) { int success; float mytmp = primattrib(0, "restlength", myprims[myndx], success); if(success == 1) { push(mylens, mytmp); } }
  3. Hi all, I have an arrays-in-loops puzzle. I thought of a shortcut to do a thing, it doesn't seem to work, and I should move on -- except I would like to understand why it doesn't work. Minimal background: I've got some point data, I've polywired it together using Connect Adjacent Pieces, and gotten a restlength on the primitives from that. I need to set a pscale on the points before moving on to my next step. Half the distance to the nearest neighbor is good enough for now. I could use nearpoints() to figure that out (and it seems to work!), but I thought, "hey, I already have restlengths; why not just look up the shortest restlength and use that?" That turns out not to work, or at least not as I think it should. Where have I gone wrong? After my connect step, each point ends up connected to 4-20 other points by primitives with restlengths between .9 and 3.9. My first stab at this was: use pointprims() to get an array of primitives associate with each point; create an empty float array to hold the restlengths; foreach loop over the primitives, read the restlength with primattrib(), and push the result onto the lengths array; sort() the lengths array into a new array; read out the shortest length and use that to calculate a pscale. Here's the actual code: int myprims[] = pointprims(0, @ptnum); float mylens[] = {}; foreach (int myndx; myprims) { float mytmp = primattrib(0, "restlength", myprims[myndx], 0); // f@checktmp = mytemp; push(mylens, mytmp); // f@checkrslt = mylens[myndx]; } float lensort[] = sort(mylens); float shortest = lensort[0]; f@pscale = shortest/2; I think it's failing at the push statement. If I write out mytmp as a point attribute just before I push it, I get a reasonable number (commented code). If I check the stored value right after the push, I get either zero or the restlength of prim zero. If I check after the foreach loop completes, I get restlength of prim zero. So the push doesn't work. Looks like example code in the docs, but I'm missing something. Any thoughts?