Changing multiple parameters using "AppliedSubassembly.SetParameterByName"

Hi everyone, I am new to Dynamo for Civil 3D, and trying to connect this powerful tool with excel. Specifically, I want to read multiple corridor subassembly parameters from excel, and updating these parameters (and subsequently corridors) at one time.

(1) Do we have a functionality dedicated to this? It seems that we have the functionality to update “only one” parameter of a subassembly (AppliedSubassembly.SetParameterByName), but we do not have the one to update “multiple” parameters at one time.

(2) I have made a custom node which extends “AppliedSubassembly.SetParameterByName” and updates multiple subassembly parameters at one time, which is shown below.

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')

# Add Assemblies for Civil3D
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# Add Assemblies for Dynamo (Additional)
clr.AddReference('Civil3DNodes')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# Import references from Dynamo (Additional)
from Autodesk.Civil.DynamoNodes import AppliedSubassembly

def SetParameters(appliedSubassembly, data):

	# Magical spells ...
	adoc = Application.DocumentManager.MdiActiveDocument
	editor = adoc.Editor

	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:

				# Update for each subassembly type, section, and parameter 
				for i in range(len(appliedSubassembly)):
					for j in range(len(appliedSubassembly[i])):
						for k in range(len(data[i])):
							AppliedSubassembly.SetParameterByName(appliedSubassembly[i][j], data[i][k][0], data[i][k][2], 0)

				# Commit before end transaction
				t.Commit()
				# pass

OUT = SetParameters(IN[0], IN[1])

The .dyn file and .dwg file is attached below.
Subassembly_Params_Import.dyn (40.8 KB)
Subassembly_Params.dwg (1.4 MB)

All I am doing is run “AppliedSubassembly.SetParameterByName” iteratively. But the program gives me an error on reaching to non-editable parameters, so I need to manually get rid of these from excel in advance.

Do you know any workaround on it? (For example, finding out non-editable parameters before running “AppliedSubassembly.SetParameterByName”, or picking up only editable parameters extending “SubassemblyParameter.Name”, etc.)

I would appreciate any kind of replies!

3 Likes

You can use List.Map node for this, if you use AppliedSubassembly.SetParameterByName node as a function.


Best regards
Lukas

1 Like