Static methods in imperative block

Can anyone help me with, how to use nodes in imperative block?
I am trying to learn Designscript to simplify graphs, but I cannot get around this error.

My goal here is to determine the output depending ot the input type. So if the input is alignment do this, if 3DPoly do that so the output always be the same type (list of elevation). I chose DS, because I thought it would be more simple than Python as the nodes are given and how it handles lists.
I figured out that node to code creates some mess with methods pointing to wrong classes, but despite looking for a solution I could not figure out what to do with this error.

Thanks,
Valentin

Hi @kovacsv ,

I have used the ‘imperative’ statements within Code Blocks in the past but I’ve found that often a complicated setup like this isn’t necessary. You can create an easier statement with a setup like this:

//statement ? true result : false result;
reference == null ? 0 : reference;

Within this setup you can make it as extensive as you want/need, such as the calculations/ order of operations in your screenshot.

PS: Perhaps a solution with the native ScopeIf node might also be a nice solution, but I don’t know exactly how to use that in this case.

1 Like

Hi @Daan ,

Thanks, I was thinking using this if statement, but my main issue is what to do next?
I don’t only need to change the value, but do some operations depending on the input type, resulting in the same output type (elevation value).

A: Alignment: get profile, get station at point, get elevation at station
B: 3DPoly: get nearest points. get Z of points

I don’t know that the if statement can handle calling code block functions? So do A function if true do B if false.

Oh okay, while writing this I figured it out, it can indeed call a function. Thanks, I have to set lacing, but it works.
EDIT: Oh and I also should have read this line more carefully :sweat_smile:
Again, thanks.

Within this setup you can make it as extensive as you want/need, such as the calculations/ order of operations in your screenshot.

image

type = DSCore.Object.Type(referencia);

type == "Autodesk.Civil.DynamoNodes.Alignment" ? getprofilepoints(referencia,pointlist) : get3dpolypoints(referencia,pointlist);
1 Like