How to change Model State of view in Drawing Document?

How to change Model State of view in Drawing Document?

W.Scott.Dempster
Enthusiast Enthusiast
423 Views
2 Replies
Message 1 of 3

How to change Model State of view in Drawing Document?

W.Scott.Dempster
Enthusiast
Enthusiast

I have a Part Document with various Model States. I have a macro which I would like to have change the active model state in its Drawing Document. Here is a snippet of code I am using. On the DV.ActiveModelState line, I am getting an error stating incorrect number of arguments of an invalid property assignment. Is there something wrong with this?

 

Sub ChangeModelState()
    Dim PN As String
    PN = "999998"

    Dim app As Application
    Dim IDW As DrawingDocument

    Set app = ThisApplication
    Set IDW = app.ActiveDocument
    Dim DV As DrawingView
    Set DV = IDW.ActiveSheet.DrawingViews(1)

    Dim DVfp As DrawingView 'Flat pattern
    Dim view As DrawingView

    Dim oPart As PartDocument
    Set oPart = IDW.ReferencedDocuments.Item(1) 

    Dim oModelState As ModelState
    Set oModelState = oPart.ComponentDefinition.ModelStates

    For Each view In IDW.ActiveSheet.DrawingViews
        If view.IsFlatPatternView = True Then
            Set DVfp = view
        End If
    Next view

    Dim fileName As String

    Dim i As Long
    Dim memberName As String

    memberName = "[Primary]"

    DV.ActiveModelState = memberName
    DVfp.ActiveModelState = memberName

End Sub

 

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @W.Scott.DempsterDrawingView.ActiveModelState is a ReadOnly Property.  To set its value, you need to use the DrawingView.SetActiveModelState method.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

W.Scott.Dempster
Enthusiast
Enthusiast

Thank you.

0 Likes