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
            #t.Commit()
            #pass

# 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

Thanks

hi
try this

import sys
import clr

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

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:
		return
	
	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
					   output.append([Profile_View_Name,Datum])
						
				t.Commit()
	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