ProfileView Datum

I wish to read & set the Datum of a ProfileView, so its the level range lower and upper. Im familiar with Dynamo and have just recently posted a query which required python, as I believe to solve this requires the same. Im complete novice and came up with this -

           profileView = IN[0]

            Datum = []
            for pv in profileView:
                profile_view = t.GetObject(profile_view_id, OpenMode.ForWrite, True)
                Profile_View_Name = profile_view.Name
                Datum = profile_view.ElevationMin
            # Commit before end transaction

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

I suppose Im looking for something I can work from to understand the syntax of it all. Not a lot online for civil3D python


try this

import sys
import clr


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

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

from System.Collections.Generic import Dictionary

adoc = Application.DocumentManager.MdiActiveDocument
cdoc = CivilApplication.ActiveDocument

from Autodesk.DesignScript.Geometry import *

def get_profileView_info(profileViews):
	global adoc
	global cdoc
	output = []

	if not profileViews:
	if not isinstance(profileViews, list):
		profileViews = [profileViews]

	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
				for profileView in profileViews:			
					profileViewId = profileView.InternalObjectId
					obj = t.GetObject(profileViewId, OpenMode.ForRead)
					if isinstance(obj,ProfileView):
					   Profile_View_Name = obj.Name
					   Datum = obj.ElevationMin
	return output 		

OUT = get_profileView_info(IN[0])

1 Like

That worked ! Thanks very much, another helping hand from yourself. Much appreciated. I will now look at how to set this value based on your code, helps the learning process.

There were a few errors with spacing/indents and it took some messing about with tab key but got there in the end

1 Like