.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

draw object dinamically during prompt loop

1 REPLY 1
SOLVED
Reply
Message 1 of 2
joantopo
331 Views, 1 Reply

draw object dinamically during prompt loop

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.

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
1 REPLY 1
Message 2 of 2
joantopo
in reply to: joantopo

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);

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost