I want to create 2 points (1,0,0) and (2,0,0) by using for loop in Code Block / Designscript, but it doesn’t do anything, and there is no error message.
I know how to do it in regular way, but I want to do it by "Loop"
Loop.dyn (2.8 KB)I want to create 2 points (1,0,0) and (2,0,0) by using for loop in Code Block / Designscript, but it doesn’t do anything, and there is no error message.
I know how to do it in regular way, but I want to do it by "Loop"
Loop.dyn (2.8 KB)Need to define the results - Return =
Looks as if you still need to append the results onto the list before you return it. Check out this documentation from @solamour’s BiLT class last year.
Also, you don’t need to go imperative in this case - just process the list as you normally would.
Thanks for the link, just got down to here…
Edit: Just for the record I did finish it, thanks @solamour great resource!
@ JacobSmall
If I don’t use Imperative, DY shows error, say it’s can only be used in imperative mode.
@ Mark.Ackerley
I tried to mimic the code in the document, but it doesn’t create any point.
do this:
point1[i] = Point.ByCoordinates(i,0,0)
Michael_Kirschner2
Thank you for the tips.
" 3. when possible - avoid imperative. It’s simply not as robust as the rest of the language, as very few nodes compile to it."
——Designscript manual says:
“do this: point1[i] = Point.ByCoordinates(i,0,0)”
No error, no point created.
The code that @Michael_Kirschner2 posted doesn’t need to be in an imperative code block.
i=1..2;
point1=Autodesk.Point.ByCoordinates(i,0,0);
Notice that using the code there for every value in i you are getting a point. No imperative code required. Design script manages replication internally in most ‘for loop’ cases using list lacing and levels.
Here are a few more samples to get you started:
@Xiaofei_Ying In your case i starts with 1
Ensuring the first index is 0 should sort things out
I found the culprit: “Autodesk.Point.ByCoordinates(i, 0, 0)”, sholuld be “Point.ByCoordinates(i, 0, 0)”
this is the bug I suspected - it’s fixed in 2.1 -
you can do
func = Autodesk.Point.ByCoordinates() outside the imperative block
and then func(1,1,1)
I learn from other post that package Rhynamo cause this issue.