Announcement

Collapse
No announcement yet.

How to export FamilyDocument without activating Family Document?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to export FamilyDocument without activating Family Document?

    Hello everyone.
    I need to get Image, DWFX and FBX files of selected family element in project. I am trying to do this with following code:
    Code:
    Element el = commandData.Application.ActiveUIDocument.Selection.Elements[0];
    if (el is FamilyInstance)
    {
    
    Document currentDoc = commandData.Application.ActiveUIDocument.Document;
    
    Family fam = el.Symbol.Family;
    
    //Get family document
    Document famDoc = currentDoc.EditFamily(fam);
    
    //And now I'm trying to get Image
    ImageExportOptions ieo = new ImageExportOptions();
    ///....
    ///ieo.Init
    famDoc.ExportImage(ieo);
    
    //get exported views
    ViewSet vs = new ViewSet();
    
                //In this case Active View always null
                if (famDoc.ActiveView == null) 
                {
                    FilteredElementCollector collector =
                        new FilteredElementCollector(famDoc);
    
                    // May be you know how to get default 3D view with other method
                    var views =
                        collector.OfClass(typeof(View3D))
                        .Where(v=>v.Name == "{3D}")
                        .ToList();
                    
                    foreach (View3D v3d in views)
                    {
                        vs.Insert(v3d);
                    }
                }
    
    //And Export to FBX
    //Here export always false
     if (document.Export(Path.GetTempPath(), tempFile, vs, new FBXExportOptions()) == false)
    {
    
    }
    
    //Export to DWFX 
    //code same as export to FBX
    
    }
    So. I want to open Family Document using API function Document.EditFamily and then export it to other formats. But when I export famDoc to Image I get image of currentDocument not famDoc. When I export famDoc to FBX and DWFX the Export function always returns false.

    Anybody knows how to get Family Image and Export to FBX via Revit API without opening and activate Family Document or it's not impossible?

    Thanks.

    #2
    Anybody can help me?

    Comment

    Related Topics

    Collapse

    Working...
    X