Notifications
Clear all

[Closed] can someone help me excute the code?

the code as follow , now I used a stupid method I think , can someone make it easier or simpler ?

d01=cylinder radius:0.04 height:2.16 pos:[0.126,17,49.3]
copy d01 pos:[0.126,-17,49.3]
d02=copy d01 pos:[-0.126,17,49.3]
copy d02 pos:[-0.126,-17,49.3]
d1=cylinder radius:0.04 height:2.20 pos:[15.874,17,49.3]
d2=cylinder radius:0.04 height:2.20 pos:[16.126,17,49.3]
d3=cylinder radius:0.04 height:2.30 pos:[31.874,17,49.3]
d4=cylinder radius:0.04 height:2.30 pos:[32.126,17,49.3]
d5=cylinder radius:0.04 height:2.70 pos:[47.874,17,49.3]
d6=cylinder radius:0.04 height:2.70 pos:[48.126,17,49.3]
d7=cylinder radius:0.04 height:3.10 pos:[63.874,17,49.3]
d8=cylinder radius:0.04 height:3.20 pos:[64.126,17,49.3]
d9=cylinder radius:0.04 height:3.70 pos:[79.874,17,49.3]
d10=cylinder radius:0.04 height:3.80 pos:[80.126,17,49.3]
d11=cylinder radius:0.04 height:4.50 pos:[95.874,17,49.3]
d12=cylinder radius:0.04 height:4.60 pos:[96.126,17,49.3]
d13=cylinder radius:0.04 height:5.30 pos:[111.874,17,49.3]
d14=cylinder radius:0.04 height:5.40 pos:[112.126,17,49.3]
d15=cylinder radius:0.04 height:6.40 pos:[127.874,17,49.3]
d16=cylinder radius:0.04 height:6.50 pos:[128.126,17,49.3]
d17=cylinder radius:0.04 height:7.70 pos:[143.874,17,49.3]
d18=cylinder radius:0.04 height:7.80 pos:[144.126,17,49.3]
d19=cylinder radius:0.04 height:9.00 pos:[159.874,17,49.3]
d20=cylinder radius:0.04 height:9.10 pos:[160.126,17,49.3]
d21=cylinder radius:0.04 height:10.50 pos:[175.874,17,49.3]
d22=cylinder radius:0.04 height:10.60 pos:[176.126,17,49.3]
d23=cylinder radius:0.04 height:12.10 pos:[191.874,17,49.3]
d24=cylinder radius:0.04 height:12.20 pos:[192.126,17,49.3]
d25=cylinder radius:0.04 height:13.80 pos:[207.874,17,49.3]
d26=cylinder radius:0.04 height:13.90 pos:[208.126,17,49.3]
d27=cylinder radius:0.04 height:15.70 pos:[223.874,17,49.3]
d28=cylinder radius:0.04 height:15.80 pos:[224.126,17,49.3]
d29=cylinder radius:0.04 height:17.70 pos:[239.874,17,49.3]
d30=cylinder radius:0.04 height:17.80 pos:[240.126,17,49.3]
d31=cylinder radius:0.04 height:19.90 pos:[255.874,17,49.3]
d32=cylinder radius:0.04 height:20.00 pos:[256.126,17,49.3]
d33=cylinder radius:0.04 height:22.30 pos:[271.874,17,49.3]
d34=cylinder radius:0.04 height:22.40 pos:[272.126,17,49.3]
d35=cylinder radius:0.04 height:24.60 pos:[287.874,17,49.3]
d36=cylinder radius:0.04 height:24.70 pos:[288.126,17,49.3]
d37=cylinder radius:0.04 height:27.30 pos:[303.874,17,49.3]
d38=cylinder radius:0.04 height:27.40 pos:[304.126,17,49.3]
d39=cylinder radius:0.04 height:30.10 pos:[319.874,17,49.3]
d40=cylinder radius:0.04 height:30.20 pos:[320.126,17,49.3]
d41=cylinder radius:0.04 height:33.00 pos:[335.874,17,49.3]
d42=cylinder radius:0.04 height:33.10 pos:[336.126,17,49.3]
d43=cylinder radius:0.04 height:36.10 pos:[351.874,17,49.3]
d44=cylinder radius:0.04 height:36.20 pos:[352.126,17,49.3]
d45=cylinder radius:0.04 height:39.20 pos:[367.874,17,49.3]
d46=cylinder radius:0.04 height:39.30 pos:[368.126,17,49.3]
d47=cylinder radius:0.04 height:42.50 pos:[383.874,17,49.3]
d48=cylinder radius:0.04 height:42.60 pos:[384.126,17,49.3]
d49=cylinder radius:0.04 height:46.00 pos:[399.874,17,49.3]
d50=cylinder radius:0.04 height:46.10 pos:[400.126,17,49.3]
d51=cylinder radius:0.04 height:49.70 pos:[415.874,17,49.3]
d52=cylinder radius:0.04 height:49.80 pos:[416.126,17,49.3]
d53=cylinder radius:0.04 height:53.50 pos:[431.874,17,49.3]
d54=cylinder radius:0.04 height:53.60 pos:[432.126,17,49.3]
d55=cylinder radius:0.04 height:57.40 pos:[447.874,17,49.3]
d56=cylinder radius:0.04 height:57.50 pos:[448.126,17,49.3]
d57=cylinder radius:0.04 height:61.50 pos:[463.874,17,49.3]
d58=cylinder radius:0.04 height:61.60 pos:[464.126,17,49.3]
d59=cylinder radius:0.04 height:65.80 pos:[479.874,17,49.3]
d60=cylinder radius:0.04 height:65.90 pos:[480.126,17,49.3]
d61=cylinder radius:0.04 height:70.20 pos:[495.874,17,49.3]
d62=cylinder radius:0.04 height:70.30 pos:[496.126,17,49.3]
d63=cylinder radius:0.04 height:74.80 pos:[511.874,17,49.3]
d64=cylinder radius:0.04 height:74.90 pos:[512.126,17,49.3]
d65=cylinder radius:0.04 height:79.40 pos:[527.874,17,49.3]
d66=cylinder radius:0.04 height:79.50 pos:[528.126,17,49.3]
d67=cylinder radius:0.04 height:84.40 pos:[543.874,17,49.3]
d68=cylinder radius:0.04 height:84.50 pos:[544.126,17,49.3]
d69=cylinder radius:0.04 height:89.40 pos:[559.874,17,49.3]
d70=cylinder radius:0.04 height:89.50 pos:[560.126,17,49.3]
d71=cylinder radius:0.04 height:94.60 pos:[575.874,17,49.3]
d72=cylinder radius:0.04 height:94.70 pos:[576.126,17,49.3]
d73=cylinder radius:0.04 height:100.0 pos:[591.874,17,49.3]
d74=cylinder radius:0.04 height:100.1 pos:[592.126,17,49.3]
d75=cylinder radius:0.04 height:105.5 pos:[607.874,17,49.3]
d76=cylinder radius:0.04 height:105.6 pos:[608.126,17,49.3]
d77=cylinder radius:0.04 height:111.2 pos:[623.874,17,49.3]
d78=cylinder radius:0.04 height:111.3 pos:[624.126,17,49.3]
d79=cylinder radius:0.04 height:117.1 pos:[639.874,17,49.3]
d80=cylinder radius:0.04 height:117.2 pos:[640.126,17,49.3]
d81=cylinder radius:0.04 height:123.1 pos:[655.874,17,49.3]
d82=cylinder radius:0.04 height:123.2 pos:[656.126,17,49.3]
d83=cylinder radius:0.04 height:129.3 pos:[671.874,17,49.3]
d84=cylinder radius:0.04 height:129.4 pos:[672.126,17,49.3]
d=#(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17,d18,d19,d20,d21,d22,d23,d24,d25,d26,d27,d28,d29,d30,d31,d32,d33,d34,d35,d36,d37,d38,d39,d40,d41,d42,d43,d44,d45,d46,d47,d48,d49,d50,d51,d52,d53,d54,d55,d56,d57,d58,d59,d60,d61,d62,d63,d64,d65,d66,d67,d68,d69,d70,d71,d72,d73,d74,d75,d76,d77,d78,d79,d80,d81,d81,d82,d83,d84)
for i=1 to 42 do
 (
   copy d[2*i] pos:[0.126+i*16,-17,49.3]
  copy d[2*i-1] pos:[-0.126+16*i,-17,49.3] 
  copy d[2*i-1] pos:[-0.126-16*i,17,49.3]
  copy d[2*i] pos:[0.126-i*16,17,49.3]
  copy d[2*i] pos:[0.126-i*16,-17,49.3]
  copy d[2*i-1] pos:[-0.126-16*i,-17,49.3]
 )
 
6 Replies

try something like this


   fn easeIn t b c d =
   (
    c * pow 2 (10 * (t/d - 1)) + b
   )
   
    cyl_count = 20
    t = 0
    base = 0
    c = 5
   	 
   while t < cyl_count do
   (
    v = 0
    v = easeIn t base c cyl_count
    sp = cylinder radius:0.04 height:v pos:[t, 0, 0]
    t += .25
   )
   
   

thanks for your reply ,incognitoDave
but what if I want to keep the cylinders position and height ?

Sure there is a better way but you could try something like this:


fn easeIn t b c d =
      (
   	c * pow 2 (10 * (t/d - 1)) + b
      )

(
d = 20
t = 0
base = 0
c = 5
      
      cyl_array =#()
      counter = 1
      
      while t < d do
      (
   	v = 0
   	v = easeIn t base c d
   	cyl_array[counter] = cylinder radius:0.04 height:v pos:[t, 0, 0]
   	t += .25
   	counter += 1
      )
   
      print cyl_array.count
      print cyl_array[34].height   
   )

thank you
but I think perhaps I didnt express myself exactly
when I say keep the cylinders’ position and height I mean to make the cylinders’ postion and height as I given in the code
but still thanks for your kindness

try this code, which will print a list of values to compare with your original listing. The positions match exactly, but the height followed a very strange pattern that I did not have time to decode. I was able to get it close – you will notice that the first and last values are the same, but in between the values have a small margin of error. If you want the height values to be 100% correct, I will need more information on where these values came from. But hopefully this will be close enough for you.

counter = 0 -- this is for formatting the output only
 -- Now declare some variables to be used with the cylinders
 theRadius = 0.04
 theHeight = 2.2
 theXPos = .126
 theYPos = 17
 theZPos = 49.3
 d = #()-- an empty array to add the cylinders to
 theHeightAdd = -.229268 -- this is the amount of increase in the large jump in height values
 
 --Now create each cylinder and add it to the array
 for f = 1 to 42 do -- each loop will make 2 cylinders
 (
 	TheHeightAdd += (.229268  - (if counter < 6 then 0 else 0.1))-- increase the amount of the large jump in values
 	theHeight += theHeightAdd -- this is the larger jump in values minus the smaller change in values
 	theXPos += 15.496 -- this is the larger jump in values minus the smaller change in values
 	for c = 1 to 2 do
 	(
 		counter += 1 -- for the output only, not necessary for cylinder creation
 		theHeight += (if counter < 7 then 0 else 0.1) -- add the smaller jump in values
 		theXPos += 0.252 -- add the smaller jump in values
 		dTemp = cylinder radius:theRadius height:theHeight pos:[theXPos, theYPos, theZPos] -- make the cylinder!!
 		format "d%=cylinder radius:% height:% pos:[%,%,%]
" counter theRadius theHeight theXPos theYPos theZPos -- this will display the list to check the values
 		append d dTemp -- add the cylinder to the array
 	)
 )
 
 -- this part I left unchanged from the original
 for i=1 to 42 do
  (
    copy d[2*i] pos:[0.126+i*16,-17,49.3]
   copy d[2*i-1] pos:[-0.126+16*i,-17,49.3] 
   copy d[2*i-1] pos:[-0.126-16*i,17,49.3]
   copy d[2*i] pos:[0.126-i*16,17,49.3]
   copy d[2*i] pos:[0.126-i*16,-17,49.3]
   copy d[2*i-1] pos:[-0.126-16*i,-17,49.3]
  )
 
  

msmith81 ,thank you to take time to try out the foumula