CreateCorridorSurface

Hi,

Is it possible to add multiple corridor link/featureline codes to single surface? Atm i have py coded node that is creating surfaces but can add only one code to a single surface on single run. Adding current situation

Excel file for .dyn data: Asys name
Drawing: Example
Dynamo script: 7. XML_surfaces_creation.dyn

7. XML_surfaces_creation.dyn (49.1 KB)
Asys name.xlsx (10.2 KB)
Example.dwg (543.4 KB)

Screenshots:

Py code:

Hi
It is better to attach a dynamo file instead of a picture
If there is an example drawing

Do you mean attaching dwg? that is imposible due work related law thing, unless i could create matching example, if its necessary. I can upload .dyn file if that is more helpful?

I said an example drawing Not the drawing you’re working on

Thank you for advice, added :slight_smile:

Hi
The first problem is that a name from Excel does not match with the real name of your link

Divide the text into a list
Capture01

It is necessary to separate the work of the surface from
a code “surf.AddLinkCode(links[i][0], True)”
or
a link " surf.AddFeatureLineCode(links[i]) "

until it is added correctly

7. XML_surfaces_creation 000001.dyn (67.4 KB)

Example(5) 000000.dwg (561.6 KB)

import sys
import clr

# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('Civil3DNodes')

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# 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 for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument




def move_labels(corNames,surfNames,links):
	if not hasattr(corNames, "__iter__"):
		corNames = [corNames]

	if not hasattr(surfNames, "__iter__"):
		surfNames = [surfNames]
		
	if not hasattr(links, "__iter__"):
		links = [links]
		
	error_report = None
	res = []
	try:
		with adoc.LockDocument():		
		    with adoc.Database as db:		
		        with db.TransactionManager.StartTransaction() as t:		    
		            #sampleLineId = PROFILE_VIEW[0].InternalObjectId
		            #objVIEW = t.GetObject(sampleLineId, OpenMode.ForWrite)
		            corId = civdoc.CorridorCollection[corNames[0]]
		            cor = t.GetObject(corId, OpenMode.ForWrite)
		            i = 0
		            #ii = 0
		            for surfName in surfNames:    #surfName in surfNames:
						
						#cor = t.GetObject(corId, OpenMode.ForWrite)
						cor.CorridorSurfaces.Add(surfNames[i])
						surf = cor.CorridorSurfaces[surfNames[i] ]
						#i += 1
						for ii in range( len( links[i] )):
						    #i += 1
						    surf.AddLinkCode(links[i][ii], True)
						    #res.append(links[i][ii])
						
						
						
						
						
						
						
						#i += 1
						surf.IsBuild = True
						bndyCount = surf.Boundaries.Count
						if bndyCount == 0:
						   surf.Boundaries.AddCorridorExtentsBoundary("Corridor Boundary(1)")
						
						i += 1
																
						#res.append('Success')
						res.append(surf)
		            t.Commit()
	except:
		import traceback
		error_report = traceback.format_exc()
	if error_report is None:
		return res
	else:
		return error_report
		
		
		
		
OUT = move_labels(IN[0],IN[1],IN[2])		

What do you mean by this? <<It is necessary to separate the work of the surface from
a code “surf.AddLinkCode(links[i][0], True)”
or
a link " surf.AddFeatureLineCode(links[i]) "

until it is added correctly>>

And i still cant make it work? your script is not creating surfaces, even if i am using your example.

Hi
Test my dyn file that attached with your drawing

I used your Dyn file, and its not creatign surfaces?

I tried the dynamo file And I got the results as shown in the picture
I have attached a drawing for you after applying the dynamo file to it

Look at the drawing, please

Screenshot_٢٠٢٢_٠٣٠٦_١٩٢٥١٥

Did you notice this note?

Yeah i saw this and understand this problem, quotes are not needed.

DUmb. the problem was that there was 5 surfaces and only 3 lists of codes, problem solved :slight_smile:

Do you have any ideas of how to do that in a right way? should i use if func, to see if the code itself is matching link code or point code (by Baseline.codes node)? so by that logic id would run link or featureline add code?

Think Puts LinkCode values ​​into a list and set a condition
If the value exists within the list, then apply the first condition
Otherwise
According to the second condition

FYI there are nodes for working with Corridor Surfaces in Camber v3.0.0.

1 Like

Hi @mzjensen ,

Is it possible that some of these nodes are not available in Autodesk Civil 3D 2021 & 2022 versions? I updated to Camber 4.2.6 and I cannot see some nodes such as CorridorSurface.AddBoundary, xRef.InsertFromFile, etc…

Cheers!

Which specific version of Civil 3D are you using?

image

image

You’ll need to install the latest updates for both versions in order for everything to work. Try with Civil 3D 2021.3 and 2022.1 (at a minimum).

1 Like