Slope pattern between two feature lines in each corridor

The following Python script is to add a slope pattern between two feature lines in each corridor, using the corridor feature lines I obtained from a Dynamo block. However, the Python script is expecting the corridor feature lines to be selected from the Block Table Record.

How do I use feature lines from the Block Table Record?

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

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# 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 *

adoc = Application.DocumentManager.MdiActiveDocument
civdoc = CivilApplication.ActiveDocument
editor = adoc.Editor

def create_corridor_Slope_Patterns(corNames,FeatLines,TaludeID):

	output = []
	errorReport = None
	i = 0
	check_out = []
	Procura_feat = ""
	
	
	if corNames is None or FeatLines is None:
		return
	
	if not isinstance(corNames, list):
		corNames = [corNames]
	
	if not isinstance(FeatLines, list):
		FeatLines = [FeatLines]
	
	global adoc
	global civdoc
	global editor
	
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
				btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)

				for corName in corNames:
					# Get corridor from corridor collection               
					corId = civdoc.CorridorCollection[corName]
					cor = t.GetObject(corId, OpenMode.ForWrite)
					Features_Fil = FeatLines[i]
					Features_Cor = Features_Fil[0]
					check_out.append(corName)
					for Feat_Line in Features_Cor:
						# Check if feature line is the last one
						#check_out = dir(Feat_Line)
						#check_out.append(Feat_Line)
						Teste_nome = Feat_Line.Code[-4:]
						if Teste_nome[:2] == "33":
							Procura_feat = ""
							if Feat_Line.Code[:5] == "Aterr":
								Feat_Sl_2 = Feat_Line
								Feat_Number = str(int(Feat_Sl_2.Code[-1]) - 1)
								Procura_feat = "AterroBanEsq-" + Feat_Number
								for Feat_Line_2 in Features_Cor:
									if Feat_Line_2.Code == Procura_feat:
										Feat_Sl_1 = Feat_Line_2
							if Feat_Line.Code[:5] == "Corte":
								Feat_Sl_1 = Feat_Line
								Feat_Number = str(int(Feat_Sl_1.Code[-1]) - 1)
								Procura_feat = "CorteBanEsq-" + Feat_Number
								for Feat_Line_2 in Features_Cor:
									if Feat_Line_2.Code == Procura_feat:
										Feat_Sl_2 = Feat_Line_2	
							#Create the slope Pattern
							#check_out = dir(cor)
							#check_out = dir(cor.SlopePatterns)
							#check_out.append(Feat_Sl_1)
							#check_out.append(Feat_Sl_2)
							#check_out.append(TaludeID)
							cor.SlopePatterns.__add__(Feat_Sl_1, Feat_Sl_2, TaludeID)
					#Next Corridor		
					i =+ 1
				t.Commit()            	
	if errorReport == None:
		return check_out
	else:
		return errorReport
OUT = create_corridor_Slope_Patterns(IN[0],IN[1],IN[2])

Check Parameters type
As picture

SlopePattern.dyn (284.5 KB)

thanks hosneyalaa but still not working can you please check it

As @hosneyalaa mentioned make sure you use the correct object type. You have to use Autodesk.Civil.DatabaseServices.CorridorFeatureLine. Your input on the picture is in the dynamonodes workspace. Open feature lines with GetObject() as you did with corridor.

Can you attached example drawing for testing your code

@ntma85

6

1 Like