AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

programatically create a style override

0 REPLIES 0
Reply
Message 1 of 1
admin
287 Views, 0 Replies

programatically create a style override

I am trying to programatically create a new display representation style override on an existing wall style.  I've found how to alter an existing override, but can't quite get how to make an new one.  Can anyone point me in the right direction?

 

    Public Shared Sub ChangeDispComponentOverride()
        Dim objDB As Database = HostApplicationServices.WorkingDatabase
        Using trans As Transaction = objDB.TransactionManager.StartTransaction
            Dim dicWallStyles As DictionaryWallStyle = New DictionaryWallStyle(objDB)
            Dim idWallStyle As AcObjectId = dicWallStyles.GetAt("1C10")
            Dim styWall As WallStyle = idWallStyle.GetObject(OpenMode.ForRead)
            Dim mngrDispRep As New DisplayRepresentationManager(objDB)
            Dim colIDs As AcObjectIdCollection = mngrDispRep.GetAllDisplayRepresentationsWorkForSpecifiedClass(RXClass.GetClass(GetType(Wall)))
            For Each idObject As AcObjectId In colIDs
                Dim objDispRep As DisplayRepresentation = idObject.GetObject(OpenMode.ForRead)
                Select Case objDispRep.DisplayRepresentationName
                    Case "Aa-Plan Floor Typ"
                        objDispRep.UpgradeOpen()
                        Dim objDispPropNew As New DisplayProperties
                        objDispPropNew.SetDisplayRepDefaults(objDispRep)
                        Dim colStrings As StringCollection = New StringCollection()
                        Dim arrayDispComps As DisplayComponent() = objDispPropNew.GetDisplayComponents(colStrings)
                        If arrayDispComps.Length > 0 Then
                            For I As Integer = 0 To arrayDispComps.Length - 1
                                Dim objDispComp As DisplayComponent
                                Dim strName As String = colStrings(I)
                                If strName.StartsWith("Shrink") Or strName.StartsWith("Boundary") Or strName.StartsWith("Hatch") Then
                                    objDispComp = arrayDispComps(I)
                                    Dim objDispCompEnt As DisplayComponentEntity = objDispComp
                                    Select Case True
                                        Case strName.StartsWith("Shrink Wrap Hatch")
                                            objDispCompEnt.IsVisible = False
                                        Case strName.StartsWith("Shrink Wrap")
                                            objDispCompEnt.IsVisible = True
                                        Case strName.StartsWith("Boundary")
                                            objDispCompEnt.IsVisible = True
                                        Case strName.StartsWith("Hatch")
                                            objDispCompEnt.IsVisible = False
                                    End Select
                                End If
                            Next I
                        End If
                        'objDispRep.SetOverriddenDisplayPropertiesDefaults(objDispPropNew)
                        objDispRep.SetEnforcedOverridenDisplayPropertiesValues(objDispPropNew)
                        'trans.AddNewlyCreatedDBObject(objDispPropNew, True) '** eNotInDatabase
                End Select

                'Dim idOverride As AcObjectId = objDispRep.FindDisplayPropertiesOverride(styWall) '***need to be able to set a new override, not just find an existing one
                'If Not idOverride.IsNull Then
                '    Dim objOverride As DisplayProperties = idOverride.GetObject(OpenMode.ForRead)
                '    Dim colStrings As StringCollection = New StringCollection()
                '    Dim arrayDispComps As DisplayComponent() = objOverride.GetDisplayComponents(colStrings)
                '    If arrayDispComps.Length > 0 Then
                '        For I As Integer = 0 To arrayDispComps.Length - 1
                '            Dim objDispComp As DisplayComponent
                '            Dim strName As String = colStrings(I)
                '            If strName.StartsWith("Shrink") Or strName.StartsWith("Boundary") Or strName.StartsWith("Hatch") Then
                '                objOverride.UpgradeOpen()
                '                objDispComp = arrayDispComps(I)
                '                Dim objDispCompEnt As DisplayComponentEntity = objDispComp
                '                Select Case True
                '                    Case strName.StartsWith("Shrink Wrap Hatch")
                '                        objDispCompEnt.IsVisible = True
                '                    Case strName.StartsWith("Shrink Wrap")
                '                        objDispCompEnt.IsVisible = True
                '                    Case strName.StartsWith("Boundary")
                '                        objDispCompEnt.IsVisible = True
                '                    Case strName.StartsWith("Hatch")
                '                        objDispCompEnt.IsVisible = True
                '                End Select
                '            End If
                '        Next I
                '    End If
                'End If

            Next idObject
            trans.Commit()
        End Using
    End Sub

 

0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report

”Boost