ModelState: iLogic form TEXT did not update

ModelState: iLogic form TEXT did not update

Frederick_Law
Mentor Mentor
672 Views
4 Replies
Message 1 of 5

ModelState: iLogic form TEXT did not update

Frederick_Law
Mentor
Mentor

What I'm trying to do:

1) Use iLogic rule to Add (Copy from active State) ModelState.

2) Show form to change parameters.

3) Allow user to type ModelState member name and change it.

 

1, 2 works well.

Failed on 3.

 

I have text parameter ActiveMember.

All other parameters updated the model after change in dialog box.

ActiveMember got updated in ModelState but the rule cannot see update after dialog box closed.

I tried oDoc.Update and Update2 after dialog box.

 

IV2023 file attached.

MSBug-02-01.jpg

0 Likes
Accepted solutions (1)
673 Views
4 Replies
Replies (4)
Message 2 of 5

Andrii_Humeniuk
Advisor
Advisor

Hi @Frederick_Law . I changed your code a bit, form and added an event, I hope the result suits you. Tested in 14-42, 14-44, 14-46 and built 14-47 seems to work very well.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 5

Frederick_Law
Mentor
Mentor

Thanks, I'm on IV2023.

I'll see if I can install 2024 later.

0 Likes
Message 4 of 5

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Changes as I made:

Sub Main()
	Dim oDoc As PartDocument = ThisDoc.Document
	Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim oModelStates As ModelStates
	Dim oModelState As ModelState
	Dim oModelStateOld As ModelState
	Dim oOccu As ComponentOccurrence
	Dim oOccuDef As ComponentDefinition
	Dim oOccuDoc As Document
	Dim OldState As String
	Dim newSize As Double = WPFLength
	If oCompDef.IsModelStateFactory Then
		oModelStateOld = oCompDef.ModelStates.ActiveModelState		
		If oModelStateOld.Name <> "14-" & newSize Then	
			Parameter("WPFLength") = oModelStateOld.Name.Remove(0, oModelStateOld.Name.IndexOf("-") + 1)
			Try
				oCompDef.ModelStates.Item("14-" & newSize).Activate()
			Catch
				oModelState = oCompDef.ModelStates.Add("14-" & newSize)
			End Try
			Parameter("ActiveMember") = "14-" & newSize
			Parameter("WPFLength") = newSize
			Parameter("d0") = WPFLength - 0.03 in
		End If
	End If
End Sub

 EditForm.pngRuleEvent.png

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 5 of 5

Frederick_Law
Mentor
Mentor

Thanks.

I had it backward.

 

Need to rethink how I do iLogic.

0 Likes