Untitled

 avatar
unknown
csharp
a year ago
5.9 kB
15
Indexable
  [CommandMethod("PROFILE_EXPRESS")]
        public void PROFILE_EXPRESS()
        {
            //  CONFIGURAÇÃO DAS OPÇÕES DE SELEÇÃO
            TypedValue TVTipo = new TypedValue((int)DxfCode.Start, "LWPOLYLINE");         
            SelectionFilter SF = new SelectionFilter( new TypedValue[] { TVTipo });
            PromptSelectionOptions SOpts = new PromptSelectionOptions();
            SOpts.MessageForAdding = "\nSelecione as polylines";
            SOpts.MessageForRemoval = "\nApenas polylines";
            // PEGA AS POLYLINES
            PromptSelectionResult SelPolys = Manager.DocEditor.GetSelection(SOpts, SF);
            if (SelPolys.Status != PromptStatus.OK)
            {
                return;
            }

            PromptEntityOptions OptsSurf = new PromptEntityOptions("\nSelecione a surperfície");
            OptsSurf.SetRejectMessage("\nApenas Superficies");
            OptsSurf.AddAllowedClass(typeof(TinSurface), true);

            PromptEntityResult SelSurf = Manager.DocEditor.GetEntity(OptsSurf);
            if (SelSurf.Status != PromptStatus.OK) {
                return;      
            }

            F_ESTILOS Janela = new F_ESTILOS();
            Janela.ShowDialog();
            if (!Janela.Fazer)
            {
                return;
            }
            PromptPointResult PTClicado = Manager.DocEditor.GetPoint("\nPonto Clicado");
            if (PTClicado.Status !=  PromptStatus.OK)
            {
                return;
            }


            // PEGA O ID DO ESTILO ALINHAMENTO
            ObjectId IDEstiloAlinhamento = Manager.DocCivil.Styles.AlignmentStyles[Janela.NomeEstiloAlinhamento];
            ObjectId IDLabelsAlinhamento = Manager.DocCivil.Styles.LabelSetStyles.AlignmentLabelSetStyles[Janela.NomeLabelAlinhamento];
            ObjectId IDEstiloVistaPerfil = Manager.DocCivil.Styles.ProfileViewStyles[Janela.NomeEstiloVista];
            ObjectId IDEstiloPerfil = Manager.DocCivil.Styles.ProfileStyles[Janela.NomeEstiloTerreno];
            ObjectId IDEstiloLabelPerfil = Manager.DocCivil.Styles.LabelSetStyles.ProfileLabelSetStyles[Janela.NomeLabelsPerfil];
            ObjectId IDBandSet = Manager.DocCivil.Styles.ProfileViewBandSetStyles[Janela.NomeEstiloBand];
            ObjectId IDEstiloGreide = Manager.DocCivil.Styles.ProfileStyles[Janela.NomeEstiloGreide];

            using (DocumentLock Lock = Manager.DocCAD.LockDocument())
            {
                using (Transaction TransCAD = Manager.DocData.TransactionManager.StartTransaction())
                {
                    LayerTable TabelaLayer = TransCAD.GetObject(Manager.DocData.LayerTableId, OpenMode.ForRead) as LayerTable;
                    ObjectId IDLayer = TabelaLayer["0"];

                    TinSurface Terreno = TransCAD.GetObject(SelSurf.ObjectId, OpenMode.ForRead) as TinSurface;


                    ProgressMeter PB = new ProgressMeter();
                    PB.SetLimit(SelPolys.Value.Count);
                    PB.Start("Processando");
                   
                           
                    double X = PTClicado.Value.X;
                    double Y = PTClicado.Value.Y;

                    for (int i = 0; i < SelPolys.Value.Count; i++)
                    {
                        PolylineOptions OptsPL = new PolylineOptions();
                        OptsPL.PlineId = SelPolys.Value[i].ObjectId;
                        OptsPL.EraseExistingEntities = Janela.ApagarPL;
                        string NomeAlinhamento = "Eixo - " + SelPolys.Value[i].ObjectId.Handle.Value.ToString();
                        string NomePerfil = "Perfil - " + Terreno.Name;
                        string NomePerfilVista = "Perfil - " + NomeAlinhamento;
                        string NomeGreide = "Greide - " + NomeAlinhamento;
                        ObjectId IDNovoAlinhamento = Alignment.Create(Manager.DocCivil, OptsPL, NomeAlinhamento, ObjectId.Null, IDLayer, IDEstiloAlinhamento, IDLabelsAlinhamento);
                        Alignment ALCriado = TransCAD.GetObject(IDNovoAlinhamento, OpenMode.ForRead) as Alignment;
                        
                        ObjectId IDPerfilTerreno =  Profile.CreateFromSurface(NomePerfil, IDNovoAlinhamento, SelSurf.ObjectId, IDLayer, IDEstiloPerfil, IDEstiloLabelPerfil);
                        Profile PerfilTerreno = TransCAD.GetObject(IDPerfilTerreno, OpenMode.ForRead) as Profile;

                        double CotaInicial = PerfilTerreno.ElevationAt(0);
                        double CotaFinal = PerfilTerreno.ElevationAt(ALCriado.EndingStation);


                       
                        ObjectId IDPerfilGreide =   Profile.CreateByLayout(NomeGreide, IDNovoAlinhamento, IDLayer, IDEstiloGreide, IDEstiloLabelPerfil);
                       
                        Profile PerfilGreide = TransCAD.GetObject(IDPerfilGreide, OpenMode.ForWrite) as Profile;


                        Point2d PT1 = new Point2d(0, CotaInicial);
                        Point2d PT2 = new Point2d(ALCriado.EndingStation, CotaFinal);
                        PerfilGreide.Entities.AddFixedTangent(PT1, PT2);

                                             
                        Point3d PTFazerPerfil = new Point3d(X, Y, 0);
                        ObjectId IDPerfil =  ProfileView.Create(Manager.DocCivil, NomePerfilVista, IDBandSet, IDNovoAlinhamento, PTFazerPerfil);
                        ProfileView PerfilCriado = TransCAD.GetObject(IDPerfil, OpenMode.ForWrite) as ProfileView;
                        X = PerfilCriado.GeometricExtents.MaxPoint.X + 20;
                        PB.MeterProgress();
                        System.Windows.Forms.Application.DoEvents();
                    }
                    PB.Stop();
                    TransCAD.Commit();
                }
            }
        }
Editor is loading...
Leave a Comment