How could I insert a Raster Image using the Revit API? In other words, the equivalent of doing Insert>Image
Solved! Go to Solution.
Solved by Revitalizer. Go to Solution.
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
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
Dear drdanielfc,
just use:
document.Import Method (String, ImageImportOptions, View, out Element)
Best regards,
Revitalizer
Embedded ?
Embedded into what ?
If it is part of another Revit document, try copy/paste API.
Revitalizer
Hi,
yourView.SetBackground(ViewDisplayBackground.CreateImage(string imagePath, etc.));
Revitalizer
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
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
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.
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
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;" ?
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
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.
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.