# Create Sample Lines and Section Views

**URL:** <https://forum.dynamobim.com/t/create-sample-lines-and-section-views/95284>\
**Category:** Civil 3D\
**Created:** [November 7, 2023, 5:51pm UTC](https://forum.dynamobim.com/t/create-sample-lines-and-section-views/95284 "2023-11-07T17:51:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piscis](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@Piscis](https://forum.dynamobim.com/u/Piscis)\
**Post date:** [November 7, 2023, 5:51pm UTC](https://forum.dynamobim.com/t/create-sample-lines-and-section-views/95284/1 "2023-11-07T17:51:12Z")

</div>

Hello, a question about which nodes could be used to do what is in the video, of course, if possible, I sent the first part, which is for the sample line, but the section views would be missing.

> **[Rec 0045.mp4](https://drive.google.com/file/d/1zFUs6lPuS2SuQ-C0e6lC1uHrH06Xjvmx/view?usp=sharing)**
>
> Google Drive file.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/e/beb3469078fac5bf4ff04866e01fe872c14cff8f.png)

---

<div class="post-metadata">

**Author:** ![kovacsv](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kovacsv](https://forum.dynamobim.com/u/kovacsv)\
**Post date:** [November 8, 2023, 7:10pm UTC](https://forum.dynamobim.com/t/create-sample-lines-and-section-views/95284/2 "2023-11-08T19:10:18Z")

</div>

I have a work in progress for section views, it creates the views, I had some issues with styles, modify it for your needs:

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

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

#sample line groups
SLGS = IN[0]
#insertion point
P = IN[1]
#station range, 0 if from start to end
SSin = IN[2]
ESin = IN[3]
#placement type 0 if draft anything else if production
placement = IN[4]
templatepath = IN[5]
layoutname = IN[6]

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

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            P1 = Point3d(P.X, P.Y, P.Z)
            for SLG in SLGS:
				SLGId = SLG.InternalObjectId
				SLGOb = SLGId.GetObject(OpenMode.ForWrite)
				
				SLGS = SLGOb.GetSectionSources()
				for source in SLGS:
					st = source.SourceType
					if str(st) == "TinSurface":
						source.IsSampled = False
						source.IsSampled = True
						source.StyleId = civdoc.Styles.SectionStyles["UNI_terep"]
					if str(st) == "Corridor":
						source.IsSampled = False
						source.IsSampled = True
						source.StyleId = civdoc.Styles.CodeSetStyles["UNI_Keresztszelvény_Kiviteli"]
					else:
						pass
					sn = source.SourceName
					if str(sn) == "Terep":
						EGId = source.SourceId
				
				PA = SLGOb.ParentAlignmentId.GetObject(OpenMode.ForRead)
				
				if SSin == 0:
					SS = PA.StartingStation
				else:
					SS = SSin
				if ESin == 0:
					ES = PA.EndingStation
				else:
					ES = ESin
					
				rangeOptions = SectionViewGroupCreationRangeOptions(SLGId)
				
				placementOptions = SectionViewGroupCreationPlacementOptions()
				
				
				if placement == 0:
					placementOptions.UseDraftPlacement()
				else:
					placementOptions.UseProductionPlacement(templatepath,layoutname)
					
				sectiondisplayOptions = SectionDisplayOptionCollection(SLGId)
				for option in sectiondisplayOptions:
					option.Draw = True
				
				#sectiondisplayOptions[0].UseOverrideStyle = True;
				#sectiondisplayOptions[0].OverrideStyleId = civdoc.Styles.CodeSetStyles["UNI_Keresztszelvény_Kiviteli"];
				
				sectionViewStyleId = civdoc.Styles.SectionViewStyles["UNI_ksz rajz"]
				
				sectionViewBandSetStyleId = civdoc.Styles.SectionViewBandSetStyles["UNI_ksz_lábléc"]
			
				SVGC = SLGOb.SectionViewGroups
				SVGS = SVGC.Add(P1,SS,ES,rangeOptions,placementOptions,sectiondisplayOptions,sectionViewStyleId,sectionViewBandSetStyleId)
				SVGS.PlotStyleId = civdoc.Styles.GroupPlotStyles["UNI_ksz_csoportnyomtatás_420"]
				SVIds = SVGS.GetSectionViewIds()
				for SVId in SVIds:
					SV = SVId.GetObject(OpenMode.ForWrite)
					SL = SV.SampleLineId.GetObject(OpenMode.ForWrite)
					EGsectionid = SL.GetSectionId(EGId)
					bottombanditems = SV.Bands.GetBottomBandItems()
					for bottombanditem in bottombanditems:
						#if bottombanditem.BandStyleId == civdoc.Styles.BandStylesRoot.SectionViewSectionDataBandStyles["UNI_ksz_terep magasság"]:
						bottombanditem.Section1Id = EGsectionid
					SV.Bands.SetBottomBandItems(bottombanditems)
						#else:
							#pass
				
				P1 = Point3d(P1.X,P1.Y-70,P1.Z)
				
				sectiondisplayOptions.Dispose()

            # Commit before end transaction
            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT = bottombanditems

```
