Message 1 of 4
DirectShape Faces not print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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:
But when trying to print or export to PDF it's as if the DirectShape created has no Faces:
Why is that? What can I do with it?