This is similar to my previous post about the Ambient settings. In Civil 3D 2014 I am also trying to update the Abbreviation settings. As with the Ambient settings, the first running updates the Abbreviation settings without any problem. On a subsequent running I get a NULL exception on the SetAlignmentEnhancedAbbreviation method. Creating a new drawing with the Client's template and running this generates the exception the first time through.
I suspect that the cause of this error is the same as the Ambient setting problem.
Private Function UpdateAbbreviationSettings(ByRef civDoc As Autodesk.Civil.ApplicationServices.CivilDocument) As Boolean Dim i As Integer Dim iStart As Integer Dim iEnd As Integer Dim strValue As String UpdateAbbreviationSettings = False Try Dim abAlgET() As Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType abAlgET = {Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.AlignmentBeginningPoint, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.AlignmentEndPoint, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.CompoundSpiralLargeRadiusAtBeginning, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.CompoundSpiralLargeRadiusAtEnd, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.CompoundSpiralSmallRadiusAtBeginning, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.CompoundSpiralSmallRadiusAtEnd, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.CurveBeginning, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.CurveEnd, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.LineBeginning, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.LineEnd, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.SimpleSpiralLargeRadiusAtBeginning, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.SimpleSpiralLargeRadiusAtEnd, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.SimpleSpiralSmallRadiusAtBeginning, _ Autodesk.Civil.Settings.AbbreviationAlignmentEnhancedType.SimpleSpiralSmallRadiusAtEnd _ } iStart = LBound(abAlgET) iEnd = UBound(abAlgET) For i = iStart To iEnd strValue = civDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointEntityData.GetAlignmentEnhancedAbbreviation(abAlgET(i)) If strValue = "ABC" Then civDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointEntityData.SetAlignmentEnhancedAbbreviation(abAlgET(i), "XYZ") Else civDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointEntityData.SetAlignmentEnhancedAbbreviation(abAlgET(i), "ABC") End If Next UpdateAbbreviationSettings = True Catch ex As Exception End Try End Function
Again, any help would be most appreciated.
Thanks.
Rod Wing
Solved! Go to Solution.
Solved by RodWing. Go to Solution.
Rod, if you would use Imports and variables so you could shorten the code it would be much easier to read/follow. This code does so and is working for me in 2014, running multiple times and verifying the values are changing from to ABC, then XYZ, then ABC again.
Private Function UpdateAbbreviationSettings(ByRef civDoc As CivilDocument) As Boolean Dim strValue As String Dim abbrevs = civDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointEntityData UpdateAbbreviationSettings = False Try Dim abAlgET() As String abAlgET = [Enum].GetNames(GetType(AbbreviationAlignmentEnhancedType)) For Each enumname In abAlgET strValue = abbrevs.GetAlignmentEnhancedAbbreviation([Enum].Parse(GetType(AbbreviationAlignmentEnhancedType), enumname)) If strValue = "ABC" Then abbrevs.SetAlignmentEnhancedAbbreviation([Enum].Parse(GetType(AbbreviationAlignmentEnhancedType), enumname), "XYZ") Else abbrevs.SetAlignmentEnhancedAbbreviation([Enum].Parse(GetType(AbbreviationAlignmentEnhancedType), enumname), "ABC") End If Next UpdateAbbreviationSettings = True Catch ex As SystemException End Try End Function
Thanks for the condensed code.
I copied your code into my module, but still get the same result. It modifies the value to ABC the first time. When I save the drawing and run it again it throws a NULL Exception when trying to change the value to XYZ.
I found that setting CommandFlags.Session in the CommandMethod causes the Exception. If I remove it the function runs fine. That bings up another issue in that I need to execute this on multiple documents. Something else I will have to deal with.
Thank you for your assistance Jeff.