Hi, I'm trying to write an iLogic rule to batch apply the model state name to the iProperties fields because if one of those fields is wrong then an update needs to be made in about 8 places and it's really annoying and tedious. Pretty much have this so far...not sure where to access a model states iProperties. If anyone has any idea how to proceed or where to find the documentation that'll give some tips that'd be great
' ilogic rule ModelStates - Part Number Assignment
Sub Main()
Dim oDoc As Inventor.Document = ThisDoc.Document
Dim oStates As Inventor.ModelStates
Dim oState As Inventor.ModelState
For Each oState In oStates ' this line generates error
activeState = ThisDoc.ActiveModelState
curState = oDoc.ModelStateName
Next
End Sub
Solved! Go to Solution.
Solved by BM_Ashraf. Go to Solution.
Hi,
Try this Rule !
'This Rule is done By MechDS 19.10.2022 'For Help Please contact me Email: zezo15330@gmail.com 'Youtube 'https://www.youtube.com/MechInventor 'Grab cad 'https://grabcad.com/mech.inventor-1 Dim oDoc As Document = ThisApplication.ActiveDocument Dim oCompDef As ComponentDefinition = oDoc.ComponentDefinition 'Get the existing property Dim CustomPropSet As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties") Dim oMState As ModelState Dim MSCount As Integer Dim oProp() As [Property] Dim i As Integer For Each oMState In oCompDef.ModelStates i = i + 1 On Error Resume Next oProp(i - 1) = CustomPropSet.Item("MState" & i) If oProp(i - 1) Is Nothing Then oProp(i - 1) = CustomPropSet.Add(oMState.Name, "MState" & i) Else oProp(i - 1).value = oMState.Name End If Next Msgbox("There are " & i & " Model State(s) in the Document" & vbLf & vbLf & "The name(s) is (are) added to The custom Properites", MsgBoxStyle.Information + Msgboxstyle.OkOnly, "Model State")
Hope this can help you !
Can't find what you're looking for? Ask the community or share your knowledge.