Draw Border Around Raster Image with Dynamo

When importing several images or pdfs, I typically draw detail lines around them to create a border, separating pages (typically for specs on sheet).

Is there a way to automate this process through dynamo by drawing a border around images, even if the lines are borders that are touching? Like so:

I would assume this would have to be based on coordinates of a view/sheet, but if it could grab the coordinates of the images and trace the borders, that’s exactly what I’m looking to do.

element.bounding box to get the corner-point and draw a rectangle from there?

Getting a null list

Is Select.ByCategoryAndView returning valid elements? A valid ImageInstance should have a bounding box.

Seems to be all valid elements

Might be worth noting these are imported as pdfs in Revit which classifies them as Raster Images, if that may change anything

Another node works! Since each only gives two points, is there a node I don’t know of that could use just these two to draw a rectangle or do I need all four?

It gives you the full bounding box, it’s just that a bounding box only has the min and max points as properties. So you’ll have to get the perimeter yourself.

I’d recommend two ways to do that:

  1. Build the points: Get the min and max point and build the other two missing points based on the X and Y coordinates. Because the image is a “flat” object, the Z coordinates shouldn’t matter.
  2. Get the bounding box boundaries: Convert the BoundingBox to a Cuboid, then get the Edges of the cuboid topology. Again, because the image is flat, you should get just the one set of edge boundaries. The edges can then be converted directly into curves.
1 Like

Success! Thanks for the help!

1 Like

Nice. You can even use Edge.CurveGeometry to skip the rebuilding of the curves.

And as an added FYI, here’s what building the points would look like:

I have all of them coincident like so, and I have a feeling this would double up the line thickness for plotting. Is there a way to delete the overlapping lines after these are created? Or filter out duplicates of the overlapping horizontal and vertical edges beforehand? I was messing with a Clean.list script but didn’t really get it to work well…

If they really are coincident then they won’t be any thicker. Line weight is just line weight.

You can filter out duplicates but it’s a little tricky due to curve direction. Search the forum for topics on comparing lines/curves. There are quite a few that should at least get you started.

I just have the image import script to start the next one in the row at (x+width of bounding box). If you zoom in, the lines are technically not touching, but I’m not sure of another way to line the images up perfectly without aligning in Revit

That would only work if all your images are exactly the same width. Technically it would be half of the previous image’s width plus half of the new image’s width.
width1 / 2 + width2 / 2;

They are all the same width, since it’s the same sheet sizes for all of the pdf pages.

Confirm that (through Dynamo) if you haven’t already. The math won’t lie. If they aren’t lining up then something is off.

Either way, it still might be best to build the offset based on the images.