Code block: views


I want the views node written in code, but I don’t exactly know what to fill in.
What am I doing wrong?

Select the working Nodes, right click, choose Node to Code
Study the result

I don’t see the option “node to code”

Hi,

This is one way to get the view by name, the long and non-efficient way ofc.
I don’t know how would you get the view without a collector in design script.

doc = Document.Current;
view_Category = Revit.Category.ByName("Views");
col = Collector.ElementsOfCategoryInDocument(doc, view_Category);
filtered = ElementFilter.ByName(col,"Level 1","Equal",true);
cleaned = DSCore.List.Clean(filtered,false);
DSCore.List.Flatten(cleaned);

image

Hope it helps a bit.

2 Likes

Hi,

I don’t think you can integrate it into the code block (if you look at the help on the Node as it has qualitative UI: this should not be possible)
you can choose it as input for the player or other

cordially
christian.stan

1 Like

ok thanks for the help

RE: Node to Code failure.

This is one super unintuitive thing about Dynamo: To get the “Node to Code” Option in the right-click menu, you need to right-click in the canvas, outside of any selected nodes- not on the node itself.

You can select more than one Node to translate as well, and if they reconnected, the resulting design script will provide correctly filled in variables for input/output.

image

To me this makes sense, but I may just be insane. You aren’t node to coding ONE node, but the selected collection thereof. Right clicking on the node I would expect N code blocks for N nodes.

Once you figure it out, it makes sense. “Create Group” behaves similarly. However, if you Right click on a node (with our without multiple nodes selected) you still have the “Group->Create Group” menu option so it never totally disappears.
I guess I’m always thinking that when I right click, I am trying to do an action on something, so clicking the canvas makes less sense- in CAD or Revit that can clear the selection, so maybe that is the muscle memory that my brain is trying to rationalize.

In any case, it certainly couldn’t hurt to have “Node to code” in the right click menu of the node itself and have it act on whichever objects are selected, similar to the group menu. It’s a needless stumbling block that I have run into multiple times, and it appear that the OP did as well from the picture he posted.

(Tangent finished?) :wink:

1 Like

I agree. Can you submit this as is to the Dynamo Wishlist so we can get it onto the product teams radar? Issues · DynamoDS/DynamoWishlist · GitHub

1 Like