Multi-Segment grids

Is there a simple way to extract the coordinates of the sketch for a multi segment grid to recreate it in another file.

Can you show a picture? I’m not sure what attend to do.

Show us what you’ve tried. You can get grid geometry with just a few nodes.

if I have a grid (see attached image) and this is a multi-segment grid. how can I edit the grid sketch and copy all the segments in the sketch and have dynamo redraw this multi-segment grid in another file.

I imagine this is a read coordinates > write coordinates function within a sketch for a specified category of element.

trying to find the right nodes or functions to do this in as few steps as possible.

Have you tried open the projects in the same Revit session, then be in a grid sketch in both of the sessions and then copy from your project and over in the new project? :slight_smile:

Try working backwards. What do you need to create a grid with Dynamo? How do you get that information from an existing grid? Look for nodes that can help with that process.

As @CVestesen said, copy/paste is probably a better option in this case - either manually or automated.

I’d actually go copy monitor before copy paste, as that’s about as few clicks as you’ll likely get via Player.

1 Like

that would be fine for 1 grid. when you have 40+ to do its different. which is why i’m looking at dynamo.
also needs to be repeated in about 50+ files.

1 Like

can’t copy monitor multi-segment grids.

1 Like

Ah! Third feature request of the day for me right there. Totally forgot about that limitation.

You’ll either have to copy the grid elements from another document and paste into a new one or use the API to create new grids from the existing geometry.

1 Like

Yes, so MultiSegmentGrids are not the same type of objects as regular Grids. Having said that I must respond to Nick’s comment:

Yes, and no. Not with the existing nodes. None of the ones that I saw in Dynamo do the trick unless you do something first - get the Grid objects out of the MultiSegmentGrid object. Basically a multi-segment grid is multiple grids stored inside of different object.

Anyways let’s say I have a file like so:

I put some fancy multi segment grids in there to demonstrate the workflow. First we need to collect the data:

You end up with an excel file like so:

Now we can jump into a different file and read that data in, and re-create our grids:

Here’s the result:

As you can see some grids have a different “direction”. That’s because when we were joining the curves, they probably got sorted into a different order. You might have to clean that up somehow. I don’t want to get too much into the weeds with this stuff. Obviously my grids have weird numbers in the bubbles, but that’s because I ran this definition couple times when testing, and deleted previous set of grids every time. Still, a better approach would be to set the grid number from excel, so don’t export just geometry, but also include the number etc. Your call.

Here’s the Python code for getting grid segments from MultiSegmentGrid:

# Copyright(c) 2018, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

import System
from System import Array
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

def get_grids(g):
	grid = UnwrapElement(g)
	ids = grid.GetGridIds()
	grids = []
	for i in ids:
		grids.append(doc.GetElement(i))
	return grids

try:
    errorReport = None
	output = [get_grids(x) for x in IN[0]]
except:
    import traceback
    errorReport = traceback.format_exc()


if None == errorReport:
    OUT = output
else:
    OUT = errorReport

Here’s the Python code for creating a new MultiSegmentGrid:

# Copyright(c) 2018, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

import System
from System import Array
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

def create_grid(type, curves, plane):
	typeId = UnwrapElement(type).Id
	plane = Plane.CreateByNormalAndOrigin(XYZ(0,0,1), XYZ(0,0,0))
	sketchPlane = SketchPlane.Create(doc, plane)
	curveLoop = CurveLoop()
	for i in curves:
		c = i.ToRevitType()
		curveLoop.Append(c)
	grid = MultiSegmentGrid.Create(doc, typeId, curveLoop, sketchPlane.Id)
	return grid

try:
    errorReport = None
    TransactionManager.Instance.EnsureInTransaction(doc)
    output = []
    for i in IN[1]:
    	output.append(create_grid(IN[0], i, IN[2]))
    TransactionManager.Instance.TransactionTaskDone()

except:
    import traceback
    errorReport = traceback.format_exc()

if None == errorReport:
    OUT = output
else:
    OUT = errorReport

You will need archi-lab.net and bumblebee packages for this:

image

Definition files can be found here:

2_Grids.dyn (63.0 KB)
2_GridsRead.dyn (73.2 KB)

This was built with Revit 2019 and Dynamo 2.0

17 Likes

This is great @Konrad_K_Sobon.
This is the exact workflow I started working on yesterday.
Get the sketch > store the coordinates > run that as a create multi-segment grid per stored segment coordinates.

What you’ve shared is very helpful thanks for taking the time.

been playing with this a bit now and running in to a few snags:

the read is clean i’m getting same results with my coordinates. all good.

the write seems to be breaking for me though:
not sure why but in the recreate curves function the arc is collecting the line segment coordinates and the line is collecting the curve coordinates. the nodes look to be connected right, I’ve tried flipping a few around.

due to this function failing the curve.ByJoinedCurves and PolyCurve.Curves fails as well.

any thoughts or ideas?

I’ve tried doing smaller chunks of the read csv as well and same issue, thought it might be a data mismatch as its a decent sized dataset? the initial read runs about 1100 coordinate combinations.

add, gives a traceback error.

I think I said this before, but let me re-iterate. You have to make sure that all of the curves are in the proper order before attempting to create a Multi-Segment Grid from them. What do I mean by “proper order”? I mean that if a grid is made of 2 curves:

[curve1, curve2]

…then when you feed them into the grid creation Python node, curve1 end point has to be the same as curve2 start point. They have to be continuous like that.

Now, I made a quick and dirty way of doing that by joining the curves and then extracting their curves again, but that’s not likely a good idea. You might want to be a little bit more specific in your implementation if you want this to be working well across multiple projects etc.

In summary, I gave you a blueprint mate. Time to do some work. Good luck!

Hi @Konrad_K_Sobon, If I want to extract the IDs name for multi-segment grids(Bubble names), What should I do ?
As, Is the sample Image the IDs for multi-segment grids are 8,9,10,11. But when gets created into another project the names were changed as 24,22,23,21 (in the last image). Like I want to get exact IDs name with same side of position. Is this possible, if yes then what should the approach.

As said above, get the Grid name value, and write it to excel with other data. Then simply set the name to that value when re-creating the Grids.

Hi @Konrad_K_Sobon, I tried to test dynamo script and its working perfectly fine from data extraction of previous project to re-create the multi-segment grids in new projects. But while testing on a project , the recreating of multi-segment grids on Revit get very small size and not be able scale up. But it completely build up similar in Dynamo but I am not sure why its happening in Revit.

Check the grid type.

Yes, Its creating a multi-segment grid, But its creating as shows in the below image.