I am using extensively functions in 0.7. Take into account:
1.Imperative code seems to have issues . Loops are not working at all for example (at least the last time i checked). I would avoid it by the moment.
2.There have been some changues in the lenguaje. And some of then are related to quite usual tasks. If you have experience before and you take a look to the library in 0.7, you will figure out quite fast what is going on. But if not, if you are starting to learn now using the manual for autocad DS, it can be very confusing. I suppose that we will have a new updated manual soon.
About conditions, as I said in 1, better to avoid imperative code. No issues until now with conditions in associative code.
I would recommend you try first with a very simple function. Maybe you can post here a specific sample that is giving you trouble.
Conditional statements (If-Else, while) do not seem to work
However, what works is something in the format …
s = (a == b ? “Are equal” : “Are not equal”);
I’m a beginner, but, the Design Script manual still seems like a decent place to start. Some of the changes in the language, I figure out by referring to the names of the nodes while some others with a little imagination (BSplines now seem to be Nurbs) and then there are some I just can’t figure out. But since I’m presently just exploring the language, it’s alright.
(condition) ? (what happens if true) : (what happen in false) ; …is asociative code . Associative code is just the normal code you can use directly in CBN (imperative you have to start with var=[Imperative] and put the imperative block between {} ).
For example, You have a curve (Cu) and you want to create a Point in the middle only when its length is bigger than D. If not, a point in one third of the distance
I have been actively working on designing with Design Script over the last few weeks and at the moment it seems like it’s potential is only limited by my ignorance of various utilities and features that probably already exist.
However, it is inconsistent. Geometry doesn’t generate sometimes (The code block turns yellow with warning), but on restarting Dynamo, the same code works.
Sorry for reviving an old burried thread but I have been trying to do a If-ElseIf-Else Statement in a Design Script format without using a Imperative Code. Is that now feasible in the current version on Dynamo ? If yes can someone post an example, I haven’t been able to find the right syntax.
Apologies for my ignorance… Been using this for a few days.
The associative DS syntax for the IF function is: test ? true_value : false_value
If you want to simulate an IF - ElseIf -Else functionality, you’ll need to nest one if function inside the other. Another nice approach is to use the “Formula” node to do the same:
Thanks for your answer ! You’re crazy fast at answering these posts, pretty impressive…
I had seen the “Formula” node but I don’t find it super convenient as you cannot add several lines to it, like a Code Block. I had notice that it worked a bit like a Excel If Statement were you could nest Ifs inside an If statement. Didn’t realize you could do the same with Design Script.
Hey guys, did we ever reach resolution on Vikram’s inquiry?:
“Is there a way to reference within, variables and collections declared outside the Imperative block?” And please pardon my limited knowledge of design script at this point (I don’t believe I’ve written an “Imperitive” block yet, but maybe this is the same question:
Is it possible to reference variables and/or collections declared outside a typical code block defined function?: