How to Use Levels in DesignScript?

Hello there,

I tried finding the solution but couldn’t find any plausible solution.
I want to use level as we use in ootb node in DS code, but couldn’t in the following case-

image

image

Please assist.

Regards,
Atharva Purohit

Check this

Thank you for replying.

I did check that previously but here my curve variable is non-static, so i’m not able to code it for the given instance in the 1st snip. If you can type that, it’ll help. (syntax)

br,

do it by normal node then right click on blank area . select " node to code ". it will show you the method

2 Likes

Hi
that’s a smart approach but the issue is again about the static/ dynamic
node to code for other (static) giving the solution but for this (custom node) as it is dynamic it is not.

“Autodesk.ds.geo.curve”, is not a static property and the node to code for other is giving syntax for static.
br,

Hi @atharva.purohit466SX …dont think i know this ootb node geometry.curves i only know element.curves

It is a custom one, I want to apply level syntax here, can you please help?

br,

Which package is it ?

ampersand,
My intent was to decrease the dependency of custom page so that user wont need to install it.
(all credits given to dev)
So when I took this out from the custom node (which gives the option to set level) to dynamo workspace, I’m able to use level syntax in DS. I do not even know how to do it.

If you can just help me in using level syntax in the above DS code in first snip, that will row my stagnant boat.

now i can understand…
You are trying to modify input node.

Autodesk.DesignScript.Geometry.Curve[];
This is just to explain to a user that your input must be curve.
So you can simply delete that.

Use this code it will be same.

cur@L2<2>
2 Likes

yes now i understand too…i would do as @dylim say

@sovitek @dylim

I’m sorry for dragging this.
maybe i’m not able to understand your solution.

You can see in above custom node the L2 level is used.
The below group of nodes i’ve take out from that custom node only but am not able to assign L2 level.
and it looks like
image

is one important thing here.

Can you please write the code you suggested above fully and paste it here.
sounding naïve. I apologies.

Regards,
ap

hmm i think solution is variety depends on your data input and desired result.


or like this? probably the worst idea but you can try this way.

1 Like

Hi again Atharva…could something here help

1 Like

Not helping yet.

This is how it looks like inside the custom node.

But thank you both for your efforts, youre great!

The Autodesk.DesignSctipt.Geometry.Curve[] bit is the input value for the custom node. There is no need for this in the Dynamo environment.

Instead you will need to rewrite the Python code to ensure it utilizes the correct list level in all cases (not an easy task), and then use @L2 list level on each subsequent node in the string.

Doing all of this is possible, but I do not recommend it. It will all make things slower by requiring more data be stored in the memory, and make it so when there is a change in the environment (ie: Dynamo 2.13 and you need to migrate all the Python over to Python 3) you will have to maintain a new version of the dyn file instead of just having users leverage another version of the ampersand package - you become the owner of the technical debt of updating the code instead of the technical debt of saying ‘install ampersand’. Lastly (and not least of all), it strips the credit of the code contained in the Ampersand package away, a violation of the license and therefore a copyright violation if I am not mistaken. I doubt the author will care (he’s a great guy), but others have in the past.

If you really want to try this (again, I don’t recommend it), than Flattening the incoming lists @L2 might make it so the Python node always works, but could ruin other stuff downstream in your graph as it removes the high rank list levels entirely.

3 Likes

Yes @JacobSmall …you are right …think a list flattern will help…

2 Likes

Hi Jacob
thank you for responding
About the copyright violation, I already wrote all credits given in the code itself and in the above question. But still if it is not allowed, I will surely refrain from doing it as I understand how much efforts it take.

Regards,

1 Like

I’ll try and mark it as solution.

Thank you Soren!

1 Like