Updating a Profile mode using Profile.UpdateMode

By Partha Sarkar

AutoCAD Civil
3D Profile type has a property named UpdateMode which can be used to get or set
the update mode of the profile.

Here is a
note from the Civil 3D API reference document help file on Profile.UpdateMode property
which I would like to draw your attention - 

Gets for
Superimposed, EG, CorridorFeature only. Sets for surface profiles only.
Specifies whether the profile updates automatically to reflect changes in
surface elevation.

System.InvalidOperationException
is thrown when setting the UpdataMode which profile's type is not EG.

 

Here is a C#
code snippet which demonstrates the usage of this API –

 

Profile profile = trans.GetObject(profileId, OpenMode.ForRead) as Profile;
 
if (profile.ProfileType == ProfileType.EG)
{
  ed.WriteMessage("nSelected Profile is of Type : " + profile.ProfileType.ToString());
  ed.WriteMessage("nUpdateMode Before Change :" + profile.UpdateMode.ToString());
 
  // update using Profile.UpdateMode
  // Gets for Superimposed, EG, CorridorFeature only. 
  // Sets for surface profiles only. 
  profile.UpgradeOpen();
  profile.UpdateMode = ProfileUpdateType.Dynamic;
  ed.WriteMessage("nUpdateMode After Change :" + profile.UpdateMode.ToString());
 
}
 
else
{
  ed.WriteMessage("nSelected Profile is of Type : " + profile.ProfileType.ToString() + "  Can not update the Mode");
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading