Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.
8 hours ago
Hi,
I am working on an object where I have values in an array parameter, and they are represented in 2D as points on a line. You can move them by hotspots, and if you move one over the other, the parameter script finds the duplicate values, and deletes one of them from the array.
This works mostly fine, except if i try to remove the last node (last item of the array) it doesn't get removed, it just sets itself to "0", and I have no idea why. It seems like a fairly simple setup, but I still cannot see what I am doing wrong.
Can someone tell me what am I missing?
! ----------
! 2D script:
! ----------
unID = 1
hotspot2 0, 0, unID : unID = unID + 1
for i = 1 to vardim1(dimArray) step 1
hotspot2 0, 0, unID, dimArray[i], 1 + 128 : unID = unID + 1
hotspot2 dimArray[i], 0, unID, dimArray[i], 2 : unID = unID + 1
hotspot2 -1, 0, unID, dimArray[i], 3 : unID = unID + 1
next i
line2 dimArray[1], -0.5, dimArray[1], 0.5
for i = 2 to vardim1(dimArray) step 1
line2 dimArray[i-1], 0, dimArray[i], 0
line2 dimArray[i], -0.5, dimArray[i], 0.5
next i
! -----------------
! Parameter script:
! -----------------
put dimArray[1]
for i=1 to (vardim1(dimArray) - 1) step 1
if dimArray[i] # dimArray[i+1] then
put dimArray[i+1]
endif
next i
dim _temp[]
for i = 1 to nsp step 1
_temp[i] = get(1)
next i
parameters dimArray = _temp
Thanks!
8 hours ago - last edited 8 hours ago
Hi
edit: closer but still not right
in your parameter script i added following line (13)
put dimArray[vardim1(dimArray)]
The corrected version below
@danielk schrieb:
! ---------- ! 2D script: ! ---------- unID = 1 hotspot2 0, 0, unID : unID = unID + 1 for i = 1 to vardim1(dimArray) step 1 hotspot2 0, 0, unID, dimArray[i], 1 + 128 : unID = unID + 1 hotspot2 dimArray[i], 0, unID, dimArray[i], 2 : unID = unID + 1 hotspot2 -1, 0, unID, dimArray[i], 3 : unID = unID + 1 next i line2 dimArray[1], -0.5, dimArray[1], 0.5 for i = 2 to vardim1(dimArray) step 1 line2 dimArray[i-1], 0, dimArray[i], 0 line2 dimArray[i], -0.5, dimArray[i], 0.5 next i ! ----------------- ! Parameter script: ! ----------------- put dimArray[1] for i=1 to (vardim1(dimArray) - 1) step 1 if dimArray[i] # dimArray[i+1] then put dimArray[i+1] endif next i put dimArray[vardim1(dimArray)] dim _temp[] for i = 1 to nsp step 1 _temp[i] = get(1) next i parameters dimArray = _temp
Thanks!
7 hours ago
Hi,
My code is supposed to go through the array, and put each value into the buffer, except if 2 items are identical, and then in the next step, feed them into a temporary array, then assign the temporary array to the parameter.
So, if I had an array of 1,2,3,4,4, it would first put 1,2,3,4 into the buffer, then create a new array with these values, and assign that array back to the parameter, so it would also be 1,2,3,4.
I think what your addition would do is just grab the 4 from the end, and put it back into the temporary array, so at the end I would end up with 1,2,3,4,4? Or am I misunderstanding something?
Thanks!
7 hours ago
Another thing is, it works perfectly fine if I just change the value in the Object settings dialog. It only does this, if I use the hotspots to change the value.