Bug in API revit

Bug in API revit

sizy458
Advocate Advocate
306 Views
1 Reply
Message 1 of 2

Bug in API revit

sizy458
Advocate
Advocate

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.

 

0 Likes
307 Views
1 Reply
Reply (1)
Message 2 of 2

moturi.magati.george
Autodesk
Autodesk

Hi @sizy458,

 

There was a related question on this that was discussed on the forum.

Kindly check if the information offered on the responses is sufficient.

 

https://forums.autodesk.com/t5/revit-api-forum/document-maketransientelements/m-p/7774471#M28625

 

 

  Moturi George,     Developer Advocacy and Support,  ADN Open