Insert Raster Image

Insert Raster Image

Anonymous
Not applicable
6,316 Views
24 Replies
Message 1 of 25

Insert Raster Image

Anonymous
Not applicable

How could I insert a Raster Image using the Revit API? In other words, the equivalent of doing Insert>Image

0 Likes
Accepted solutions (1)
6,317 Views
24 Replies
Replies (24)
Message 2 of 25

jeremytammik
Autodesk
Autodesk

Install RevitLookup. Explore the Revit database. Insert an image manually. Check what changed. That tells you what elements were added. Then you can look in the Revit API help file RevitAPI.chm to see how to add such elements programmatically. If you do not have RevitLookup and RevitAPI.chm installed, work through the getting started material first of all, especially the My First Revit Plugin and DevTV tutorials.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 25

Anonymous
Not applicable

RevitLookup is installed, I've gone thru the First Plugin tutorial, and have been writing plugins for about a month now. However, I can't seem to figure this one out. I've found the element in Revit lookup but the information doesn't seem particularly helpful. I also don't seem to be able to find anything relevent in the RevitAPI.chm file. I know how annoying it is when people don't seem to be willing to pull their weight on forums, but I just can't seem to find my way past the first hurdle of what function I would call to create an image. I should be able to figure everything else out thereafter.

 

Cheers

0 Likes
Message 4 of 25

Revitalizer
Advisor
Advisor
Accepted solution

Dear drdanielfc,

just use:
document.Import Method (String, ImageImportOptions, View, out Element)

 
Best regards,
Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 25

Anonymous
Not applicable

How to insert embeded image into revit file ?

 

 

 

 

0 Likes
Message 6 of 25

Revitalizer
Advisor
Advisor

Embedded ?

Embedded into what ?

 

If it is part of another Revit document, try copy/paste API.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 7 of 25

Anonymous
Not applicable
For example. I want add custom image on backgroud of the view. I want that i don't need image file
0 Likes
Message 8 of 25

Revitalizer
Advisor
Advisor

Hi,

 

yourView.SetBackground(ViewDisplayBackground.CreateImage(string imagePath, etc.));

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 9 of 25

Anonymous
Not applicable
Thanks,
I know that . That is not what I want. I want that i don't need external source of image. Because, when I move .rtf file to another computer i also need to move the image file.

0 Likes
Message 10 of 25

Revitalizer
Advisor
Advisor

Hi,

 

you should better have asked

"How to embed image into revit file ?"

instead of

"How to insert embeded image into revit file ?"

 

The answer is: no, you cannot embed an image, you just can reference it.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 11 of 25

Anonymous
Not applicable
Thanks 🙂
0 Likes
Message 12 of 25

Anonymous
Not applicable
Hi,

Is it possible to reference image from web location and how ?
0 Likes
Message 13 of 25

Revitalizer
Advisor
Advisor

Hi,

 

here is an approach using AVF:

 

http://thebuildingcoder.typepad.com/blog/2010/06/grabbing-an-internet-webcam-image.html

http://thebuildingcoder.typepad.com/blog/2012/02/revit-webcam-2012.html

 

Using not the view depending analysis visualization framework but persistent image elements:

Once grabbed and stored the image, you can update an existing ImageType by its Reload() methods.

 

 

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 14 of 25

Anonymous
Not applicable

Hi,

 

is it Possible do something like that.

 

   String PATH_FILE = "http://net.dd/image.png";

   dispBackground = ViewDisplayBackground.CreateImage(PATH_FILE, ViewDisplayBackgroundImageFlags.UseTiling, UV.Zero, UV.Zero);

 

I tried. Got file not found exception.

 

 

0 Likes
Message 15 of 25

Revitalizer
Advisor
Advisor

Hi,

 

obviously, you answered your question by yourself.

You cannot.

 

RevitAPI.chm says:

"Autodesk.Revit.Exceptions.FileArgumentNotFoundException: The file specified by imagePath doesn't exist. "

 

It seems that Revit needs a valid local file path but not a web URL.

That is understandable:

A web url would be an external resource that would need to be watched by Revit, since it could be temporarily unavailable, could change its content, etc.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 16 of 25

Anonymous
Not applicable
Ok Thanks 🙂
0 Likes
Message 17 of 25

Anonymous
Not applicable

Hi !

Nice ! Thanks ! It helped me !

The function "ducument.import(PathToFile, ImageOptins, view, out Element)" is really usefull !

To go further, is it possible to use "out Element" as a raster image ?
Is it possible to get something like "Element.width = ChosenWidth;" ?

0 Likes
Message 18 of 25

sobon.konrad
Advocate
Advocate

Revitalizer,

 

Would a nasty workaround like this possibly work: you could store the image inside of view as extensible storage (byte stream?) and then in case that file was moved from its original location write a new image to a relative location (from byte stream), so that ViewCreateBackground.CreateImage() method can be executed. Thoughts? 

 

-K

0 Likes
Message 19 of 25

Anonymous
Not applicable

I'm actually doing something similar in one of my add-ins. I store a base64 image string and write it to a temp file for loading. It works fine.

0 Likes
Message 20 of 25

jeremytammik
Autodesk
Autodesk

Dear Konrad,

 

Yes, absolutely that would work!

 

In fact, I implemented and published a Revit plug-in that stores and retrieves arbitrary files to and from extensible storage:

 

https://github.com/jeremytammik/EstoreFile

 

You should also take a look at The Building Coder topic group on extensible storage:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.23

 

I just expanded and completed it a little bit, just for this conversation here.

 

Cheers,

 

Jeremy.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder