Created
September 6, 2016 19:16
-
-
Save gtalarico/02c8112b955f9dafed06a169c3a36b0f to your computer and use it in GitHub Desktop.
RevitAPI::Code Snippets::Import Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import Image | |
# http://www.revitapidocs.com/2015/05c3dbe2-fe7e-c293-761d-b11f356a011b.htm | |
from clr import StrongBox | |
from Autodesk.Revit.DB import XYZ, ImageImportOptions, BoxPlacement, BuiltInParameter | |
# Import Options | |
import_options = ImageImportOptions() | |
import_options.Placement = BoxPlacement.Center | |
import_options.RefPoint = XYZ(0,0,0) | |
import_options.Resolution = 72 | |
# Create New Image in Revit | |
t = Transaction(doc, 'Crop Image') | |
t.Start() | |
new_img_element = StrongBox[Element]() | |
new_img_path = 'C:\\path\\to\\image.jpg' # Remember to escape backslashes | |
width_in_ft = 2 | |
doc.Import(new_img_path, import_options , doc.ActiveView, new_img_element) | |
new_img_width = new_img_element.get_Parameter(BuiltInParameter.RASTER_SHEETWIDTH) | |
new_img_width.Set(width_in_ft) | |
t.Commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment