Creating a Subregion *then* using it to shape edit a floor

Hello All,

I’ve been using Dynamo for a while but this is my first post.

As I’m currently a new user I can’t currently upload an attachment - however I’ll upload the graph once I have the ability to. For now I’ll just describe the intended graph:

I’m looking to get two graphs we are using together frequently and combine them to speed things up.

The first takes a Revit floor’s footprint and applies it to a Revit Topo as a Subregion (using the following python script which I got from these forums (thanks to jbo)).

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
import System.Collections.Generic
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

# Get input variables
subregions = IN[0]
host = UnwrapElement(IN[1])

# Init variables
curveLoops = []
createdSubRegions = []
error = []

TransactionManager.Instance.EnsureInTransaction(doc)

# Get groups of curves (exploded polycurves!) and creates per group a SubRegion
for i in subregions:
	# Init CurveLoop for every curve group
	x = CurveLoop()
	
	# Iterate the seperate curves -> convert type to Revit Type -> add to CurveLoop
	for j in i:
		x.Append(j.ToRevitType())
	curveLoops.append(x)
	
	# Add layer to list
	y = [x]
	yI = List[CurveLoop](y)
	
	if SiteSubRegion.IsValidBoundary(yI):
		# Create SubRegion out of the CurveLoop group and add its to 'createdSubregions'
		newSubRegion = SiteSubRegion.Create(doc, yI, host.Id)
		createdSubRegions.append(newSubRegion)
	
TransactionManager.Instance.TransactionTaskDone()

# Output
OUT = createdSubRegions

The second takes a Revit Floor and shape edits it to follow a Topo Subregion.

I’m keen for our users to be able to simply select the Floor and Topo and have both the Subregion and the shape edit executed by the same graph.

The issue I’m having is that the python output won’t currently wire into the Topography.Points node. My Python experience is pretty limited - I’ve tried re-wrapping the SiteSubRegion with ToDSType(False) but I think I’m currently out of my depth.

I’m looking for a suggestion to modify the python script so that it can feed into a Topography.Points node - Thank you in advance for any help you can offer.

1 Like

Hello Martin,

Let’s see if I understand you

Point 1 flat floors to generate regions in the topo, all good, using jbo code
Point 2, you want to project the points of the floors to match the topo?

is this what you need?

Yes - I can already achieve it with two graphs - but I’d like the entire workflow to happen within one graph - without having to manually select the new subregion.

I’ve apparently stopped being a ‘New’ member - so here is the graph… I’ve put a note on the connector which is currently not working.subregion_from_floor.dyn (14.1 KB)

1 Like

Hi @PowellDesign,

creates per group a SubRegion


1 Like

Hi Darmus_Cesur,

The graph I uploaded was already creating a sub-region successfully - this isn’t what I’m having issues with. It is getting the Topography.Points node which follows to recognise and select the python script output (the subregion).

Thanks,

Martin

Thanks Mark - I was wondering how to do this :slight_smile:

Hi @PowellDesign,

The Python output cannot create an “Element”, so you cannot connect the output directly to Dynamoda code entries. Because the resulting output is not the “Element”.
The code works perfectly.

The problem can be solved quickly with this way:

You have a problem with “Converting from Revit.DB.Element to Revit.Elements.Element” and please open a new topic.

4 Likes

Thanks so much Darmus. Really appreciate the help.

I believe the solution shown in your screenshot will not work if there are more than the two topography’s in the project. Because that graph is only removing the topography that is hosting the subregion, correct?

Also, the SiteSubRegion does not inherit Revit.DB.Element but rather .NET Framework System Object.
image
Please correct me if any of my statements are incorrect.

So, does anyone know of another way to convert SiteSubRegion object to Dynamo Element?

I have opened a new thread regarding this topic here.

I got this warning:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 47, in
AttributeError: ‘List[object]’ object has no attribute ‘Id’

Sorry to bring this topic up again.

I successfully replicate the scheme, but mine only complete the slab adjustment the second time I hit run. Looks like in first run it only creates the topo subregion, and needs the second run to read the point list.

ajustaPisoSobreTopografia.dyn (41.8 KB)

And around the same topic, there’s no use for the subregion to remain in the model. I was wondering if I could use Passthrough to delete all of the unnecessary topo-stuff, but there’s some detail I’m missing.

Update: I changed the FirstItem node for a LastItem, to pick always the newly created topo-subregion. In both cases, the issue is: Topography.Points isn’t picking the points.

Use transaction end and start after creating sub region to move the slab after