revit二次开发-获得族类型的缩略图

 PictureBox pictureBox = null;
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            
            

         
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;
            Reference refer = uidoc.Selection.PickObject(ObjectType.Element,  "拾取目标构件");

            FamilyInstance instance = doc.GetElement(refer) as FamilyInstance;
            FamilySymbol symbol = instance.Symbol;
            //可以将image保存或是传递给PictreBox
            Form1 form1 = new Form1();
            form1.Show();
            System.Drawing.Image image = symbol.GetPreviewImage(new System.Drawing.Size(100, 100));
            weiTuo wei = new weiTuo(form1.GetPicture);
            wei(image);

 

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ClassLibrary2
{
    public delegate void weiTuo(Image image);
    public partial class Form1 : Form
    {
        public Form1()
        { revit二次开发-获得族类型的缩略图_第1张图片

 

 

 

 

小弟在这里是留下的自己的笔记,不喜勿喷,想交流大家一块研究    

 

 

 

 


            InitializeComponent();

        }

        public  void GetPicture (Image Image)
        {
            pictureBox1.Image = Image;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
 

你可能感兴趣的:(revit二次开发)