Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66666

Re: InserImage into any cell in ViewSchedule Table Header and simple Image Impor

$
0
0

Dear Evgeniy Pashin,

1: The Document.Import(string file, ImageImportOptions options, View view, out Element element) has no any problem to import image to project; From UI, we can insert image via Insert Tab\Import Panel\Image, the Import API just does what UI does.

2: If you want to insert image to TableCell, you should consider another API: TableSectionCell.InsertImage(); besides, to insert image, you should build one ImageType firstly; following code demonstrates how to achieve this:

		/// <summary>
		/// Builds one ImageType and then import it to schedule cell.
		/// </summary>
		public void InsertImage2Schedule()
		{
			// build one ImageType from image in disk
			Document revitDoc = this.ActiveUIDocument.Document;
			ElementId imageId = ElementId.InvalidElementId;
			using(Transaction tran = new Transaction(revitDoc, "Image Type"))
			{
				tran.Start();
				ImageType imageTpe = ImageType.Create(revitDoc, "C:\\ThumbNail.jpg");
				imageId = imageTpe.Id;
				tran.Commit();
			}
			//
			// insert this image to schedule cell 
			ViewSchedule vs = this.ActiveUIDocument.ActiveView as ViewSchedule;
			TableData td = vs.GetTableData();
			TableSectionData tsd = td.GetSectionData(0);
			if(tsd.IsValidImageSymbolId(imageId))
			{
				using(Transaction tran = new Transaction(revitDoc, "Insert Image"))
				{
					tran.Start();
					tsd.InsertImage(0, 0, imageId);
					tran.Commit();
				}
			}
		}

Viewing all articles
Browse latest Browse all 66666

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>