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
When Getting the Profile View Min and Max via code i initially get:
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 FucntionYou 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.
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.
Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.