Is it possible?

To use dynamo to insert an image into a drafting view?

You can use a custom Python node and call this Revit API method:

Document.Import (String, ImageImportOptions, View, Element)

Let me know if you need more help.

In theory I understand what you are saying, i just dont have the coding chops to execute. In the simpler big picture, I’m trying to create a script that when run will update a drafting view (containing only a image) from a file path of that image. i searched through all the nodes and found some parts to do this but cant see the whole process.

So, it wasn’t as easy as i thought it would be, but I was still able to do what you were asking for. Here it is:

First you need to import an image into a drafting view and to achieve it we need to call the method that I mentioned previously:

Document.Import(string, ImageImportOptions, View, Element)

Where:

String is a file path to the image.

ImageImportOptions is a class in Revit API that defines where and how we want to place our image.

View is a view that you want to place your import in.

Element is a new element class that Revit will use to store the newly created image in so that you can use that image element later.

Now, let’s have a detailed look at how we create a node like that:

File Path is simple enough because that node already exists.

ImageImportOptions would need to be created like so: ImageImportOptions() and there are three properties that we can set for that class: Placement, Ref Point and Resolution.

Placement can be set to either one of the outputs of BoxPlacement enumeration class and can be one of the following: Center, TopLeft, TopRight, BottomRight, BottomLeft. This basically sets what point in the image will be aligned with the Ref Point.

Capture1

 

 

 

This gets us to the next property which is RefPoint. This is a point in a view that image will be placed at and has to be a XYZ() class. For that we can use just a Dynamo point and use a simple conversion function later.

Resolution is a resolution of the image in DPI and by default it will be set to 72 but can be changed with an integer input. Here are refpoint and resolution defined and new ImageImportOptions node:

This should define our import options for the image.

Capture4

 

Next we need to obtain a View that we want to place our imported image in. You can use archi-lab’s node called Get All Views and then extract the one that interests you like so:

Capture5

 

You can put that into our newly created Import Image node. We already defined inputs for it. That node will only execute the call that we talked about early in the post. Once its done, you should see a new image pop into your drafting view.
Capture7

To reload it you would have to use the last bit of code that i provided here.

 

 

 

Here’s the reload image definition. I couldnt upload it there:

 

Capture8

 

 

The reload image node will take an input of a file path and it will split it into separate components to extract the image name only because then we can use the image name to extract an imported element type and then simply reload it. Keep in mind that if you run the import image node multiple times, each time it will insert a new image into the model. Go to Manage Images dialog box in revit to see the new instances. They will keep getting a (1), (2), (3) etc appended to their name. Make sure that you don;t create multiple instances of the image, because only the first one will match the original file name and thus reload properly. All other ones will not. Good luck!

Konrad, you are god. Ive been studying your actions and applying them to a new script. Way more intense then I could have realized. Great stuff.
I did hit a stumbling block on my end as I got to the 2nd custom python script that creates the 3 inputs:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “<string>”, line 17, in <module>
IndexError: index out of range: 1
error

you need to hit that plus sign two more times on the yellow python node

myles, your script expects 3 inputs namely placement IN[0], sefPt IN[1] and res IN[2]

and you are only providing 1 input = Code Block

That was an easy fix :slight_smile: for that node. i see now that that is manual function you need to perform tied to your list of inputs.

Working through hit another roadblock that im not clear on; these python nodes are tripping me up. Thanks Dynamo community!

Screenshot 2015-07-10 16.47.52

You will have to unwrap thepoint input

Not exactly, the error states that point doesn’t have attribute “y” which i am guessing is the letter case problem. Capital Y should be used as in point.Y or point.X. Try that

Hi KONRAD,

I did what you said in order to achive this script and I’m wondering if it could work not just for a sheet and one coordinatation but for a list of sheets and at some diferents points.

THks

 

Hi KONRAD,

Did you see my post?

I can see it now. Please start a new post for this question. This one has been answered.

None of the scripts are clearly visible. This solves my problem but i can not read the python scripts. Please Help !!!

Hi Konrad,

I wondered if you could potentially assist me with the image placement problem I have posted about linked here -
Placing images at mapped (x,y,z) positions.

I am trying to zoom into the python node snapshots you have attached to this post but it is not clear enough to read and reproduce unfortunately?

Thanks!