ModelStates iLogic rule for drawing

ModelStates iLogic rule for drawing

mgrenier2
Collaborator Collaborator
374 Views
2 Replies
Message 1 of 3

ModelStates iLogic rule for drawing

mgrenier2
Collaborator
Collaborator

I'm looking to make a rule that would set the default modelstate for all the views on every sheet of a drawing

This is what ChatGPT gave me but it is spitting out some errors

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet
For Each oSheet In oDoc.Sheets
    Dim oView As DrawingView
    For Each oView In oSheet.DrawingViews
        If oView.ReferencedModelDocument IsNot Nothing Then
            Dim oModelState As ModelState = oView.ReferencedModelState
            If oModelState.Name <> "Default" Then
                oView.ReferencedModelState = oView.ReferencedModelDocument.ModelStateManager.Item("Default")
            End If
        End If
    Next
Next

 

Can someone help?

 

0 Likes
375 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Hi @mgrenier2 

 

Using the API help pages you can check the active modelstate of the view and then use SetActiveModelstate method.

Syntax

DrawingView.ActiveModelState() As String

 

Syntax

DrawingView.SetActiveModelStateModelState As String, [UpdatePartsList] As Boolean, [KeepOverrides] As Boolean )

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

Frederick_Law
Mentor
Mentor

Need to get to each View in Sheet to change ModelState.

Dim oMSName as String

oMSName = "ModelState name to change to"
For Each oDrawingView In oIDWFile.ActiveSheet.DrawingViews
	If oDrawingView.ActiveModelState <> oMSName Then
		Logger.Info(oDrawingView.Label.Text & " " & oDrawingView.ActiveModelState)
		oDrawingView.SetActiveModelState(oMSName, True, True)
	End If

	oSheet.Update
	oIDWFile.Update
Next
0 Likes