DirectShape Faces not print

DirectShape Faces not print

ModPlus
Enthusiast Enthusiast
244 Views
3 Replies
Message 1 of 4

DirectShape Faces not print

ModPlus
Enthusiast
Enthusiast

I'm create DirectShape by Room solid. Like this:

var fillPatternElement = new FilteredElementCollector(doc)
    .OfClass(typeof(FillPatternElement))
    .OfType<FillPatternElement>()
    .FirstOrDefault(e => e.GetFillPattern().IsSolidFill);

var random = new Random();
var array = new byte[3];
var idCategoryForDirectShape = new ElementId(BuiltInCategory.OST_GenericModel);
using (var tr = new Transaction(doc, "Create room shapes"))
{
    tr.Start();
    foreach (var spatialElement in spatialElements)
    {
        try
        {
            var directShape = DirectShape.CreateElement(doc, idCategoryForDirectShape);
            GeometryElement closedShell = spatialElement.ClosedShell;

            if (directShape.IsValidShape(closedShell.ToList()))
            {
                if (spatialElement.Transform != null)
                    closedShell = closedShell.GetTransformed(spatialElement.Transform);
                directShape.SetShape(closedShell.ToList());
                random.NextBytes(array);
                var color = new Color(array[0], array[1], array[2]);

                SetColor(_uiApplication.ActiveUIDocument, directShape, fillPatternElement, color);
            }
            else
            {
                // message to user
            }
        }
        catch (Exception exception)
        {
            // exception processing
        }
    }

    tr.Commit();
}
...
    private void SetColor(UIDocument doc, DirectShape directShape, FillPatternElement fillPatternElement, Color color)
    {
        var overrideGraphicSettings = new OverrideGraphicSettings();
        overrideGraphicSettings.SetProjectionLineColor(color);
#if R2017 || R2018
        overrideGraphicSettings.SetProjectionFillColor(color);
        overrideGraphicSettings.SetCutFillColor(color);
        overrideGraphicSettings.SetCutFillPatternId(fillPatternElement.Id);
        overrideGraphicSettings.SetProjectionFillPatternId(fillPatternElement.Id);
#else
        overrideGraphicSettings.SetCutBackgroundPatternColor(color);
        overrideGraphicSettings.SetCutBackgroundPatternId(fillPatternElement.Id);
        overrideGraphicSettings.SetCutBackgroundPatternVisible(true);
        overrideGraphicSettings.SetCutForegroundPatternColor(color);
        overrideGraphicSettings.SetCutForegroundPatternId(fillPatternElement.Id);
        overrideGraphicSettings.SetCutForegroundPatternVisible(true);
        overrideGraphicSettings.SetCutLineColor(color);
        overrideGraphicSettings.SetSurfaceBackgroundPatternColor(color);
        overrideGraphicSettings.SetSurfaceBackgroundPatternId(fillPatternElement.Id);
        overrideGraphicSettings.SetSurfaceBackgroundPatternVisible(true);
        overrideGraphicSettings.SetSurfaceForegroundPatternColor(color);
        overrideGraphicSettings.SetSurfaceForegroundPatternId(fillPatternElement.Id);
        overrideGraphicSettings.SetSurfaceForegroundPatternVisible(true);

#endif
        overrideGraphicSettings.SetSurfaceTransparency(50);
        doc.ActiveGraphicalView.SetElementOverrides(directShape.Id, overrideGraphicSettings);
    }

It's all being created normally:

Screenshot_11.png

But when trying to print or export to PDF it's as if the DirectShape created has no Faces:

Screenshot_12.png

Why is that? What can I do with it?

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

jeremy_tammik
Alumni
Alumni

Maybe a print related issue, maybe affected by the transparency? Do you observe any difference between UI and API behaviour? If not, then that is maybe just the way it is.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

ModPlus
Enthusiast
Enthusiast

I tried creating a DirectShape without changing the graphics and then changing the graphics through the UI - the effect is the same. I checked in Revit 2020 and 2024. I get the impression that this is a limitation of Revit itself, but it's strange that no one has had a similar issue so far (I haven't found one)

0 Likes
Message 4 of 4

bimbaas
Explorer
Explorer

I know this is an older post, but... Same issue here with wireframe output when printing, with the same purpose (3D Room volumes). Even using Revit's native pdf export. anyone found a solution yet?

0 Likes