Is it possible to convert SectionView ObjectId → Dynamo CivilObject?
It’s not possible
Civil 3D does not expose SectionView objects through the CivilObject API in a way that allows a direct cast or conversion. SectionViews simply aren’t wrapped as CivilObjects in the Dynamo environment.
-–
If not, what is the recommended workflow to get a CivilObject output for SectionView?
Close this dyn and use another one after using the sections
The practical workflow is:
- Use your current Dynamo graph to create or manipulate SectionViews.
- Save, close, and run a separate Dynamo graph that works with the resulting geometry or data after the SectionViews exist.
This avoids the limitation of not being able to treat SectionViews as CivilObjects.
-–
Should SectionView creation always be done using SectionView.BySampleLine instead of Python?
Just try
In practice, the node is more stable and predictable than Python for SectionView creation, but you can experiment. Python can work, but it’s more fragile because the API surface for SectionViews is limited.
Dynamo is a .NET wrapper of the host application API, and all nodes are just .NET wrappers. So if Dynamo allows you to do something via nodes, you can most assuredly call the same nodes via other means and get the same result(s). The question is ‘what is the correct call’. Sadly Civil 3D is the only mature Dynamo integration which isn’t open source, so we can’t review what the changes might be. However if you provide a sample graph which does what you’re after (basically what @zieios recommends in his second answer), and are willing to spend some time poking at the exposed portions of the Dynamo for Civil 3D api you can likely start to identify what the methods needed might be.
For Section Views, it appears that conversion to a CivilObject can work only when the workflow is split into two steps:
first output the SampleLine, and
then run SectionView.BySampleLine in the next step.
If I try to do this in one continuous process, Civil 3D becomes unstable and may crash/close unexpectedly. So at the moment, the Section View workflow seems to require that intermediate SampleLine step for stability.
By contrast, the Profile View workflow is behaving normally. ProfileView.ByAlignment works correctly with CivilObject.SetStyle, and I have not seen the same instability there.
At this stage, I am not yet sure why Section Views behave differently from Profile Views. My current assumption is that there is a limitation or instability in the Civil 3D Dynamo wrapper/API specific to Section Views, rather than a general issue with the graph logic.