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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Abbreviation Settings Update

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
RodWing
840 Views, 4 Replies

Abbreviation Settings Update

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

4 REPLIES 4
Message 2 of 5
Jeff_M
in reply to: RodWing

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

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 5
RodWing
in reply to: Jeff_M

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.

 

Message 4 of 5
Jeff_M
in reply to: RodWing

I've just run it a dozen times, saving between each run, no problems. Perhaps something else in the rest of your code is going awry and not being exposed until it gets to this function.
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 5
RodWing
in reply to: Jeff_M

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report