Hi.
I have this:
using (Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { Alignment alineacion = trans.GetObject(entRes.ObjectId, OpenMode.ForRead) as Alignment; PromptPointResult ppr; PromptPointOptions ppo = new PromptPointOptions("\nPica un punto en el eje o cercano a él.(se considerará el punto proyectado sobre el eje) : "); ppo.AllowNone = true; double pk = 0; double offset = 0; ObjectId IdLineaAux = new ObjectId(); do { ppr = ed.GetPoint(ppo); if (ppr.Status == PromptStatus.OK) { try { alineacion.StationOffset(ppr.Value.X, ppr.Value.Y, ref pk, ref offset); IdLineaAux = toolsC3D.Objetos.Entidad_AutoCAD.ObtenerXline_Alineación(alineacion.ObjectId, pk, ModoTransversal); //ed.WriteMessage("\nP.K: " + functions.funciones_genéricas.formatoPK(pk) + " " + "Offset: " + functions.funciones_genéricas.stringdecimales(offset, variables_globales.precisio[0].decimalesLongitud)); } catch { ed.WriteMessage("\nFUERA DE LÍMITES"); } } } while (ppr.Status == PromptStatus.OK); trans.Commit(); }
I have a loop (do... while) and within it, I want to create a xline every time with :
IdLineaAux = toolsC3D.Objetos.Entidad_AutoCAD.ObtenerXline_Alineación(alineacion.ObjectId, pk, ModoTransversal);
However, I don´t get a xline every time. I get all the xlines when I've just pressed "cancel" keyboard.
How can I do it to work like I would want?
Thanks.
P.S: some objects are from Civil 3D because it´s for Civil 3D.
Solved! Go to Solution.
Solved by joantopo. Go to Solution.
OK.
Transaction is within the loop, and we close transaction (tr.Commit() ) just before to call my method to draw xlines.
do { using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { Alignment alineacion = tr.GetObject(idAlin, OpenMode.ForRead) as Alignment; PromptPointOptions ppo = new PromptPointOptions("\nPica un punto en el eje o cercano a él.Para teclear un PK, escribe \"PK,0\" : "); ppo.AllowNone = true; ppr = ed.GetPoint(ppo); if (ppr.Status == PromptStatus.OK) { try { if (ppr.Value.Y == 0) //se dá el PK en la coordenada X { pk = ppr.Value.X; //comprobamos si el pk está dentro de los límites de la alineación. double este = 0; double norte = 0; //en caso de estar el pk fuera de los límites del eje, salta la excepción y se va al catch. alineacion.PointLocation(pk, 0, ref este, ref norte); } else //se trata de coordenadas de punto (x,y) { alineacion.StationOffset(ppr.Value.X, ppr.Value.Y, ref pk, ref offset); } tr.Commit(); IdLineaAux = toolsC3D.Objetos.Entidad_AutoCAD.ObtenerXline_Alineación(alineacion.ObjectId, pk, ModoTransversal); ed.WriteMessage("\nP.K: " + functions.funciones_genéricas.formatoPK(pk) + " " + "Azimut: " + functions.funciones_genéricas.stringdecimales(offset, 6) + " gon."); } catch { ed.WriteMessage("\nFUERA DE LÍMITES DEL EJE."); } } } } while (ppr.Status == PromptStatus.OK);