Message 1 of 2
Bug in API revit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
The source does not work,
I can't see the 3d object.
Source:
public class TransientElementMakerT : ITransientElementMaker
{
public static Solid CreateBox()
{
XYZ btmLeft = new XYZ(-3, -3, 0);
XYZ topRight = new XYZ(3, 3, 0);
XYZ btmRight = new XYZ(topRight.X, btmLeft.Y, 0);
XYZ topLeft = new XYZ(btmLeft.X, topRight.Y, 0);
Curve btm = Line.CreateBound(btmLeft, btmRight) as Curve;
Curve right = Line.CreateBound(btmRight, topRight) as Curve;
Curve top = Line.CreateBound(topRight, topLeft) as Curve;
Curve left = Line.CreateBound(topLeft, btmLeft) as Curve;
CurveLoop crvLoop = new CurveLoop();
crvLoop.Append(btm);
crvLoop.Append(right);
crvLoop.Append(top);
crvLoop.Append(left);
IList<CurveLoop> cl = new List<CurveLoop>();
cl.Add(crvLoop);
Solid box = GeometryCreationUtilities.CreateExtrusionGeometry(cl, XYZ.BasisZ, 5);
return box;
}
private readonly Document _document;
public TransientElementMakerT(Document document)
{
_document = document;
}
public void Execute()
{
DirectShape ds = DirectShape.CreateElement(_document, new ElementId(BuiltInCategory.OST_GenericModel));
ds.AppendShape(new List<GeometryObject>() { CreateBox() });
}
}
[Transaction(TransactionMode.Manual)]
public class CommandTransient2 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document document = commandData.Application.ActiveUIDocument.Document;
using (Transaction t = new Transaction(document, "Create Transient"))
{
var transient = new TransientElementMakerT(document);
document.MakeTransientElements(transient);
//document.Regenerate();
commandData.Application.ActiveUIDocument.RefreshActiveView();
//commandData.Application.ActiveUIDocument.
}
return Result.Succeeded;
}
}
Thank.
Developer Advocacy and Support,