GeometryInstance preview

GeometryInstance preview

Anonymous
Not applicable
604 Views
3 Replies
Message 1 of 4

GeometryInstance preview

Anonymous
Not applicable

Hi,

 

I have a linked cad file. The cad file has many blocks. My objective is to get the preview image of that block. Same way we get GetPreviewImage of FamilySymbol.  Any ideas?

 

Thanks & Regards

Sanjay Pandey

0 Likes
605 Views
3 Replies
Replies (3)
Message 2 of 4

Mustafa.Salaheldin
Collaborator
Collaborator

Can you please provide the sample CAD file because I guess I know the solution?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 4

Anonymous
Not applicable

Dear Mustafa,

 

Here is the example file.

 

Thanks & Regards

Sanjay Pandey(BIM[Revit] Developer)

0 Likes
Message 4 of 4

Mustafa.Salaheldin
Collaborator
Collaborator

I got something like this:

        public void PreviewLinkedCAD(Document doc)
        {
            IList<ImportInstance> importIntaces = new FilteredElementCollector(doc)
                .OfClass(typeof(ImportInstance))
                .Cast<ImportInstance>()
                .Where(i => i.IsLinked == true).ToList();

            foreach (ImportInstance ints in importIntaces)
            {
                if (ints.Category.Name.EndsWith(".dwg"))
                {
                    ElementId typeId = ints.GetTypeId();
                    CADLinkType cadLink = doc.GetElement(typeId) as CADLinkType;

                    frmMain frm = new frmMain();
                    frm.BackgroundImage = cadLink.GetPreviewImage(new System.Drawing.Size(128, 128));
                    frm.Show();
                }
            }
        }

The GetPreviewImage method will not work for what I'm trying to do. Sorry about that.

Here is an explanation:

Import Instances don’t have preview images in the Revit user interface either.

 

If you go to place a family instance, the preview image is displayed like this:

 

 

Family instance

 

 

For a Import Symbol, the preview image square in the type selector remains blank:

 

Import Symbol

 

 

This is why GetPreviewImage has nothing it can return. There is a workaround to achieve what you want anyway:

You could create a temporary view, temporarily hide everything except the import instance, and create a snapshot of that.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes