Thanks @RPTHOMAS108 @jeremy_tammik I did and still using the Direct3dContext. I was just wondering if there is any documented updated towards the Transient .
After a couple of search I found this:
Using the interface "ITransientElementMaker" didn't show any thing on the GraphicalView, I tried refreshing the view and still nothing.
internal class TransientMaker : ITransientElementMaker
{
public void Execute()
{
DirectShape directShape = DirectShape.CreateElement(m_doc, new ElementId(BuiltInCategory.OST_GenericModel));
directShape.AppendShape(new List<GeometryObject>() { CreateCube() });
}
public Solid CreateCube()
{
CurveLoop cubeBaseLines = new CurveLoop();
cubeBaseLines.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(100, 0, 0)));
cubeBaseLines.Append(Line.CreateBound(new XYZ(100, 0, 0), new XYZ(100, 100, 0)));
cubeBaseLines.Append(Line.CreateBound(new XYZ(100, 100, 0), new XYZ(0, 100, 0)));
cubeBaseLines.Append(Line.CreateBound(new XYZ(0, 100, 0), new XYZ(0, 0, 0)));
var solidCube = GeometryCreationUtilities.CreateExtrusionGeometry(new List<CurveLoop> { cubeBaseLines }, XYZ.BasisZ, 100);
return solidCube;
}
}
and the above is called from the ExternalCommand:
var trans = new TransientMaker();
m_doc.MakeTransientElements(trans);
** it doesn't Require any transaction to work else exception will throw.
After a couple of searches I found ZiyunShang did it using a hacky way. Basically, he executed the method "SetForTransientDisplay" using Reflection, inspired from Dynamo. This will make a Geometry Transient.
Coded like this:
using (Transaction t = new Transaction(m_doc, "Create Transient"))
{
t.Start();
IEnumerable<GeometryObject> geoms = new List<GeometryObject>() { CreateCube() };
var method = GenerateTransientDisplayMethod();
var argsM = new object[4];
argsM[0] = m_doc;
argsM[1] = ElementId.InvalidElementId;
argsM[2] = geoms;
argsM[3] = ElementId.InvalidElementId;
var transientId= (ElementId)method.Invoke(null, argsM); t.Commit();
}
internal static MethodInfo GetTransientDisplayMethod()
{
var geometryElementType = typeof(GeometryElement);
var geometryElementTypeMethods =
geometryElementType.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
var method = geometryElementTypeMethods.FirstOrDefault(x => x.Name == "SetForTransientDisplay");
return method;
}

and To delete "eliminate" the Created Transient, we use the normal Deletion method.
using (Transaction t = new Transaction(m_doc, "Delete Transient"))
{
t.Start();
m_doc.Delete(transientId);
t.Commit();
}
The thing that drives a question, why a document.Delete(eId) is required to delete an object that originally doesn't exist in the projectdocument, even the projectdocument it self doesn't consider it self changed. Meaning the moment you close the opened Project, it doesn't ask for a save. which is also contrary to the commited transaction used to generate the transient.
This is all i got since yesterday's discussion. I will try to dig deeper later if necessary.
Credit goes to ZiyunShang
Additional things I noticed while exploring the Source code.
Moustafa Khalil