Activate an assembly design view from a drawing

Activate an assembly design view from a drawing

mgrenier1
Advocate Advocate
123 Views
2 Replies
Message 1 of 3

Activate an assembly design view from a drawing

mgrenier1
Advocate
Advocate

I'm trying to write an iLogic rule to change design view representations for each assembly views present on a drawing sheet.

Capture d’écran 2025-07-17 090859.png

Here's what I have so far :

 

' iLogic - Changer la vue de représentation via SetDesignViewRepresentationName
Imports System.Windows.Forms

Dim docDessin As DrawingDocument = ThisDoc.Document
Dim feuilleActive As Sheet = docDessin.ActiveSheet

Dim vuesReprésentations As New List(Of String)
Dim vuesAssemblages As New List(Of DrawingView)

' Collecte des vues de représentations disponibles dans les assemblages
For Each vue As DrawingView In feuilleActive.DrawingViews
    If vue.ReferencedDocumentDescriptor IsNot Nothing Then
        Dim docRef As Document = vue.ReferencedDocumentDescriptor.ReferencedDocument
        If docRef.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
            Dim asmDoc As AssemblyDocument = docRef

            vuesAssemblages.Add(vue)

            For Each rep As DesignViewRepresentation In asmDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations
                If Not vuesReprésentations.Contains(rep.Name) Then
                    vuesReprésentations.Add(rep.Name)
                End If
            Next
        End If
    End If
Next

If vuesReprésentations.Count = 0 Then
    MsgBox("Aucune vue de représentation trouvée dans les assemblages de la feuille active.", MsgBoxStyle.Critical)
    Return
End If

vuesReprésentations.Sort()
Dim vueChoisie As String = InputListBox("Sélectionnez la vue de représentation à appliquer :", vuesReprésentations, vuesReprésentations(0), "Choix de la vue", "Sélection requise")

If String.IsNullOrEmpty(vueChoisie) Then
    MsgBox("Aucune vue sélectionnée. Opération annulée.", MsgBoxStyle.Information)
    Return
End If

' Appliquer la vue de représentation sélectionnée via SetDesignViewRepresentationName
For Each vue As DrawingView In vuesAssemblages
    Try
        vue.ReferencedDocumentDescriptor.SetDesignViewRepresentationName(vueChoisie, True)
    Catch ex As Exception
        MsgBox("Erreur lors de l'application à la vue '" & vue.Name & "': " & ex.Message)
    End Try
Next

iLogicVb.UpdateWhenDone = True

 

I just can't get it to work, ChatGPT has been going circles on this for a while now and is not very helpful

 

Any ideas how to do achieve this?

0 Likes
Accepted solutions (1)
124 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

It looks like you would just need to use the following Inventor API method for doing that.

DrawingView.SetDesignViewRepresentation method

But to use that method, you would need to know the name of the design view representation that you want to set the view to, because it must be one that exists within the document that is being directly referenced by that drawing view.

And to check which one a drawing view is currently set to, you can use the following property.

DrawingView.DesignViewRepresentation (ReadOnly Property)

DrawingView.DesignViewAssociative (ReadOnly Property)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

mgrenier1
Advocate
Advocate

Awesome, thanks a lot

0 Likes