Extract (auto)Corridor Featurelines

Hi all,

I can extract Corridor Featurelines. But I need to find out which region a fealtureline belongs. But can’t find the solution. I think is is not possible if i look at the object hierarchy.

[Code}
def corridor_FeatureLines(flStartId,corNames,PointCodeLST,isDynamic,FLname,FLStyleNameLST,layerId,existingFLnames):
output =
errorReport = None
i = 0
iFlcounter = flStartId

if corNames is None or PointCodeLST is None:
	return
# Check if not list then create list
if not isinstance(corNames, list):
	corNames = [corNames]

global adoc
global civdoc
global editor
global newFLnames

smoothOption = GradingSmoothOption(1,0.1,True,0.1)

with adoc.LockDocument():
	with adoc.Database as db:
		with db.TransactionManager.StartTransaction() as t:
			SiteObjId = civdoc.GetSiteIds()[0]
			#res.append(SiteObjId)

			#res.append(layerId)
			
			for corName in corNames:
				for j in range(len(PointCodeLST)):
					PointCode = PointCodeLST[j]
					FLStyleName = FLStyleNameLST[j]
					styleId = civdoc.Styles.FeatureLineStyles[FLStyleName]
					#res.append(styleId)
			
					# Get corridor from corridor collection               
					corId = civdoc.CorridorCollection[corName]
					cor = t.GetObject(corId, OpenMode.ForRead)
					try:
						for Baseline in cor.Baselines:
							MainBlFl = Baseline.MainBaselineFeatureLines
							FlColMap = MainBlFl.FeatureLineCollectionMap
							for FlCol in FlColMap:
								for CorFl in FlCol:
									if CorFl.CodeName == PointCode:
										#res.append("CorFl:" + CorFl.CodeName)
										temp = get_shortnameId2(PointCode,longNames)
										FeatureLineName = FLname + "-" + corName + "_" + temp + "-(" + str(iFlcounter) + ")"
										if exist_In_list(existingFLnames,FeatureLineName) == False:
											isDynamic = False
											CorFl.ExportAsGradingFeatureLine(SiteObjId, isDynamic, FeatureLineName, layerId, styleId, smoothOption)
											#CorFl.StyleName = FeatureLineName
											extracted = True
											iFlcounter +=1
											newFLnames.append(FeatureLineName)
					except:
						import traceback
						errorReport = traceback.format_exc()
			t.Commit()            	
if errorReport == None:
	return output
else:
	return errorReport
1 Like

I don’t know why do you need this and correct me if I am wrong, but C3D connects feature lines with the same code in diff regions if they belong to the same baseline. Therefore, an autocorridorfeatureline most likely has multiple baselineregions.

Hi @JPS,

First of all, that documentation is for the COM API, which is probably not what you want. The correct place to look is the AutoCorridorFeatureLine .NET class. There is a property to get the region name. Like @kovacsv mentioned, you’ll have to pay attention to how the Feature Lines are joined across regions. If all of the regions are joined together, the output will be “All”. If they are joined between two or more regions (but not all), then the output will be the name of the first region.

Here’s an example:

import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

autoFeatureLine = IN[0]
adoc = Application.DocumentManager.MdiActiveDocument

with adoc.LockDocument():
    with adoc.Database as db:
        with db.TransactionManager.StartTransaction() as t:
            oid = autoFeatureLine.InternalObjectId
            obj = t.GetObject(oid, OpenMode.ForRead)
            region = obj.CorridorFeaturelineRegionName
            t.Commit()
            pass
OUT = region
4 Likes