How to Change the Layer of a Line Using a Python Node

After looking through both the 2022 Developer database and the Civil 3D 2023 database, I couldn’t seem to find a way to adjust the layer of a polyline using a Python node. I’m just looking to let the user select a line, select the layer they want the line to move to, and then confirm their decision by running the program out of the player. Any help on where to find the specific database call in order to adjust the layer using a transaction within a Python node?

Using Python seems a little over-complicated. Have you tried just using the Object.SetLayer node?

3 Likes

@mzjensen Perfect, that is much better than what I had planned out.

Is there a ‘Select Layer’ node I can use to allow the user to specify a new layer for the line? It looks like I could then output that layer into the ‘layer’ input of the Object.SetLayer node.

The Object.SetLayer node will create the layer if it doesn’t exist.

2 Likes

Here is a simple example that utilizes Arkance’s layer drop down node but also allows for the definition of a new layer by string input.
SetLayerForObjects.dyn (12.6 KB)


3 Likes

@WrightEngineering
Two questions for you, mainly aimed at being user-friendly.

First, how were you able to select multiple lines at a time for the select option when using the player? It won’t let me click and drag after I press select, so I’ve only been able to select one at a time.

Second, my layer drop down menu is at the bottom instead of the middle of my dynamo player, and the ‘new layer name’ is in the middle. Is there a way I can flip those two so I can imitate yours?

1.) What is your “PICKDRAG” variable set to? Are you using the “select objects” node in the C3D Toolkit or the “select object” node? The “select object” node will only allow one selection.

2.) I’m unsure. I’ve never tried to deliberately define the order of the inputs. Maybe open in dynamo and uncheck one as input, save and then recheck it as input and save again and then try opening the player? Maybe the order in which nodes are checked as “in-put” will effect the order? Not sure, never thought about that before.

The order in Player is determined by the order that the nodes were added to the graph. So you can cut/paste the nodes in the order you want to rearrange them.

3 Likes

Good call on the node check, I was using the default node.

It seems to determine the order based on when the blocks were created. When I deleted my ‘select object’ node and replaced it with the C3D Toolkit Node, it moved that ‘select’ option to the bottom of the player. After deleting the other two layer-name blocks and reinserting them in the correct order, I was able to get the dropdown selector above the ‘new layer name’ textbox, with the select option on top.

Thanks for the help!

1 Like

Note that the default sort order for Dynamo Player inputs will be alphabetical in the near future (introduced in Dynamo for Revit 2023, and likely Civil 3d soon if not already).

2 Likes