Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Bug With ProfileView Elevation Min and Max

2 ANTWORTEN 2
Antworten
Nachricht 1 von 3
Domzinator
71 Aufrufe, 2 Antworten

Bug With ProfileView Elevation Min and Max

i am experiencing an issue while getting the initial Min and Max elevation from a Newly create profile view: as the screenshot bellow the Min is 80 and the Max is 120

Domzinator_0-1735731779116.png

When Getting the Profile View Min and Max via code i initially get:

Domzinator_1-1735731820639.png

 

if i set the same elevation to 70 min and 130 max for example the profile view updates correctly and stets those Min and Max Correctly. Why is the initial ElevationMin & ElevationMax wrong when retrieving? but setting them works and also outputs correctly?

sample function:

 public void SetProfileViewElevations()
 {
     //Documents
     Document acadDoc = acadApp.DocumentManager.MdiActiveDocument;
     Database db = acadDoc.Database;
     Editor edt = acadDoc.Editor;
     CivilDocument civilDoc = civilApp.ActiveDocument;

     #region Variables
     ObjectId profileviewID = ObjectId.Null;
     double profileViewMinElevation;
     double profileViewMaxElevation;

     #endregion
     Application.MainWindow.Focus();


     //Selection
     try
     {
         //Ask User to Seelct Profile VIew
         PromptEntityOptions peo = new PromptEntityOptions("Select Profile View: ");
         peo.SetRejectMessage("Selected item is not valid.");
         peo.AllowNone = false;
         peo.AddAllowedClass(typeof(ProfileView), true);

         //Get Selected Results
         PromptEntityResult per = edt.GetEntity(peo);
         if (per.Status != PromptStatus.OK) return;

         //Set profile view object id
         profileviewID = per.ObjectId;


         //Start Transaction
         using (DocumentLock doclock = acadDoc.LockDocument())
         {
             using (Transaction trans = db.TransactionManager.StartTransaction())
             {
                 //Create the Profile view object
                 ProfileView selectedprofileView = trans.GetObject(profileviewID, OpenMode.ForRead) as ProfileView;
                 if (selectedprofileView == null) return;

                 //Get the Current Values for Elevations
                 profileViewMinElevation = selectedprofileView.ElevationMin;
                 profileViewMaxElevation = selectedprofileView.ElevationMax;



                 //Ask the User for a Min and Max Elevations for the Profile View
                 // Ask the user for a minimum elevation
                 PromptDoubleOptions minElevationOptions = new PromptDoubleOptions($"\nEnter Minimum Elevation (Current: {profileViewMinElevation}): ")
                 {
                     AllowNone = false,
                     DefaultValue = profileViewMinElevation
                 };

                 PromptDoubleResult minElevationResult = edt.GetDouble(minElevationOptions);
                 if (minElevationResult.Status != PromptStatus.OK) return;
                 profileViewMinElevation = minElevationResult.Value;

                 // Ask the user for a maximum elevation
                 PromptDoubleOptions maxElevationOptions = new PromptDoubleOptions($"\nEnter Maximum Elevation (Current: {profileViewMaxElevation}): ")
                 {
                     AllowNone = false,
                     DefaultValue = profileViewMaxElevation
                 };

                 PromptDoubleResult maxElevationResult = edt.GetDouble(maxElevationOptions);
                 if (maxElevationResult.Status != PromptStatus.OK) return;
                 profileViewMaxElevation = maxElevationResult.Value;




                 //Upgrade to Write for changes
                 selectedprofileView.UpgradeOpen();
                 selectedprofileView.ElevationRangeMode = ElevationRangeType.UserSpecified;

                 //Check if Elevation range Mode has been changed before trying to change values

                 if (selectedprofileView.ElevationRangeMode == ElevationRangeType.UserSpecified)
                 {
                     selectedprofileView.ElevationMin = profileViewMinElevation;
                     selectedprofileView.ElevationMax = profileViewMaxElevation;
                 }


                 trans.Commit();
                 edt.WriteMessage("\nProfile view Elevations Updated!\n");
             }//End Transaction

         }//End Documentlock
     }
     catch (Exception ex)
     {
         Application.ShowAlertDialog($"Error Encountered: {ex.Message}");

     }

 }//End Fucntion





Civil 3D Certified Professional
2 ANTWORTEN 2
Nachricht 2 von 3
Anton_Huizinga
als Antwort auf: Domzinator

You have to set Max value first, else Civil 3D might crash. I am not sure if that is your case but it was mine a while ago.

Nachricht 3 von 3
Domzinator
als Antwort auf: Anton_Huizinga

I have no issues setting the elevations. The issue is when getting the current elevations that isnt returning the correct values when selecting the profile view and reading the elevations. 

Civil 3D Certified Professional

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Rail Community


Autodesk Design & Make Report